javascript - How to get a Greasemonkey script to run both at @run-at document-start AND at @run-at document-end? -
 For my Grayscenky script, a part of the code that should be played before the page is loaded (  I do not use jQuery for this.    I tried the     You want the event to be   Here is a complete script that shows the various firing times:    Specific results:   @ Run-document-start ) and the second part of the code should be run after the document ( @ run-at document-end ). Is this possible?   onload  event but it was not working. I think the event can not be added if the document is not yet?   
 window.document.onload = function (e) {alert ("document.onload"); }    DOMContentLoaded . In addition, it is not how to use the  load  event.   
 // = = UserScript == // @name_ Show the page Start the event time / Include / @http: //your_SERVER.COM/YOUR_PATH/* // run-in document-start // ==/userscript == console.log ("==> script start.", New date ( )); // Part of a portion of 1 script goes here Console.log ("==> First part of running the script.", New Date ()); Document.addEventListener ("DOMContentLoaded", DOM_ContentReady); Window.addEventListener ("Loaded", Page Loaded Fully); The function goes to DOM_ContentReady () {// script two part 2 here. // This is equal to "run-in document-and console.log (" ==> second part of running script. ", New date ()); } Function Page Fully Loaded () {console.log ("==> Page is fully loaded, including images.", New Date ()); } Console.log ("==> Script End.", New Date ());   
  
 "==> Start the script." 2014-10-09T01: 53: 49.323Z "==" gt; The first part of running the script '2014-10-09T01: 53: 49.323Z "==> Script End." 2014-10-09T01: 53: 49.323Z "==" gt; The second part of running the script. 2014-10-09T01: 53: 49.385Z "==> The page is completely full, including images." 2014-10-09T01: 53: 49.487Z    
 
  
Comments
Post a Comment