0

I want to run a short javascript file completely after the entire page and extensions are finished loading.

Even better, if I could delay the loading of the script until 100ms after the page and all extensions in the page are finished loading.

The objective is to to ensure that this javascript file cannot in any way be modified by any browser extension, especially in chrome or firefox. The idea and method in which I intend to force this javascript to run, is to run it only after any extension could possibly run.

  • I think this is a duplicate of http://stackoverflow.com/questions/978740/javascript-how-to-detect-if-document-has-loaded-ie-7-firefox-3 – Erik Apr 23 '13 at 11:56
  • Your question is confusing. You can add a listener to a link for example, and execute the part of code what you want. – Marcelo Rodovalho Apr 23 '13 at 11:57
  • 1
    Do you have any more information about the actual extensions that you want to deal with? Extensions can modify parts of the code at all times, not only when they're loaded. What you're asking for is not technically possible, you can just work around some extensions if you know their behavior. – likeitlikeit Apr 23 '13 at 12:19
  • adblock is the extension. –  Apr 23 '13 at 12:31

3 Answers3

1

If you are using jquery you could do :

$(document).ready(function()
{
    //Your code here
});

Hope this helps ! Bye !

Antoine
  • 548
  • 4
  • 13
  • I tried that. It did not work. Extension still modified the javascript. **Not solution**, but thanks for trying. –  Apr 23 '13 at 11:59
0

the onload event of the body tag should do this unless the extensions are initialising themselves in which case you will have to use their specific callbacks.

to delay something you would use setTimeout

setTimeout(function(){ }, 100);
Tom Elmore
  • 1,980
  • 15
  • 20
  • what do you mean by "their specific callbacks"? –  Apr 23 '13 at 12:05
  • I am presuming that if an extension takes time to initialise itself it should provide a callback to say it has finished. Can you say what it is that is modifying the page after it has loaded? – Tom Elmore Apr 23 '13 at 12:10
  • the extension is called adblock –  Apr 23 '13 at 12:11
  • Hm I dont know of any way to do that - I would expect an extension to be able to modify the page in any way and at any time it sees fit. This may be useful if you decide to take a different tack : http://stackoverflow.com/questions/4078765/can-a-website-detect-what-browser-extensions-are-being-used – Tom Elmore Apr 23 '13 at 12:19
0

You can use the onload event and calling your function.

<body onload="myFunction()">
Romain
  • 1,903
  • 2
  • 18
  • 23