From OpenWetWare

Jump to: navigation, search

Note - After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh); Konqueror: click Reload or press F5; Opera: clear the cache in Tools → Preferences; Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

// adapted from TinEye gadget for Commons
// To use, add this to your user skin preferences file (probably User:YourUsername/monobook.js):
// importScript('User:Twp/tineye.js');
addOnloadHook( function() {
 if ((wgNamespaceNumber != 6) || (wgAction != "view") || !document.getElementById('file')) return;
 var links = document.getElementById('file').getElementsByTagName('a');
 if (!links.length) return;
 var imageurl = links[links.length-1].href; //imageboxes adds links _before_, so we get the last link
 if (document.getElementById('file').getElementsByTagName('img')[0].width <= 300) {
   imageurl = document.getElementById('file').getElementsByTagName('img')[0].src; //Image smaller than 300px width
 } else { //Get thumb url
   imageurl = imageurl.replace("/en/",      "/en/thumb/");
   imageurl = imageurl.replace("/commons/", "/commons/thumb/");
   n = imageurl.lastIndexOf('/') + 1;
   imageurl = imageurl + "/300px-" + imageurl.substring(n); 
 addPortletLink('p-cactions', '' + encodeURIComponent(imageurl), 'Tineye', 'ca-tineye');
Personal tools