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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:17:21+00:00 2026-06-01T20:17:21+00:00

Alright, so here is my issue. I’m writing a Greasemonkey script to insert two

  • 0

Alright, so here is my issue. I’m writing a Greasemonkey script to insert two iframes on an AJAXified site, but ajaxComplete gets caught in a loop and generates an excess number of iframes (sometimes one, sometimes five, etc…), gener.

I’ve done my research and [I think] my problem is that I’m not binding the call to the document properly, but of this I am unsure. I’m not sure how you would do it differently than I already have. If you guys could point me in the right direction I’d be grateful. Here is the offending code:

function OnLoadWidgets() {
    var tempSC = document.createElement("div");                                        
        tempSC.id = "SCWidget";
        tempSC.innerHTML = "..."
    document.getElementById("content-right").appendChild(tempSC);
    var tempMC = document.createElement("div");                                        
        tempMC.id = "MCWidget";
        tempMC.innerHTML = "..."
   document.getElementById("content-right").appendChild(tempMC);

}   

unsafeWindow.jQuery(document).ajaxComplete(function()
{   
    var existingSCPlayer = document.getElementById("SCWidget");                     
    if(typeof(existingPlayer) == "undefined")
    {
        OnLoadWidgets();
    }
});

You can see the rest of the code here:
http://userscripts.org/scripts/show/127312

Also wanted to use this a chance to thank you guys for all your hard work. Can’t thank you enough, really. stack == lifesaver

  • 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-01T20:17:22+00:00Added an answer on June 1, 2026 at 8:17 pm

    (1) The target site, hypem.com, uses its own iframes and your Greasemonkey script will fire on those also.

    Prevent this by adding:

    if (window.top != window.self)  //-- Don't run on frames or iframes.
        return;
    

    near the top of the script.

    (2) There is a variable name typo in the code. existingSCPlayer versus existingPlayer.

    (3) Refine the duplicate check to be a little more inclusive. Use this code:

    unsafeWindow.jQuery (document).ajaxComplete ( function () {
        var existingSCPlayer = document.getElementById ("SCWidget");
        var existingMCPlayer = document.getElementById ("MCWidget");
        if ( ! existingSCPlayer  &&  ! existingMCPlayer) {
            OnLoadWidgets();
        }
    } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright so here are my two tables. CREATE TABLE [cards] ( [id] TEXT PRIMARY
Alright, hard to phrase an exact title for this question, but here goes... I
Alright, so I'm having a bit of an issue here. Here is the loop.
Alright, so here is the situation... Say I have a navbar for a site,
Alright, here's the issue. In an attempt to advance my knowledge of C++ APIs,
Alright here it goes. Normally I'm doing alright in HTML, but for this specific
Alright so here is my issue. I'm working a game engine that will eventually
Alright, so I have the strangest issue here. I'm taking the mean of a
Alright, so here is my issue. I need to generate xml in Java to
Alright, here is a link to the site I am working on. http://danberinger.com/preview.html I

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.