Bingo! Thanks Lenny! Gareth's import looks like an answer
at install time,
but I went with your GM_xmlhttpRequest/eval suggestion. Is
there a way to
turn caching off in GM_xmlhttpRequest so that the user
always gets the
latest? Maybe a value in the headers?
Here's the example, that works for the two files in the
same directory on
the server. Note that libraryTest.user.js includes
itself, so the URL
construction won't make sense in the real world.
File libraryTest.user.js:
// ==UserScript==
// name LibraryTest
// namespace /phil
// description Library Test
// include http://*libraryTest.user.
js
// exclude
// ==/UserScript==
GM_xmlhttpRequest( { method:'GET'
,
url:document.location.href.replace(/\/[^\/]*$/,'/library.
js')
, onload: onLoadLibrary
} );
function onLoadLibrary(rsp) {
eval(rsp.responseText);
libraryAlert();
}
File library.js:
function libraryAlert() {
alert('libraryAlert');
GM_log('libraryAlert');
}
--
Regards, Phil Friedman - Auto Europe
|-----Original Message-----
|From: greasemonkey-bounces mozdev.org
|[mailto:greasemonkey-bounces mozdev.org] On Behalf Of
Lenny Domnitser
|Sent: Friday, May 26, 2006 1:29 PM
|To: greasemonkey mozdev.org
|Subject: Re: [Greasemonkey] Including an external JS/GM
script library
|
n
5/26/06, Philip Friedman - Auto Europe
|<philip autoeurope.com> wrote:
|> So, Is there a way to split GM scripts into multiple
files and have
|> one "include" another, but both be in the
"safe sandbox" and
|both have
|> access to GM_ functions?
|
|There has been some promising-looking work on doing just
that
|(Gareth Andrew's GM imports
|<http://www.mozdev.org/pipermail/greasemonkey/2005-
September/00
|5645.html>).
|
|For now, if you're pulling the script from a guaranteed
safe
|server, like localhost, then you can use a combination of
|GM_xmlhttpRequest and eval to run the code in the
Greasemonkey sandbox.
|_______________________________________________
|Greasemonkey mailing list
|Greasemonkey mozdev.org
|http:
//mozdev.org/mailman/listinfo/greasemonkey
|
_______________________________________________
Greasemonkey mailing list
Greasemonkey mozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
|