Maybe not "straightforward" by Anthony's standards, but it does "include"
library.js in libraryTest.user.js as desired.
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 - 207-842-2069
|-----Original Message-----
|From:
greasemonkey-bounces@...
|[mailto:
greasemonkey-bounces@...] On Behalf Of Anthony Lieuallen
|Sent: Friday, August 04, 2006 9:33 AM
|To:
greasemonkey@...
|Subject: Re: [Greasemonkey] Including other JS files and using
|"class" and custom styles
|
|On 8/4/2006 4:18 AM, Stefano POGLIANI wrote:
|> 1. Does it work including an external Javascript script inside a GM
|> script?
|
|The only straightforward way is to copy and paste the source in.
|There's no "include" statement like in some other languages.
|
|> 2. Is there a way where I could use some "static HTML" to shortcut
|> the development time? If yes, does someone have an example?
|
|There's a number of ways. For example:
|
http://www.arantius.com/article/dollar-e|
|> 3. one of the issues related to my poor knowledge of JS is
|that, when
|> programmatically creating my widgets, I do not know how to set a
|> custom CSS class (the equivalent of saying <div class="myclass">
|> ..... how can I specify in Javascript this?)
|
|Since "class" is a reserved word in JavaScript, you have to
|use something else. In this case, className.
|
|> 4. associated to the latter. If I create my own CSS classes, can I
|> store their definition in a CSS style sheet file and "import" it
|> in the GM script? If yes, how?
|
|Yes.
|
http://diveintogreasemonkey.org/patterns/add-css.html|
|> 5. Final one. Can I use XUL inside a GM script?
|
|That question is a bit too open ended for me to understand
|fully; I can't be sure, because I don't know what you're
|really trying to do, but I suspect the answer is no.
|_______________________________________________
|Greasemonkey mailing list
|
Greasemonkey@...
|
http://mozdev.org/mailman/listinfo/greasemonkey|
_______________________________________________
Greasemonkey mailing list
Greasemonkey@...
http://mozdev.org/mailman/listinfo/greasemonkey