UserScript.org Install Link On All Script Pages

By Erik Vold Last update Mar 7, 2010 — Installed 1,072 times.

There are 6 previous versions of this script.

// ==UserScript==
// @name		UserScripts.org Install Link On All Script Pages
// @author		Erik Vergobbi Vold
// @namespace	userscriptsOrgInstallLinkOnAllScriptPages
// @include		/https?:\/\/userscripts\.org\/(scripts\/[^\/]*|topics|reviews)\/.*/i
// @include		http*://userscripts.org/scripts/*/*
// @include		http*://userscripts.org/topics/*
// @include		http*://userscripts.org/reviews/*
// @match		http://userscripts.org/scripts/*/*
// @match		http://userscripts.org/topics/*
// @match		http://userscripts.org/reviews/*
// @version		0.2.2
// @datecreated	2009-08-15
// @lastupdated	2010-03-06
// @license		GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @description	This userscript will add the install link for userscripts on userscripts.org to all pages associated to the script, beyond the current page it is limited to, which is the 'About' page.
// ==/UserScript==

(function(){
	var installDiv=document.getElementById("install_script");
	if(installDiv) return;

	var contentDiv=document.getElementById("content");
	if(!contentDiv) return;
	var headingDiv=document.getElementById("heading");
	if(!headingDiv) return;

	var scriptID=document.evaluate('.//div[@id="details"]//a[contains(@href,"/scripts/show/")]',headingDiv,null,9,null).singleNodeValue;
	if(!scriptID) return;
	scriptID = scriptID.href.match(/\d+/i);

	installDiv=document.createElement("div");
	installDiv.id="install_script";
	installDiv.innerHTML='<a class="userjs" href="http://userscripts.org/scripts/source/' + scriptID + '.user.js">Install</a><a title="how to use greasemonkey" class="help" href="/about/installing">How do I use this?</a>';

	contentDiv.insertBefore(installDiv,headingDiv);
})();