List Info

Thread: Including an external JS/GM script library




Including an external JS/GM script library
user name
2006-05-26 19:16:21
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-bouncesmozdev.org 
|[mailto:greasemonkey-bouncesmozdev.org] On Behalf Of
Lenny Domnitser
|Sent: Friday, May 26, 2006 1:29 PM
|To: greasemonkeymozdev.org
|Subject: Re: [Greasemonkey] Including an external JS/GM
script library
|
n
5/26/06, Philip Friedman - Auto Europe 
|<philipautoeurope.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
|Greasemonkeymozdev.org
|http:
//mozdev.org/mailman/listinfo/greasemonkey
|
_______________________________________________
Greasemonkey mailing list
Greasemonkeymozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
Including an external JS/GM script library
user name
2006-05-26 19:19:37
On 5/26/2006 3:16 PM, Philip Friedman - Auto Europe wrote:
> 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?

The common workaround is to add a random value into the
querystring.
_______________________________________________
Greasemonkey mailing list
Greasemonkeymozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
Including an external JS/GM script library
user name
2006-05-27 01:32:51
XMLHttpRequest's are not cached.

Adam



On 26/05/06, Anthony Lieuallen <arantiusgmail.com> wrote:
> On 5/26/2006 3:16 PM, Philip Friedman - Auto Europe
wrote:
> > 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?
>
> The common workaround is to add a random value into the
querystring.
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkeymozdev.org
> http:
//mozdev.org/mailman/listinfo/greasemonkey
>
_______________________________________________
Greasemonkey mailing list
Greasemonkeymozdev.org
http:
//mozdev.org/mailman/listinfo/greasemonkey
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )