Reputation: 31810
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.
Upvotes: 1
Views: 1823
Reputation: 93473
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:
Get the direct, download URL.
For example, for this script:
(Click for larger image)
The download URL is:
http://userscripts.org/scripts/source/26062.user.js
.
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; \
} \
" );
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.
Upvotes: 3
Reputation: 1761
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.
Upvotes: 2