FW: [Greasemonkey] Including other JS files and using "class" and custom styles

sam foster potatosculptor at gmail.com
Mon Aug 28 14:48:07 EDT 2006


Not with dojo, yet. I think Dojo does some bootstrapping that doesnt
make sense in the context of GM. It does support different execution
environments such as Rhino, via some host environment detection and
"shimming" or normalization of the environment. Its possible we need
to write something specific to GM to get it to work.
Or, it might be a simple patch that could be search/replaced in before
eval'ing the library. I've not dug in that deep yet.

I did have _some_ luck pulling in YUI. But hit a snag which I've not
had time to troubleshoot yet. I'll attach my test script.

Its possible (likely) I've bitten off too much here for a first pass,
and just buried a simple problem in too much complexity. But, can
anyone see what's going on? I'm trying to get the script eval'd so all
variables defined in the script are in a "global" scope. But so far,
when I test for the YAHOO object variable, its not defined, even
though the loading and eval itself went ok
(You'll need to replace my 'localhost' paths to ones that make sense for you)

Sam

On 8/25/06, Stefano POGLIANI <stefano at poglianis.net> wrote:
> Sam
>
>     were you able to succeed on this?
> Thanks
> /Stefano
>
>
> sam foster wrote:
> > Ah, I figured if I lurked for long enough someone would ask my
> > question for me :)
> > It seems like fetching the library asynchonously might cause problems?
> > Would GM allow the page's onload event to happen while my library was
> > being loaded?
> >
> > This seems like a common use case - its a drag pasting in and managing
> > these "includes".
> > I'd like to be able to pull in aol's dojo  from
> > http://o.aolcdn.com/iamalpha/.resource/jssdk/dojo-0.2.2/dojo.js
> > and keep it cached. Anyone tried this?
> >
> > Sam
> >
> >
> >> |
> >> |Philip Friedman - Auto Europe wrote:
> >> |> 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
> > _______________________________________________
> > Greasemonkey mailing list
> > Greasemonkey at mozdev.org
> > http://mozdev.org/mailman/listinfo/greasemonkey
>
>
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yuitest.user.js
Type: application/x-javascript
Size: 2155 bytes
Desc: not available
Url : http://mozdev.org/pipermail/greasemonkey/attachments/20060828/a4175cf9/yuitest.user.js


More information about the Greasemonkey mailing list