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 8834969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:09:03+00:00 2026-06-14T09:09:03+00:00

Im working on a greasemonkey script, which injects a block of code into the

  • 0

Im working on a greasemonkey script, which injects a block of code into the page. That code then creates a script tag directed to a 3rd party source using the following:

function injectThis(){
    var s = document.createElement("script");
    s.src = "http://site.com/file.js";
    s.head.appendChild(s);

    // other code to be executed once the above file has finished downloading

}

Is there a way to make the engine block until the retrieval and processing of the script has completed?

A few notes:
1: A syncronized xhr is out of the question b/c it’s cross domain
2: gm_xhr is out of the question due to the purpose of the script Im working on
3: Adding an event/callback in file.js to indicate loaded isn’t a solution due to the same reason #2 isn’t

  • 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-14T09:09:04+00:00Added an answer on June 14, 2026 at 9:09 am

    Why not listen to the onload of the script tag, and then fire your other stuff afterward?
    If you need old-IE support, you can also listen for onreadystatechange.

    The only way you’re going to cause a synchronous load is by using .innerHTML or, much worse, document.write.

    Much better would be to set script.onload = function () { callOtherStuff(); };.

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

Sidebar

Related Questions

I am writing a greasemonkey script that is parsing a page with the following
I am working on a Greasemonkey script that will actually upgrade the version of
Recently I've been working on a Greasemonkey script that would add an image to
I have written my first script for Greasemonkey, it is working great, except that
I've created a Greasemonkey script which replaces a page function: (function() { var oldFunc
I am working on a greasemonkey script for gmail where i need to make
I'm trying to get a jsonp callback working using jquery within a greasemonkey script.
I'm working on a greasemonkey script, but the str.replace function isn't working. I'm trying
I'm trying to write a Greasemonkey script that works with Gmail. the script is
I'm making a Greasemonkey script and would like to open a new tab which

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.