User:Mtmelendez/monobook.js
From Wikipedia, the free encyclopedia
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.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
XEBOrder='0,1,2,3,5,8,9,A,B,C,D,D1,F,U,S,I1,I2,J1,E,K,M,O,R,T,V,FS,J2,R1,R4,TL,TC,Y1,Y2,Z,AI'; rmEditButtons=['all']; myButtons=[]; importScript('User:MarkS/extraeditbuttons.js'); //[[User:MarkS/extraeditbuttons.js]] // CSD AutoReason importScript('User:^demon/csd.js'); // [[User:Steel359/protection.js]] importScript('User:Steel359/protection.js'); // [[User:Outriggr/metadatatest.js]] importScript('User:Outriggr/metadatatest.js'); assessmentMyTemplateCode = ["{{PuertoRicoproj|class=|importance=}}", "{{WikiProject Business & Economics|class=|importance=}}", "{{WPBiography\n|small = \n|living = \n|class = \n|priority = \n|needs-infobox = \n|listas = \n|needs-photo = \n}} "]; assessmentDefaultProject = "PuertoRicoproj"; // importScript('User:Alex Smotrov/wlunwatch.js'); if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Watchlist' && wgAction=='view') addOnloadHook(function () { var frm = document.getElementsByTagName('form')[0]; frm.parentNode.insertBefore(document.createTextNode(' | '), frm); var lnk = document.createElement('a'); lnk.appendChild(document.createTextNode('Unwatch…')); lnk.href = 'javascript:importScript("User:Alex_Smotrov/wlunwatch.js")'; frm.parentNode.insertBefore(lnk, frm); }) /* Category watch ([[User:ais523/catwatch.js]]); adds entries on the watchlist if a page is added to a category (and is still in the category when the watchlist is checked). The entry will only appear if there is another page on the watchlist edited that day (if the addition was the only change on that day, it's neglected). The recategorisation of a page in a watched category will also trigger the watching, even if it's a different category that's added or removed (unless the watched category is removed); removals from the watched category can't be detected. A previous version of this script had a limit on the maximum size of a category that could be watched; this limit no longer exists. Thanks to [[User:TheDJ]] for helping me make this compatible with more browsers and preference settings, and to Roan Kattouw for fixing [[bugzilla:11275]] and making this cheap on the servers. Note that some users have had problems installing this in Internet Explorer; if the second cache bypass (after changing the category watchlist) doesn't work, deleting all your temporary Internet files seems to. */ //<source lang="javascript"> var cwwpajax; // From [[WP:US]] mainpage (wpajax renamed to cwwpajax) cwwpajax={ download:function(bundle) { // mandatory: bundle.url // mandatory: bundle.async // optional: bundle.onSuccess (xmlhttprequest, bundle) // optional: bundle.onFailure (xmlhttprequest, bundle) // optional: bundle.otherStuff OK too, passed to onSuccess and onFailure var x = window.XMLHttpRequest ? new XMLHttpRequest() // Firefox, Safari, Opera, IE7 : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") // IE6 : false; if (x) { x.onreadystatechange=function() { x.readyState==4 && cwwpajax.downloadComplete(x,bundle); }; x.open("GET",bundle.url,bundle.async); x.send(null); } return x; }, downloadComplete:function(x,bundle) { x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true ) || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText)); } }; // Example: // function dlComplete(xmlreq, data) { // alert(data.message + xmlreq.responseText); // } // cwwpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw', // onSuccess: dlComplete, message: "Here's what we got:\n\n" }); // End of [[WP:US]] quote function cwOntoWatchlist(xmlreq, data) { var a=xmlreq.responseText; var c=data.catname; var i; var diag=""; if(a.indexOf("<categorymembers/>")!=-1) return; //cat is empty, nothing to do here if(a.indexOf('title="')==-1) return; // this error happens sometimes, just do nothing here var latesttime=0; var latestpage=""; var temp, temp2; latestpage=a.split('title="')[1].split('" timestamp=')[0]; latesttime=a.split('timestamp="')[1].split('"/>')[0]; a=document.getElementsByTagName("h4"); //get dates in the watchlist var monthname=new Array(); monthname['01']="January"; monthname['02']="February"; monthname['03']="March"; monthname['04']="April"; monthname['05']="May"; monthname['06']="June"; monthname['07']="July"; monthname['08']="August"; monthname['09']="September"; monthname['10']="October"; monthname['11']="November"; monthname['12']="December"; latesttime=new String(latesttime); var mn1, mn2, mn3, mn4; // Allow for different date styles: // January 29, 2001 mn1=""+monthname[latesttime.substr(5,2)]+" "+new Number(latesttime.substr(8,2))+ ", "+latesttime.substr(0,4); // 29 January 2001 mn2=""+new Number(latesttime.substr(8,2))+" "+monthname[latesttime.substr(5,2)]+ " "+latesttime.substr(0,4); // 2001 January 29 mn3=""+latesttime.substr(0,4)+" "+monthname[latesttime.substr(5,2)]+ " "+new Number(latesttime.substr(8,2)); // 2001-01-29 mn4=""+latesttime.substr(0,4)+"-"+latesttime.substr(5,2)+"-"+latesttime.substr(8,2); i=a.length; while(i--) { if(a[i].innerHTML==mn1||a[i].innerHTML==mn2||a[i].innerHTML==mn3||a[i].innerHTML==mn4) { diag+=a[i].innerHTML+":"; temp=a[i].nextSibling.firstChild; if(temp==null) temp=a[i].nextSibling.nextSibling.firstChild; while(temp!=null) { diag+=temp.tagname+"!"; if(temp.tagName!=null) if(temp.tagName.toLowerCase()=="li") { temp2=temp.innerHTML.match(/; ([0-9][0-9]):([0-9][0-9])(:[0-9][0-9])? \. \./); temp2=new Number(temp2[1])*100+new Number(temp2[2]); diag+=temp2+","; if(temp2<new Number(latesttime.substr(11,2)+latesttime.substr(14,2))) {temp2=temp; break;} } temp2=temp; temp=temp.nextSibling; if(temp==null) break; } temp=document.createElement("li"); if(temp2==null) {return;} if(a[i].nextSibling.firstChild!=null) // IE-like whitespace handling a[i].nextSibling.insertBefore(temp,temp2); else // Firefox-like whitespace handling a[i].nextSibling.nextSibling.insertBefore(temp,temp2); temp.innerHTML="(diff) (hist) . . <a "+ "href='http://en.wikipedia.org/wiki/Category:"+ encodeURI(c)+ "'>Category:"+c+"</a>; "+latesttime.substr(11,2)+":"+latesttime.substr(14,2)+ " . . (+ <a "+ "href='http://en.wikipedia.org/wiki/"+ encodeURI(latestpage)+"'>"+latestpage+"</a> "+ "(<a href='http://en.wikipedia.org/w/index.php?title="+encodeURI(latestpage)+ "&diff=last'>last</a>))"; return; } } } var WatchedCategories; //An example of a query to check a category would be //http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmcategory=Wikipedia%20protected%20edit%20requests&cmlimit=1&cmprop=title|timestamp&cmsort=timestamp&cmdir=desc&format=xml addOnloadHook(function(){ //DHTMLloadscript( 'http://en.wikipedia.org/w/index.php?title=User:'+wgUserName // +'/WatchedCategories.js&action=raw&ctype=text/javascript'); if(wgPageName=="Special:Watchlist") { if(document.getElementsByTagName("tt").length>0) { alert("You seem to be using the Javascript-enhanced watchlist, which is incompatible "+ "with the category watchlist script at present; please uninstall it."); return; } // load the script using AJAX, because DHTML fails in Firefox and document.write fails in Safari var sru='http://en.wikipedia.org/w/index.php?title=User:'+wgUserName+'/WatchedCategories.js&action=raw&ctype=text/javascript'; var sr=cwwpajax.download({url:sru,async:false}); eval(sr.responseText); if(WatchedCategories==undefined) { if(confirm("You don't have a category watchlist yet. Do you want to create one?\n\n"+ "(Please provide the following debug information when reporting a problem if "+ "this message comes up when you already have a category watchlist: "+ (sr.responseText.length<50 ? "responseText='"+sr.responseText+"'" : "responseText.length="+sr.responseText.length)+", statusText='"+sr.statusText +"'.)")) location.href='http://en.wikipedia.org/w/index.php?title=User:'+wgUserName+ '/WatchedCategories.js&action=edit&preload=User:Ais523/WatchedCategoriesTemplate.js'; } else { var i; for(i=0; i<WatchedCategories.length; i++) { var a=WatchedCategories[i]; cwwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&' +'cmcategory='+encodeURI(a)+'&cmlimit=1&cmprop=title' +'|timestamp&cmsort=timestamp&cmdir=desc&format=xml', onSuccess:cwOntoWatchlist, catname:a, async:true}); } } } }); //</source> //<!--[[Category:Wikipedia scripts]]--> //this helps automate AfD closing by adding a 'close' tab to AfD debates //written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]] function autoafd_result() { var close = prompt("Result of debate?") var f = document.editform, t = f.wpTextbox1; t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0'); t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:" + "ab" + "}}"; f.wpSummary.value = "Closing debate; result was " + close; } function autoafd_relist() { var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}"; f.wpSummary.value = "Relisting debate"; } function autoafd_keep() { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD"; } function autoafd_no_consensus() { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD with no consensus"; } function autoafd_redirect() { var date = prompt("Nomination was made when?") var redirect = prompt("Redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD"; } function autoafd_merge() { var date = prompt("Nomination was made when?") var redirect = prompt("Merge and redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD"; } function autoafd_other() { var date = prompt("Nomination was made when?") var result = prompt("Result was?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "AfDed; result was " + result; } function autoafd_add_afd_tabs() { // Only add for pages with the right string somewhere in the title if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1) { addPortletLink('p-cactions', 'javascript:autoafd_result()', "close"); addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist"); } if (document.title.indexOf("Editing Talk:") != -1) { addPortletLink('p-cactions', 'javascript:autoafd_keep()', "keep"); addPortletLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus"); addPortletLink('p-cactions', 'javascript:autoafd_redirect()', "redirect"); addPortletLink('p-cactions', 'javascript:autoafd_merge()', "merge"); addPortletLink('p-cactions', 'javascript:autoafd_other()', "other"); } } addOnloadHook(autoafd_add_afd_tabs); //end AfD closing script //

