Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8472805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:10:40+00:00 2026-06-10T17:10:40+00:00

I am trying to inject some javascript into a site I do not own.

  • 0

I am trying to inject some javascript into a site I do not own. The code I am trying to inject is as follows:

function submitFormForTime(time){
    $(".t_h").each(function(i, obj){ // find each element with the class t_h
        if ($(this).text() != time) return; // not the right one
        $(this).parent().find("form").each(function(i, obj){
            obj.submit(); // submit that form
        });
    });
}

This does not work. It seems that the method I am using, stringByEvaluatingJavaScriptFromString, does not work with nested brackets or whatever. It works fine with simple code.

The problem is that the code is not being injected at all

My full code is as follows:

[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"var script = document.createElement('script');"
                            "script.type = 'text/javascript';"
                            "script.text = \"function submitFormForTime(time){ "
                                "$(\".t_h\").each(function(i, obj){"
                                "if ($(this).text() != time) return;"
                                    "$(this).parent().find(\"form\").each(function(i, obj){"
                                        "obj.submit();"
                                    "});"
                                "});"
                            "}\";"
                            "document.getElementsByTagName('head')[0].appendChild(script);"]];

Any help would be greatly appreciated. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:10:41+00:00Added an answer on June 10, 2026 at 5:10 pm

    Well without alot of trouble i can see a couple a small things. I rewrote it, maybe you can give it a try.

    [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@
                            "var script = document.createElement('script');"
                            "script.type = 'text/javascript';"
                            "script.text = function submitFormForTime(time) { $('.t_h').each(function(i, obj) { if ($(this).text() == time) $(this).parent().find('form').each(function(i, obj){ obj.submit(); }); }); } document.getElementsByTagName('head')[0].appendChild(script);"]];
    

    I hope it works like that.

    Basically i removed some double quotes, and replaced some with single quotes to not have to escape them. And i wrote all the script text on one line.

    AND find(‘form’) should be find(‘.form’) if form is a class or find(‘#form’) if form is an id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to inject some Javascript code into a webpage using Greasemonkey. First I
I'm trying to inject some Scala code into my existing Java app. (So, being
I'm attempting to inject some text (specifically a few lines of javascript code), into
I'm trying to inject some ASM code into a Win32 program with C++. Is
I was trying to inject code into the Finder process using mach_inject . I
I'm trying to have Python run some Javascript, and I am running into a
I'm trying to get my Chrome Extension to inject some javascript with content_scripts ,
I'm using Javascript to inject some stylized HTML into another webpage (which has been
I'm trying to add some styles into a page using javascript var style =
I'm trying to inject some properties into a parent class and child class, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.