User:Abu badali/monobook.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
//This code will change ISBN links to point to the url of your choice, //instead of Special:Book_sources. // //How to use it: // //First, you must copy this code to your user javascript page. This is //at User:<your username>/monobook.js . My username is Lunchboxhero so //my javascript page is User:Lunchboxhero/monobook.js . You must be logged //in to edit your javascript page. // //Once you have copied the code and saved the page, you need to refresh your //browser's cache. For Mozilla/Safari/Konqueror: hold down Shift while clicking //Reload (or press Ctrl-Shift-R), IE: press Ctrl-F5, Opera: press F5. // //The code should now work, as long as you are logged in. // //You can change the destination url by simply modifying the quoted url that //follows document.links[i].href= // //Good luck, and if you have any questions, leave me a comment on the discussion //page of User:Lunchboxhero/monobook.js . // //(Every line that starts with "//" is a comment and can be discarded.) 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); //If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction. /* function addEditSection0() { ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page']; if (!document.getElementById) return; x = document.getElementById('ca-edit'); if(!x) return; y = document.createElement('LI'); y.id = 'ca-edit-0'; if (x.className == 'selected') { if (/&action=edit§ion=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected'; } else { x.className = 'selected istalk'; } } else if (x.className == 'selected istalk') { if (/&action=edit§ion=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected istalk'; } else { y.className = 'istalk'; } } else { y.className = x.className; x.className = 'istalk'; } z = document.createElement('A'); if (x.children) { z.href = x.children[0].href + '§ion=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling); } else { z.href = x.childNodes[0].href + '§ion=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling); } } if (document.title.indexOf("Editing ") == -1) { addOnloadHook(addEditSection0); } */ // function addLink(where, url, name, id, title, key, after){ //* where is the id of the toolbar where the button should be added; // i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". // //* url is the URL which will be called when the button is clicked. // javascript: urls can be used to do more complex things. // //* name is what will appear as the name of the button. // //* id is the id of the button; it's best to define one. // Use a prefix to make sure its unique. Optional. // //* title is the tooltip title that gives a longer description // of the button; if you define a accesskey, mention it here. Optional. // //* key is the char you want for the accesskey. Optional. // //* after is the id of the button you want to follow this one. Optional. // var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { tabs.appendChild(li); } if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title];} } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } // //Please leave the following line //user:Where/usertabs addOnloadHook(function() { if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history return; } if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) { username_a = document.URL.match(/:.*:(.*)/); username=username_a[1]; addTab("http://en.wikipedia.org/wiki/Special:Contributions/" + username, "contrib", "ca-contrib", "contribs", ""); addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=" + username, "block log", "ca-blog", "blog", ""); addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=upload&user=" + username, "upload log", "up-blog", "blog", ""); } }); function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title]; } } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } // function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } // addOnloadHook(function () { var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]="; //var query_prefix = "action=unwatch&title="; if (window.location.href.indexOf("Special:Watchlist") == -1) return; var links = document.getElementById('content').getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].href.substring(links[i].href.length-15) != '&action=history') continue; var unwatch = document.createElement('a'); unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title); unwatch.title = "Unwatch "+links[i].title; unwatch.appendChild(document.createTextNode("unwatch")); links[i].parentNode.insertBefore(unwatch, links[i].nextSibling); // kluge to handle case where "diff" is unlinked: var delim = links[i].previousSibling; delim = (delim.nodeType == 3 ? delim.nodeValue : ""); links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch); } }); // /********************** navigation popup ***********************/ // [[User:Lupin/popups.js]] document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Abu_badali/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /********************** end of navigation popup ***********************/ /**** abu's personal image tools *****/ var imagePageRE = /http:\/\/en\.wikipedia.org\/wiki\/Image:.*\.(jpg|JPG|gif|GIF|png|PNG|jpeg|JPEG)$/ var imageEditPageRE = /http:\/\/en\.wikipedia.org\/wiki\/Image:.*\.(jpg|JPG|gif|GIF|png|PNG)\?action=edit(&abugogogo=([a-z])*)?$/ function abu_tag_replaceable_fair_use(){ var url = window.location; if(imagePageRE.test(url)){ window.location = url + "?action=edit&abugogogo=rfu"; } else if (imageEditPageRE.test(url)){ var f = document.getElementById('editform'); f.wpTextbox1.value+=('{{' + 'subst:rfu' + '}}'); f.wpSummary.value = 'Replacaeble unfree image (see [[WP:FUC]]#1 and #8 on [[WP:FU#Counterexamples]])'; f.submit(); } } function abu_tag_orfan_fair_use(){ } var abuGogogoRE = /(&|\?)abugogogo=([a-z]*)$/ function abugogogoHandler(){ var res = abuGogogoRE.exec(window.location); if(res){ var whattodo = res[2]; if(whattodo == "rfu"){ abu_tag_replaceable_fair_use(); } else if(whattodo == "orfud"){ abu_tag_orfan_fair_use(); } else { alert("waht to do? " + whattodo); } } } function abu_imagetools(){ if(!imagePageRE.test(window.location)){ return; } abu_addImageTool('Replacaeble',"javascript:abu_tag_replaceable_fair_use()"); } function abu_addImageTool(name,action){ if(!imagePageRE.test(window.location)){ return; } var ul = document.getElementById('filetoc'); var a = document.createElement("a"); a.href=action; var li = document.createElement("li"); var text = document.createTextNode(name); a.appendChild(text); li.appendChild(a); ul.appendChild(li); } addOnloadHook(abugogogoHandler); addOnloadHook(abu_imagetools); /**** quick image delete ****/ document.write('<script type="text/javascript"' + 'src="http://en.wikipedia.org/w/index.php?title=User:Howcheng/quickimgdelete.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /* This is to keep track of who is using this extension: [[User:Howcheng/quickimgdelete.js]] */