how to include a js-file into a greasmonkey user scipt?

1,734 views
Skip to first unread message

rittergig

unread,
Aug 6, 2009, 2:15:33 PM8/6/09
to greasemonkey-users
Hi,
Is there a way to include an external js-file into my greasemonkey
scripts?

For example i want to include the toolbox.js.

I tried this way:
---------------------
function include ( JsFile )
{
var elementBody = document.getElementsByTagName('body').item(0);
var script = document.createElement('script');
script.src = JsFile ;
script.type = 'text/javascript';
//alert("1");
elementBody.appendChild(script)
//alert("2");
}

include ("toolbox.js");
------------------------

If i run this script in an normal html-file without gm it works fine.
But if i try this in a gm-script the js file will no be included, even
if i write the complete file name:
"file:///C:/Dokumente und Einstellungen/Peter/Anwendungsdaten/Mozilla/
Firefox/Profiles/***/gm_scripts/google_bilder_links_dire/toolbox.js"

What do i wrong?
Is there a easier and better way?

Thanks.

Anthony Lieuallen

unread,
Aug 6, 2009, 2:20:44 PM8/6/09
to greasemon...@googlegroups.com
On 8/6/2009 2:15 PM, rittergig wrote:
> Is there a way to include an external js-file into my greasemonkey
> scripts?

http://wiki.greasespot.net/Metadata_block#.40require

Reply all
Reply to author
Forward
0 new messages