User:Superm401/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.
If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
<!----><pre> var url=window.location.href; var docTitle=document.title; if(url.indexOf('action=delete')>=0 && url.indexOf('title=Image:')>=0 && url.indexOf('&image=')==-1) { var imgName=url.substring(url.indexOf('title=Image:')+12,url.indexOf('&action=delete')); window.location.href=url+'&image='+imgName; } //Originally based on http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510 //See [[Wikipedia:WikiProject User scripts/Scripts/Show last diff]] // addLastDiff function addLastDiff() { addPortletLink('p-cactions', wgServer + wgScriptPath + '/index.php?title=' + wgPageName + "&diff=cur&oldid=prev", 'last', 'ca-last', 'Show most recent diff'); } function addPurge() { addPortletLink("p-cactions", wgServer + wgScriptPath + '/index.php?title=' + wgPageName + '&action=purge', 'purge', 'ca-purge', 'Purge the internal cache for this page'); } //Should only run if page has a history (i.e. is or could be editable) function doHistorical() { var hist = document.getElementById('ca-history'); if(hist) { addLastDiff(); addPurge(); } } addOnloadHook(doHistorical); //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. Go to [[Wikipedia:Book sources]] and copy //the URL of the site you want to use (right-click the link, then click "Copy Link //Location", "Copy Target", or similar). Put the new URL between the quotes next //to magicURL, in place of the URL now there. // //Good luck, and if you have any questions, leave a comment on the discussion //page of User:Lunchboxhero/monobook.js . Thanks to Superm401 and drrngravy for their //improvements. // //(Every line that starts with "//" is a comment and can be discarded.) function externISBN() { var magicURL = "http://www.amazon.com/exec/obidos/ASIN/MAGICNUMBER"; var magicRegex = /MAGICNUMBER/ig; if(wgPageName != "Special:Booksources" && 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); } } } } addOnloadHook(externISBN); 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; } // This will add an [edit] link at the top of all pages except preview pages and the main page // by User:Pile0nades // Add an [edit] link to pages addOnloadHook(function () { // if this is preview page or generated page, stop if( document.getElementById("wikiPreview") || document.getElementById("histlegend") || document.getElementById("difference") || document.getElementById("watchdetails") || document.getElementById("ca-viewsource") || window.location.href.indexOf("/wiki/Special:") != -1 ) { if(window.location.href.indexOf("&action=edit§ion=0") != -1) { document.getElementById("wpSummary").value = "/* Intro */ "; } return; }; // get the page title var pageTitle = wgPageName; // create div and set innerHTML to link var divContainer = document.createElement("div"); divContainer.innerHTML = '<div class="editsection">[<a href="/w/index.php?title='+pageTitle+'&action=edit§ion=0" title="Edit section: '+pageTitle+'">edit intro</a>]</div>'; // insert divContainer into the DOM below the h1 if(window.location.href.indexOf("&action=edit") == -1) { document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]); } }); function doTag(tag, summary, minor, watch) { document.editform.wpTextbox1.value = "{{" + tag + "}}" + "\n\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = summary; document.editform.wpMinoredit.checked = minor; document.editform.wpWatchthis.checked = watch; } function doWPUI() { document.editform.wpSummary.value = "Thousands of pictures are untagged. [[WP:UI|You can help!]]"; document.editform.wpMinoredit.checked = false; document.editform.wpWatchthis.checked = false; document.editform.submit(); } function addNoSource() { addLink("p-cactions","javascript:doTag(\"subst:nsd\", \"No source, uploader notified. [[WP:UI]]\", false, true)", "no s", "ca-nosource", "Tag as No source", null); } function addNoLicense() { addLink("p-cactions", "javascript:doTag(\"subst:nld\", \"No © tag, uploader notified. [[WP:UI]]\", false, true)", "no ©", "ca-nolicense", "Tag as No license", null); } function addIfD() { addLink("p-cactions", "javascript:doTag(\"IFD\", \"Image is now listed for [[WP:IFD|deletion]], uploader notified. [[WP:UI]]\", false, true);", "ifd", "ca-ifd", "Tag for deletion", null); } function addORCR() { addLink("p-cactions","javascript:addTag(\"or-cr|~~~~~\", \"[[:Category:Orphaned unfree image|unfree orphan]], [[WP:UI]]\", false, true);", "ORCR", "ca-ORFU", "Tag as orphan unfree image", null); } function addWPUI() { addLink("p-cactions","javascript:doWPUI()", "WP:UI", "ca-WPUI", "WP:UI summary", null); } if (document.title.indexOf("Editing Image:") == 0) { addOnloadHook(addNoSource); addOnloadHook(addNoLicense); addOnloadHook(addIfD); addOnloadHook(addORCR); addOnloadHook(addWPUI); addOnloadHook(akeytt); } function addUserLogs() { var user = docTitle.substring(docTitle.indexOf(":")+1,docTitle.indexOf("-")-1); addLink("p-tb", "/w/index.php?title=Special:Log&user="+user, "User log", "t-userlog", null, null, "t-blockip"); addLink("p-tb", "/w/index.php?title=Special:Log&type=block&page=User:"+user, "Block log", "t-blocklog", null, null, "t-emailuser"); } if (docTitle.indexOf("User:") == 0 || docTitle.indexOf("User talk:") == 0) { addOnloadHook(addUserLogs); } // [[User:Lupin/popups.js]] /*document.write('<sc'+'ript type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></sc'+'ript>');*/ document.write('<sc'+'ript type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></sc'+'ript>'); //add quick-delete document.write('<sc'+'ript type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Superm401/quickDelete.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></sc'+'ript>'); popupAdminLinks=true; popupActionsMenu=false; popupHistoryLimit=1000; popupFixRedirs=true; popupOnEditSelection=false; popupDiffDatePrinter='toUTCString'; function fixSearch() { var searchInput=document.getElementById("searchInput"); searchInput.setAttribute("name","q"); var searchForm=document.getElementById("searchform"); searchForm.setAttribute("action","http://www.google.com/search"); var siteSearch=document.createElement("input"); siteSearch.setAttribute("type","hidden"); siteSearch.setAttribute("name","sitesearch"); siteSearch.setAttribute("value",window.location.host); searchForm.appendChild(siteSearch); var goButton=document.getElementById("searchGoButton"); goButton.setAttribute("type","button"); goButton.addEventListener("click",function () {var queryBox=document.getElementById("searchInput");window.location="http://"+window.location.host+"/wiki/"+queryBox.value;},false); } addOnloadHook(fixSearch); function fixCompare() { var histForm=document.getElementsByTagName("form")[0]; var finalButton=document.getElementById("historysubmit"); var firstButton=histForm.getElementsByTagName("input")[1]; histForm.removeChild(finalButton); histForm.removeChild(firstButton); var compareLink=document.createElement("a"); var genLink="http://en.wikipedia.org/w/index.php?title=" + histForm.title.value + "&diff=" + histForm.diff[0].value + "&oldid=" + histForm.oldid[1].value; compareLink.setAttribute("href", genLink); compareLink.appendChild(document.createTextNode("Compare selected versions")); histForm.insertBefore(compareLink, document.getElementById("pagehistory")); var endLink=compareLink.cloneNode(true); histForm.appendChild(endLink); var diffList=document.getElementById("pagehistory"); diffList.setAttribute("onchange", "updateCompare()"); } function updateCompare() { var histForm=document.getElementsByTagName("form")[0]; var diffList=document.getElementById("pagehistory"); var compareLink=diffList.previousSibling; var endLink=diffList.nextSibling; var oldInd=-1; var i=0; while(oldInd==-1 & i<histForm.oldid.length) { if(histForm.oldid[i].checked) oldInd=i; i++; } var diffInd=-1; var j=0; while(diffInd==-1 & j<histForm.diff.length) { if(histForm.diff[j].checked) diffInd=j; j++; } var genLink="http://en.wikipedia.org/w/index.php?title=" + histForm.title.value + "&diff=" + histForm.diff[diffInd].value + "&oldid=" + histForm.oldid[oldInd].value; compareLink.setAttribute("href", genLink); endLink.setAttribute("href", genLink); } if(url.indexOf("action=history")!=-1) addOnloadHook(fixCompare); if (url.indexOf("Special:Statistics")!=-1) setTimeout("window.location.reload()",30000); function removeKeys() { var saveBtn=document.getElementById("wpSave"); saveBtn.removeAttribute("accesskey"); saveBtn.removeAttribute("title"); var previewBtn=document.getElementById("wpPreview"); previewBtn.removeAttribute("accesskey"); previewBtn.removeAttribute("title"); var diffBtn=document.getElementById("wpDiff"); diffBtn.removeAttribute("accesskey"); diffBtn.removeAttribute("title"); } if(window.location.href.indexOf("action=edit")!=-1) addOnloadHook(removeKeys); <!----></pre>