[Greasemonkey] access to injected scripts?

Edward Lee edilee at gmail.com
Sat May 28 23:19:51 EDT 2005


On 5/28/05, Bill Donnelly <donnelly at snowcrest.net> wrote:
> I wanted to be able to "see" all injected scripts.

Well.. this seems like it can only be solved with additional GM
support because GM removes the scripts.

Hackyish... provide a GM_getScripts() [I suppose getSelf could be
bundled into there where it checks the argument]. The function would
return an array of all the scripts, but the problem is that it would
only show the scripts that have been injected so far if the current
script calls GM_getScript right away.

var allScripts = new Array();
allScripts.unshift(getContents..) // add to the array the script
contents when injecting
window.GM_getScripts = function() { return allScripts; }

As long as the allScripts keeps getting updated, later (delayed
setTimeout/events) calls to the function will get all the scripts even
those that ran afterward it.

Actually, a script could call GM_getScripts() right away and the
contents of the array would have itself at the beginning, so there
would be no need for a GM_getSelf(). Just do a GM_getScripts()[0] to
get the script itself. :)

-- 
Ed


More information about the Greasemonkey mailing list