Jump to content

User:Pegship/monobook.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.
function externISBN() {

  var magicURL = "http://www.worldcat.org/search?q=MAGICNUMBER";
 
  var magicRegex = /MAGICNUMBER/ig;
  if(mw.config.get('wgPageName') != "Special:BookSources" && !(mw.config.get('wgTitle') == "Book sources" && mw.config.get('wgCanonicalNamespace') == "Project")){
    for (var i = 0; i < document.links.length; i++) {       
      if( document.links[i].href.match(/Special:BookSources\/(.*)/) ) {
        document.links[i].href=magicURL.replace(magicRegex, RegExp.$1);
      }
    }
  }

}

addOnloadHook(externISBN);

importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');
importScript('Wikipedia:WikiProject User scripts/Scripts/Compact Navigation');

addOnloadHook(function()
{
	var disabled_urls = new Array('action=history', '/Special:', 'title=Special:');
	for (var i = 0; i < disabled_urls.length; i++)
	{
		if (document.location.href.indexOf(disabled_urls[i]) != -1)
			return;
	}
 
	var unique_url = false;
 
	var wikiPreview = new Array('action=edit', 'action=submit');
	for (var i = 0; i < wikiPreview.length; i++)
	{
		if (document.location.href.indexOf(wikiPreview[i]) != -1)
			unique_url = 'wikiPreview';
	}
 
	var element_id = unique_url ? unique_url : 'bodyContent';
	document.getElementById(element_id).innerHTML = 
		document.getElementById(element_id).innerHTML.replace(/(\d\d):(\d\d), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g, adjustTime);
});