[Greasemonkey] GM_log

Shaun Etherton shaun at synect.com
Fri Jul 1 14:15:39 EDT 2005


Hi Bill,

This is exactly what I had in mind.
Thanks heaps.


On Thu, 2005-06-30 at 20:17 -0700, Bill Donnelly wrote:
> You can do this, which might be better than nothing. (+/-)
> 
> Install the GmScript below and you can use:
> 
>    JS_log ("message text");
> 
> but only after onLoad time, or thereabouts.
> 
> Page JS is executed before GmScripts are injected and
> executed, so JS_log() will not be defined until then.
> 
> I think you can also do the following:
> 
>    if (JS_log != undefined)
>       JS_log ("message");
> 
>    else
>       alert ("message");
> 
> Or, make it an included function in your HTML page(s)
> and make your own function:
> 
> function debug (sMsg) {
> 
>    if (JS_log != undefined)
>       JS_log (sMsg);
> 
>    else
>       alert (sMsg);
> 
>    return;
> }
> 
> ==================================================
> 
> /*
>    jslog.user.js
> 
>    JS_log() == GM_log()
> 
>    Make GM_log() functionality available to HTML page scripts
>       as JS_log() (after onload +/-)
> 
>    You can make your own included function in your HTML page(s)
>       as follows:
> 
>          function debug (sMsg) {
> 
>             if (JS_log != undefined)
>                JS_log (sMsg);
> 
>             else
>                alert (sMsg);
> 
>             return;
>          } // debug
> */
> 
> // userscript metadata follows...
> 
> // ==UserScript==
> // @name          JS_logger
> // @namespace     http://www.snowcrest.net/donnelly/gmscripts/
> // @description   Make GM_log() functionality available to HTML page scripts
> // @include       *
> // @Version       1.0.0
> // @GmVersion     0.3.4
> // @Author        William Donnelly
> // @Email         snowcrest.net | donnelly
> // ==/UserScript==
> 
> (function() {
> 
>    window.JS_log = GM_log;
> 
> })();
> 
> ==================================================
> 
> <html>
> <head>
> 
> <script language='javascript'>
> 
> function tryit() {
> 
>    JS_log ("\r\n" + location.href);
> 
> }
> 
> </script>
> 
> </head>
> <body bgColor="black" text="white" onload="tryit()">
> Testing JS_log()
> </body>
> </html>
> 
> ==================================================
> 
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
-- 
Shaun Etherton <shaun at synect.com>



More information about the Greasemonkey mailing list