Is it possible to create a Greasemonkey script that can manage other userscripts?
I want to write a userscript that automatically installs a group of other userscripts, given a list of userscript URLs.

有帮助吗?

解决方案

No this is not possible. It would be a major security hole if it was.

The best you can do is trigger the install dialog, for each script, and let the user decide if she wanted to install the script.

If you figure a way around these restrictions, please let us know so that we can shut it down, post haste. ;-)



To trigger the download dialog:

  1. Get the direct, download URL.
    For example, for this script:
    (Click for larger image)Finding download URL

    The download URL is:
    http://userscripts.org/scripts/source/26062.user.js.

  2. Then your script would trigger the Greasemonkey Install dialog by sourcing that URL with an <iframe>.

    Here is a complete Greasemonkey script that demonstrates that:

    // ==UserScript==
    // @name     _Auto popup Greasemonkey Script Install Dialog
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @include  http://stackoverflow.com/faq
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    // @grant    GM_addStyle
    // ==/UserScript==
    
    var scriptJS_URL    = "http://userscripts.org/scripts/source/26062.user.js";
    
    $("body").append (
        '<iframe src="' + scriptJS_URL + '" class="gmImstallIframe"></iframe>'
    );
    
    GM_addStyle ( "                                 \
        iframe.gmImstallIframe {                    \
            width:                  1px;            \
            height:                 1px;            \
            border:                 none;           \
        }                                           \
    " );
    


  3. Important: There currently seems to be a bug with Greasemonkey (circa version 1.5). The Install button works, but the Show Script Source button appears to be busted for cross-domain scripts.

    Greasemonkey install pop-up

其他提示

In Firefox you can call the URL to the userscripts in a hidden frame to fluently create installment popups. Thats the closest you can get.

Doesn't work for Chrome-users anyway, and your real cause, to bypass that installation dialog, is - of course - not possible.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top