javascriptfirefoxgreasemonkey

Is it possible to use workers in a Greasemonkey script?


I would like to use the Web Worker facility introduced in Firefox 3.5 to enhance a Greasemonkey script I'm working on.

Is this even possible?

I've done some experimentation, but I can't get past the issue of loading a worker script from an arbitrary domain.

For example, this does not work:

var myWorker = new Worker("http://dl.getdropbox.com/u/93604/js/worker.js");

This code generates an error message in my Firebug console:

Failed to load script: http://dl.getdropbox.com/u/93604/js/worker.js (nsresult = 0x805303f4)

Apparently there's a limitation that does not allow you to start a worker from a URL that's not relative to the base URL of the calling script. You can load a worker script at a relative URL like this just fine:

var myWorker = new Worker("worker.js");

But there's no way for me to get the worker script on the user's filesystem so that it could be at a path relative to the calling script.

Am I screwed here? Should I give up on trying to use workers within my Greasemonkey script?


Solution

  • See:

    Can I load a web worker script from an absolute URL?