[Greasemonkey] Installing a user script via a data: url

Julien Couvreur julien.couvreur at gmail.com
Thu Apr 7 20:29:48 EDT 2005


> Jeremy says: Make a patch to accept a url starting "data:text/javascript"?  :)

Here's the patch.
Below is the replacement function for toolsMenuShowing in browser.xul.
The only difference is the logic to set "disabled" to true or false.

Jeremy, let me know if you can get this change it or if there is any problem.

Thanks,
Julien


function toolsMenuShowing(e) {
            var installItem = ge("userscript-tools-install");
            var commandsItem = ge("userscript-commands");

            var disabled;
            if (!window._content || !window._content.location) 
            {
                disabled = false;
            }
            else if
(window._content.location.href.match(/\.user\.js(\?|$)/i) != null)
            {
                disabled = false;
            } 
            else if
(window._content.location.href.match(/^data:text\/javascript;/i) !=
null)
            {
                disabled = false;
            }
            else 
            {
                disabled = true;
            }
            
            installItem.setAttribute("disabled", disabled.toString());
            commandManager.initToolsMenu(commandsItem);
          }


More information about the Greasemonkey mailing list