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

Julien Couvreur julien.couvreur at gmail.com
Thu Apr 7 20:35:14 EDT 2005


Of course, I had to find a bug the minute after I sent the email ;-)
In the very first case, disabled should be set to true, to match the
original behavior. Here's the fixed version.

Sorry about that,
Julien



            var disabled;
            if (!window._content || !window._content.location) 
            {
                disabled = true;
            }
            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;
            }




On Apr 7, 2005 7:29 PM, Julien Couvreur <julien.couvreur at gmail.com> wrote:
> > 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