Jump to content

User:Twigboy/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() {
  for (var i = 0; i < document.links.length; i++) 
    {       
         var ln = document.links[i].href.match(/isbn=(.*)/);
         if (ln) {
           document.links[i].href='http://www.amazon.com/exec/obidos/ASIN/'+RegExp.$1;
         }
    }

}

addOnloadHook(externISBN);

// Script to footnote text to the tooltips on footnote links
addOnloadHook(function refTooltips() {
    var linkElem, linkHref, noteElem;
    // Get list of footnote links (they all have class: 'reference')
    var refElems = getElementsByClassName(document.body, "SUP", "reference");
    for(var i = 0; i < refElems.length; i++)
    {
        if(linkElem = refElems[i].getElementsByTagName("a")[0])
        {
            linkHref = linkElem.href;
            // Get footnote id from link href and add text content to link tooltip
            if(noteElem = document.getElementById(linkHref.substr(linkHref.indexOf("#") + 1)))
                linkElem.title = noteElem.innerText || noteElem.textContent || "";
        }
    }
});