User:Eloquence/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin is at User:Eloquence/monobook.css. |
function externISBN() {
var magicURL = "http://www.amazon.com/exec/obidos/ASIN/MAGICNUMBER/wikipedia08-20";
var magicRegex = /MAGICNUMBER/ig;
if(mw.config.get('wgPageName') != "Special:Booksources" && mw.config.get('wgPageName') != "Wikipedia:Book_sources"){
for (var i = 0; i < document.links.length; i++)
{
if( document.links[i].href.match(/isbn=(.*)/) ) {
document.links[i].href=magicURL.replace(magicRegex, RegExp.$1);
}
}
}
}
function global_append_tab(url, name, id)
{
var na = document.createElement('a');
na.setAttribute('href', url);
var txt = document.createTextNode(name);
na.appendChild(txt);
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
// Grab the element we want to append the tab and append the tab to it.
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
tabs.appendChild(li);
}
function add_britannica_tab() {
var title=mw.config.get('wgPageName');
if(mw.config.get('wgNamespaceNumber')==0) {
global_append_tab('http://school.eb.com/search?query='+title+'&ct=eb','in britannica','eb-search');
}
}
$(externISBN);
$(add_britannica_tab);