Jump to content

User:Will Beback/cologneblue.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/**
 * HAPPI gadget
 *  
 * This gadget is part of a research study being conducted by the 
 * GroupLens Research lab at the University of Minnesota.  Please see 
 * the consent form at http://wikipedia.grouplens.org/HAPPI/consent.  
 * If you have questions/comments/suggestions, please direct them to 
 * User:EpochFail. 
 **/
importScript("User:EpochFail/HAPPI.js")


// This code will change ISBN links to point to the url of your choice,
// instead of Special:Booksources. 
//
// How to use it:
//
// First, you must copy this code to your user javascript page. This is 
// at User:<your username>/monobook.js . My username is Lunchboxhero so
// my javascript page is User:Lunchboxhero/monobook.js . You must be logged
// in to edit your javascript page.
//
// Once you have copied the code and saved the page, you need to refresh your
// browser's cache. For Mozilla/Safari/Konqueror: hold down Shift while clicking 
// Reload (or press Ctrl-Shift-R), IE: press Ctrl-F5, Opera: press F5.
//
// The code should now work, as long as you are logged in.
//
// You can change the destination URL.  Go to [[Wikipedia:Book sources]] and copy 
// the URL of the site you want to use (right-click the link, then click "Copy Link 
// Location", "Copy Target", or similar).  Put the new URL between the quotes next 
// to magicURL, in place of the URL now there.
//
// The current magicURL includes Wikimedia's Amazon Referral reference. That means if you click on 
// the ISBN link, go to Amazon and end up buying the book, Wikimedia will earn some small amount
// of money from that sale.  If you don't want to support Wikimedia in this way, but do want ISBNs
// to link to Amazon, replace the current magicURL with "http://www.amazon.com/gp/search?ie=UTF8&field-isbn=MAGICNUMBER"
//
// Good luck, and if you have any questions, leave a comment on the discussion
// page of User:Lunchboxhero/monobook.js . Thanks to Superm401 and drrngravy for their
// improvements.
//
// (Every line that starts with "//" is a comment and can be discarded.)
 
var magicURL = "http://www.worldcat.org/search?q=MAGICNUMBER&=Search&qt=owc_search"; 
importScript('User:Lunchboxhero/externISBN.js');

importScript('User:Ale_jrb/Scripts/userhist.js');  //[[User:Ale_jrb/Scripts]]

// install User:Cacycle/wikEdDiff enhanced diff view using ajax
importScript('User:Cacycle/wikEdDiff.js');

importScript('User:Gary King/mark unviewed watchlist items.js'); // Mark Unviewed Watchlist Items

importScript('User:Gary King/mark edits after my own.js'); // Mark Edits After My Own


/*
	SHOW UPLOAD DELETION LOGS
	Description: After clicking on a link to a deleted file, this script shows links to a file's deletion logs for convenience.
	Link: [[User:Gary King/show upload deletion logs.js]]
*/
 
if (typeof(unsafeWindow) != 'undefined')
{
	wgPageName = unsafeWindow.wgPageName;
	wgServer = unsafeWindow.wgServer;
	wgScript = unsafeWindow.wgScript;
	wgAction = unsafeWindow.wgAction;
}
 
if (typeof(showUploadDeletionLogs) == 'undefined')
	showUploadDeletionLogs = {};
 
function showUploadDeletionLogsFunction()
{
	if (typeof(showUploadDeletionLogs) == 'undefined')
		showUploadDeletionLogs = {};
 
	if (typeof(showUploadDeletionLogs.linkToFileEdit) == 'undefined')
		showUploadDeletionLogs.linkToFileEdit = false;
 
	if ((wgAction == 'view' || wgAction == 'submit') && wgPageName != 'Special:Upload')
	{
		if (wgAction == 'view')
			body = document.getElementById('bodyContent');
		else
			body = document.getElementById('wikiPreview');
 
		newLinks = body.getElementsByClassName('new');
		for (var i = 0; i < newLinks.length; i++)
		{
			a = newLinks[i];
			if (a.href && a.href.indexOf('wpDestFile=') != -1)
			{
				if (showUploadDeletionLogs.linkToFileEdit)
					a.href = generateFileEditLink(a.href);
				else
					a.href = generateFileUploadLink(a.href);
			}
			else
				oldHref = '';
		}
	}
	else if (wgPageName == 'Special:Upload' && location.href.indexOf('wpDestFile=') != -1 && document.getElementById('contentSub2'))
	{
		editLink = document.createElement('a');
		editLink.className = 'external';
		editLink.href = generateFileEditLink(location.href);
		editLink.appendChild(document.createTextNode('Edit file'));
 
		sub = document.getElementById('contentSub2');
		sub.lastChild.appendChild(document.createTextNode(' / '));
		sub.lastChild.appendChild(editLink);
	}
}
 
function generateFileEditLink(url)
{
	wpDestFileIndex = url.indexOf('wpDestFile=');
	if (url.indexOf('&', wpDestFileIndex) != -1)
		endIndex = url.indexOf('&', wpDestFileIndex);
	else
		endIndex = url.length;
 
	return wgScript + '?title=File:' + url.substring(wpDestFileIndex + 'wpDestFile='.length, endIndex) + '&action=edit&redlink=1';	
}
 
function generateFileUploadLink(url)
{
	wpDestFileIndex = url.indexOf('wpDestFile=');
 
	if (url.indexOf('&', wpDestFileIndex) != -1)
		endIndex = url.indexOf('&', wpDestFileIndex)
	else
		endIndex = url.length;
 
	return wgScript + '?title=Special:Upload&wpDestFile=' + url.substring(wpDestFileIndex + 'wpDestFile='.length, endIndex);	
}
 
if (typeof(unsafeWindow) == 'undefined')
	addOnloadHook(showUploadDeletionLogsFunction);
else
	showUploadDeletionLogsFunction();