Jump to content

User:DavidHOzAu/citefix/code.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.
/* <pre> */
function MyCitation() 
{
   // iterate over all <sup>-elements
   for(var i=0; a = document.getElementsByTagName("sup")[i]; i++) {
      // if found a citation thag
      if(a.getAttribute("title")=="Needs citation" || a.getAttribute("class")=="uncited") {
         // 1) fix style -- a wider-scope fix can be found at the corresponding CSS page.
         //a.style.verticalAlign = 'top'; // absolutely required for the image.
         a.style.textDecoration = 'blink'; // another alternative

         // 2) replace it with whatever I want.  ** Note: Uncomment one of the following, or roll your own. **
         // 2.1) Image
         //a.innerHTML = '<span style="padding: 0; margin: 0;"><a href="/wiki/Wikipedia:Cite_sources" title="Citation needed"><img src="http://upload.wikimedia.org/wikipedia/en/4/4a/Citation_needed.gif" alt="Citation needed" width="38" height="11" border="0"/></a></span>';
         // 2.2) Shorter text
         a.innerHTML = '[<a href="/wiki/Wikipedia:Cite_sources" title="Citation needed">CITE</a>]';
      }
   }
}
addOnloadHook(MyCitation);
/* </pre> */