User:Peter M Dodge/monobook.js

// var myname=wgUserName.replace(' ', '_'); //use underscores instead of spaces var mypage="User:"+myname; var mytalk="User_talk:"+myname; var mycontribs="Special:Contributions/"+myname; var serverurl="http://en.wikipedia.org"; var wikiurl=serverurl+"/wiki/"; var pathurl=serverurl+"/w/"; var phpurl=pathurl+"index.php?title="; var editcounturl="http://tools.wikimedia.de/~essjay/edit_count/Count.php"; var editcount=editcounturl+"?username="; //

// document.write(''); //

// document.write(''); //

document.write('');

// //COOKIE FUNCTIONS function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); }	return null; }

function createCookie(name,value,days) { if (days) { var date = new Date; date.setTime(date.getTime+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString; }	else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }

function eraseCookie(name) { createCookie(name,"",-1); } //

// //    --- ADD VARIOUS LINKS function addToolboxLink(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, url, name, id); } // function addTopLink(url, name, id){ var personal = document.getElementById('p-personal').getElementsByTagName('ul')[0]; addlilink(personal, url, name, id); } // function addNavLink(url, name, id){ var navigation = document.getElementById('p-navigation').getElementsByTagName('ul')[0]; addlilink(navigation, url, name, id); } //

function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); }

//

//     -- MORE MAJOR LINKAGE - 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; } //

// - LINKAGE

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; } //

// addOnloadHook(function{ var theuser = wgUserName.replace(' ', '_'); var divs = document.getElementsByTagName('div'); for (i=0; i&emsp;New Messages. last change &rarr; talk page';          document.title = wgPageName.replace(/\_/g, ' ')+' - NEW MESSAGES - wikipedia';          alert('NEW MESSAGES');          createCookie('nmsalerted', 'yes', 365);     } else {        divs[i].innerHTML = "";        divs[i].style.display = "none";        addTab('/wiki/User_talk:'+theuser+'?diff=cur', 'view new message', 'ca-nms', 'view msg', 'n'); } } else if((divs[i].className == 'usermessage' && divs[i].innerHTML.indexOf(theuser) == -1)) { divs[i].style.display = "none"; } }

if(document.getElementById('bodyContent').innerHTML.indexOf('class=\"usermessage\"') == -1 && readCookie('nmsalerted') == 'yes') { createCookie('nmsalerted', 'no', 365); }

});

//END //

// // User:Lupin/popups.js

mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'             + '&action=raw&ctype=text/javascript&dontcountme=s'); //

// //-- //First loads //Helper tools mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Addtabs/monobook.js'             + '&action=raw&ctype=text/javascript&dontcountme=s'); //////////////////////

//Admin rollback tools document.write(' '); //END //BCrat tools document.write(' '); RfAshowlinks = 'true'; //END //CU tools document.write(' '); //END //UTC clock document.write(' '); //END //Admin protection tools document.write(' '); //END //Approvals document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Approvals.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"> '); //END //Replace txt document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/replacetxt.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"> '); //END

// //--- //Toolbox links function changelinks {   if(!document.getElementById) return; var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0]; var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML; if (document.title.indexOf('User:' + user_name + '/xml') != -1 || document.title.indexOf('User:' + user_name + '/XML') != -1) {addlilink(toplinks, 'javascript:XMLrequestprompt', 'Request XML', 'Request XML');} document.getElementById('pt-mytalk').firstChild.innerHTML = 'my Talk page'; document.getElementById('pt-preferences').firstChild.innerHTML = 'Change Preferences'; document.getElementById('pt-watchlist').firstChild.innerHTML = 'Check my Watchlist'; document.getElementById('pt-mycontris').firstChild.innerHTML = 'My Contributions'; document.getElementById('pt-logout').firstChild.innerHTML = 'Log out'; if(document.getElementById('ca-delete')) {document.getElementById('ca-delete').firstChild.innerHTML = ' delete ';} }

function navigationlinks {   addnavbox_link('/wiki/Wikipedia:Administrator_intervention_against_vandalism','Vandalism','aiv-ln'); addnavbox_link('/wiki/Category:Candidates_for_speedy_deletion','Speedy deletions','speedy-ln'); addnavbox_link('/wiki/Wikipedia:Requests for page protection','Protection requests','rfpp-ln'); addnavbox_link('/wiki/Wikipedia:Administrators%27_noticeboard','Noticeboard','AN-ln'); }

function addtoolboxlinks {   var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, '/wiki/Special:Newpages', 'New pages', ''); addlilink(tb, '/wiki/Special:Log/newusers', 'New users', ''); addlilink(tb, '/wiki/WP:PP', 'Protected pages', ''); } //END //---

// ======== USER TABS ======= function userlogs { //no subpages or history if (document.title.search("/") != -1 || location.href.search(/Special:|&action=[^p]|&diff=/) !=-1) {return;} if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) {     username = wgTitle.replace(/User:|User talk:/,''); addTab("/w/index.php?title=Special%3ALog&user=" + username, "log", "ca-log", "actions", ""); addTab("/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "bl", "ca-blog", "block log", ""); addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=" + username, "edits", "ca-kate", "user info", ""); } } //************

//************ //LAST DIFF TAB function lastdiff {   if (document.title.indexOf("Editing ") != -1 || document.getElementById('ca-history') == undefined || location.href.search(/&action=history/) !=-1){return;} addTab("/w/index.php?title=" + wgPageName.replace(/&/g,'%26') + "&diff=cur&oldid=prev", "Last", "ca-diff", "Show most recent diff", ""); }

// This will add an [edit top] link at the top of all pages except preview pages function addtoplink { var edittop = ' [ edit top ] '; // if this is preview page or generated page, stop if(location.href.search(/title=Special:|\/Special:/) != -1) return; if(document.title.indexOf("Main Page") != -1) return;

// create div and set innerHTML to link var divContainer = document.createElement("div"); divContainer.innerHTML = ' <a href="/w/index.php?title=' + wgPageName + '&action=edit&section=0" title="' + wgTitle + '">' + edittop + '</a> ';

// insert divContainer into the DOM before the h1 if (document.getElementById("content") !=undefined) { document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);} } //END

//************ //MAIN //************

addOnloadHook(Mainfast) function Mainfast {   userlogs; changelinks; navigationlinks; addtoolboxlinks; }

window.onload = Main; function Main {   watchlist_tab; block_check; lastdiff; addtoplink; } //END //************

function watchlist_tab { if (location.href.indexOf('Special:Watchlist/edit') !=-1) {addTab("javascript:watchlist_clean", "check deleted pages", "ca-clean", "check all deleted pages", "");} }

function watchlist_clean { //monobook if (document.getElementById('bodyContent')) { var body = document.getElementById('bodyContent'); } //cologneblue else if (document.getElementById('quickbar')) { if (!document.getElementById('content')){return;} var body = document.getElementById('content'); } var l = body.getElementsByTagName('li'); for (var i=0; i<l.length; i++) {   if (l[i].getElementsByTagName('a')[0].href.indexOf('&action=') !=-1) {l[i].getElementsByTagName('input')[0].checked=true;} } }

function block_check { if (document.title.indexOf('Block user') !=0){return;} //monobook if (document.getElementById('pt-userpage')) {var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;} //cologneblue else if (document.getElementById('quickbar') && document.getElementById('quickbar').getElementsByTagName('h6')[0]) {     var toplinks = document.getElementById('quickbar'); var user_name = toplinks.innerHTML.split(' My pages ')[1].split('title="User:')[1].split('"')[0]; } if (document.getElementsByTagName('input')[0].value == user_name) {alert('Are you sure you want to block yourself?');} else if (document.getElementsByTagName('input')[0].value == user_name.replace(/ /g,'_')) {alert('Are you sure you want to block yourself?');} }

// addOnloadHook(Dfn_js_con) function Dfn_js_con { Mvaluejs_class = 'DMalak1'; Rvaluejs_class = 'ERollen2'; Uvaluejs_class = 'DRaven2'; } //

//************ //New user log tools document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"> '); //END //Admin warning tools document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Adminwarnings/monobook.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"> '); //END //Delete tabs document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Deletion/monobook.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"> '); //END //************ //Google tools document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Google/monobook.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"> '); //END

//Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); } //

//************ //Lupin's tools //************ //Filter changes live //User:Lupin/recent2.js - please include this line mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'             + '&action=raw&ctype=text/javascript&dontcountme=s');

//User:Lupin/popupsdev.js - please include this line document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"> ');

popupShortcutKeys=true; // optional: enable keyboard shortcuts popupAdminLinks=true;  // optional: enable admin links popupSubpopups=false; popupOnEditSelection=false; popupStructure='shortmenus'; //END //************

function XMLrequestprompt { var parameters = ''; var type = 'GET'; var url = location.href; url = prompt('Enter a URL:'); parse_js_value_cache = 0; parse_js_value_cache = prompt('Parse the data?' + '\n' + '0 - false (default)' + '\n' + '1 - true (no script/SRCs/images)' + '\n' + '2 - true (no script/SRCs)' + '\n' + '3 - true (script/images allowed)'); if (parse_js_value_cache != 0 && parse_js_value_cache != 1 && parse_js_value_cache != 2 && parse_js_value_cache != 3){return;} if (!url || url == ''){return;} makeRequestXML(url, parameters,type); }

function alertContents { if (http_request.readyState != 4) return; body = document.getElementById('bodyContent'); if (body && parse_js_value_cache == 3) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; body.innerHTML = ' XML source return: ' + http_request.responseText; } else if (body && parse_js_value_cache == 2) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; var xml = http_request.responseText.replace(/<.script>/gi,'` '); body.innerHTML = ' XML source return: ' + xml.replace(/<script [^`]+`<.script>/gi,).replace(/(<\w* onload=["'][^<]+["']>)/gi,).replace(/(\src=["'][^<]+["']>)/gi,' src="">'); } else if (body && parse_js_value_cache == 1) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; var xml = http_request.responseText.replace(/<.script>/gi,'` '); body.innerHTML = ' XML source return: ' + xml.replace(/<script [^`]+`<.script>/gi,).replace(/(<\w* onload=["'][^<]+["']>)/gi,).replace(/(<img [^<]+>)/gi,'').replace(/(\src=["'][^<]+["']>)/gi,' src="">'); } else if (body && parse_js_value_cache == 0) { document.getElementsByTagName('title')[0].innerHTML = "XML request:"; var xml = http_request.responseText.replace(/<.script>/gi,'` '); xml = xml.replace(/(<a href=["'][^<]+<.a>)/gi,'%parenST|span style="background-color: yellow"|%parenEN$1%parenST|/span|%parenEN').replace(/(<img [^<]+>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<iframe [^<]+<.iframe>)/gi,'%parenST|span style="background-color: lightgreen"|%parenEN$1%parenST|/span|%parenEN').replace(/(<script [^`]+)`<.script>/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1 %parenST|/span|%parenEN').replace(/(<\w* onload=["'][^<]+["']>)/gi,'%parenST|span style="background-color: #FF9900"|%parenEN$1%parenST|/span|%parenEN').replace(/\s(src=["'][^<]+["'])>/gi,'%parenST|span style="background-color: #FF3300"|%parenEN $1>%parenST|/span|%parenEN'); body.innerHTML = ' XML source return: ' + xml.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/%parenST\|/g,'<').replace(/\|%parenEN/g,'>'); } }

//security override HTTP request //ALSO, reduce IE security settings //For FF/NS, go enable, see "http://esw.w3.org/topic/SparqlCalendarDemoUsage#FAQ" //Basically, enable "signed.applets.codebase_principal_support" in about:config function makeRequestXML(url, parameters,type,parse) {  if(window.XMLHttpRequest) { try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) {alert("Permission UniversalBrowserRead denied."); } http_request = false; http_request = new XMLHttpRequest; if (http_request.overrideMimeType) {http_request.overrideMimeType('text/xml'); } if (!http_request) {alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open(type, url + parameters, true); http_request.send(null); } else if (window.ActiveXObject) {   try {http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {     try {http_request = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){} } if (!http_request) {showError(ERROR_XML);} http_request.onreadystatechange = alertContents; http_request.open(type, url + parameters, true); http_request.send(null); } } //

//

//Peer review stuff // Script from User:AndyZ/peerreviewer.js document.write('<script type="text/javascript" src="'             + 'http://en.wikipedia.org/w/index.php?title=User:AndyZ/peerreviewer.js'              + '&action=raw&ctype=text/javascript&dontcountme=s"></s'+'cript>'); spellcheck_PR = true; showInstaview_PR = true; instaview_PR = true; cat_PR = true; initMsg_PR = ""; toolbar_PR = "cactions";