User:Maxamegalon2000/monobook.js

// raw version at http://en.wikipedia.org/w/index.php?title=User:Jnothman/monobook.js&action=raw&ctype=text/javascript&dontcountme=s //

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

/**** afd helper ****/ document.write(' ');

/* This is to keep track of who is using this extension: User:Jnothman/afd_helper/script.js */

afdh_summaryprompt = false;

// User:Lupin/popups.js - please include this line

//simplePopups = true; popupShortcutKeys = true; // more options at http://en.wikipedia.org/wiki/Wikipedia:Tools/Navigation_popups

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

// Live Preview customization (from User:Pilaf/Live_Preview), // edit this to your own liking.

wpUserName  = 'Maxamegalon2000';   // User name to display in signatures wpShowImages = true;     // Enable downloading and displaying of images

// Include Live Preview...

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

/* This is to keep track of who is using the Live Preview: User:Pilaf/livepreview.js */

//************************************ Purge cache tab ***************************** //From http://en.wikipedia.org/w/index.php?title=User:Trilobite/Tools&oldid=17855224 function addPurgeTab { ta['ca-purge'] = ['g', 'Purge the internal cache for this page']; if(!document.getElementById) return; var x = document.getElementById('ca-history'); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(!x) return; if(x.children) x = x.children[0]; else x = x.childNodes[0]; addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge'); } //********************************* Show Last Diff ********************************* //From User:JesseW/monobook.js function doLastDiff { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") { var pname=textContent(z[n]); }; }; var nurl="http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev"; document.location=nurl }

//************************************ Changes since I last edited **************************** //From User:JesseW/monobook.js function addSinceTab { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) { do_since_I_last_edited }   else if (!/wiki\/Special:|w\/index.php?title=Special:/.test(window.location.href)) { var thetitle=document.title.slice(0, String(document.title).indexOf(" - ")); var l=addlilink(tabs, "/w/index.php?title="+thetitle+"&action=history&gotosince=true", 'since', ''); l.lastChild.title="Changes since I last edited"; } } function do_since_I_last_edited { var csub=document.getElementById("contentSub"); var msg=document.createElement("p"); msg.appendChild(document.createTextNode ("Parsing history... please wait...")); msg.className="error"; csub.insertBefore(msg, csub.firstChild)

var username=textContent(document.getElementById("pt-userpage")); var hists=document.getElementById("pagehistory").childNodes; for (n=0;n<hists.length;n++) { if (hists[n].getElementsByTagName && textContent(hists[n].getElementsByTagName("span")[0])==username) { document.location=hists[n].childNodes[1].href; return; } }

msg.replaceChild(document.createTextNode ("You have not edited this page! (At least not recently!)"), msg.firstChild); }

//************************************ Edit lead section ***************************** //From http://en.wikipedia.org/w/index.php?title=User:ABCD/monobook.js&oldid=19452182 function addEditSection0{ ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page']; if(!document.getElementById) return; var x = document.getElementById('ca-edit'); if(!x) return; var y = document.createElement('LI'); y.id = 'ca-edit-0'; if(x.className == 'selected'){ if(/&action=edit&section=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&section=0$/.test(window.location.href)){ x.className = 'istalk'; y.className = 'selected istalk'; } else { y.className = 'istalk'; }   } else { y.className = x.className; x.className = 'istalk'; }   var z = document.createElement('A'); if(x.children){ z.href = x.children[0].href + '&section=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 + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling); } }

//************************************ Regexp replace tab ************************************ //From http://en.wikipedia.org/w/index.php?title=User:Trilobite/Tools&oldid=17855224 //Renamed by JesseW. function regexpReplaceTab { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("Editing ") == 0) addlilink(tabs, 'javascript:replace', 'replace', ''); } function replace { var s = prompt("Search regexp?"); if(s) { var r = prompt("Replace regexp?"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } }

//************************************ Tabs at bottom ************************************ function tabsAtBottom { var tabs = document.getElementById('p-cactions').cloneNode(true); tabs.id = 'mytabs'; var listitems = tabs.getElementsByTagName('LI'); for (var i=0;i<listitems.length;i++) { if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id; } document.getElementById('column-content').appendChild(tabs); }

//************************************ Utility functions ************************************ function addlilink(tabs, url, name, id) { var na = document.createElement('a'); na.href = url; na.id = id; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.appendChild(na); tabs.appendChild(li); return li; } function addlilink2(tabs, url, name, id, title) { var l=addlilink(tabs,url,name,id); l.lastChild.title=title; return l; } /**** Add tab as menu ****/ function addlimenu(tabs, name, id) {   var na = document.createElement('a'); na.href = '#'; var mn = document.createElement('ul'); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.className = 'tabmenu'; li.appendChild(na); li.appendChild(mn); tabs.appendChild(li); return li; } // ******* Cross browser textcontent function textContent(el) { if (el.textContent) return el.textContent; return el.innerText; }

/************ add unwatch to watchlist ***********/ $(function {    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?title=Special:Watchlist&action=submit&remove=1&id[]="+encodeURIComponent(links[i].title);        unwatch.title = "Unwatch "+links[i].title;        unwatch.appendChild(document.createTextNode("unwatch"));        links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);        links[i].parentNode.insertBefore(links[i].previousSibling.cloneNode(true), unwatch);    } });

/* function talkpageplus {   var talkpagelink = document.getElementById('ca-talk'); if (talkpagelink.className == 'new') {       talkpagelink.firstChild.href += '&section=new'; } } $(talkpageplus);

//***************************************************************************************** window.onload = Main;

function Main { // autoWikiWatchlist; if (LivePreviewInstall) LivePreviewInstall; addForceSummary var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; // addlimenu(tabs, 'Watchlists', 'watchlists-menu'); // addWikiWatchlist("Interests"); // addWikiWatchlist("Wikipedia"); // addWikiWatchlist("Conversations"); // addWikiWatchlist("News"); addlilink2(tabs, "javascript:doLastDiff", 'last', '',"Show most recent diff"); // addlilink2(tabs, "javascript:doPUI", 'PUI', '', "Tag images as unverifiedimage"); addSinceTab; /*Complicated if statements; need to find a neat way to do this...*/ // doNextItem; regexpReplaceTab; addEditSection0; addPurgeTab; // tabsAtBottom; //automate; //cesarb_fixDiffOverflowLoadListener; }

//

// 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');

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

/* * Javascript Diff Algorithm * By John Resig (http://ejohn.org/) and en:User:Lupin * * More Info: * http://ejohn.org/projects/javascript-diff-algorithm/ */

function diffEscape(n) { return n.replace(/&/g, "&amp;").replace(//g, "&gt;") .replace(RegExp('"','g'), "&quot;"); } function delFmt(x) {  if (!x.length) return ;   return "" + diffEscape(x.join()) +" "; } function insFmt(x) {   if (!x.length) return ;  return "" + diffEscape(x.join()) +" "; }

function copyDiffObj(x){ var ret=[]; for (var i=0; i 0) count++; } return count; }

//function debug(s){ // try {document.getElementById('debug').value+=s+'\n'; } catch(foo) {}; //}

function untangle( a, b) { // try to remove crossing edges from an ordered bipartite graph, // removing the least number possible var aa=copyDiffObj(a); var bb=copyDiffObj(b);

// remove the edge with the largest number of crossings until no // crossings remain do { var maxCrossings=0; var worstEdge=null; for (var i=0; i maxCrossings) { maxCrossings=c; worstEdge=i; } }   if (worstEdge!=null) { aa[ bb[worstEdge].row ] = aa[ bb[worstEdge].row ].text; bb[worstEdge] = bb[worstEdge].text; } } while (maxCrossings > 0); return { a: aa, b: bb }; }

window.max=function(a,b){return ab ? b : a;}

function shortenDiffString(str, context) { var output=[]; var s=str; var m=true; while ( true ) { var re=RegExp('(<del[\\s\\S]*? |<ins[\\s\\S]*? )+');   m=re.exec(s); if(!m) break; var t=(s.substring(max(0,m.index-context), min(s.length, m.index+m[0].length+context))); //alert(s+'\n\n\n'+m[0] +'\n\n'+(m.index-context) + '\n\n'+t); output.push(t); s=s.substring(min(s.length, m.index+m[0].length)); } return output; }

function diffString( o, n ) { var out = diff( o.split(/\b/), n.split(/\b/) ); var str = ""; var acc=[]; // accumulator for prettier output

// crossing pairings -- 'A B' vs 'B A' -- cause problems, so let's iron them out //var untangled=untangle(out.o, out.n); <-- too slow! //out.o=untangled.a; out.n=untangled.b; var maxOutputPair=0; for (var i=0; i out.n[i].row ) { // tangle - delete pairing out.o[ out.n[i].row ]=out.o[ out.n[i].row ].text; out.n[i]=out.n[i].text; }     if (maxOutputPair < out.n[i].row) maxOutputPair = out.n[i].row; } }

// output the stuff preceding the first paired old line for (var i=0; i<out.o.length && out.o[i].text == null; ++i) acc.push( out.o[i] ); str += delFmt(acc); acc=[]; // main loop for ( var i = 0; i < out.n.length; ++i ) { // output unpaired new "lines" while ( i < out.n.length && out.n[i].text == null ) acc.push( out.n[i++] ); str += insFmt(acc); acc=[]; if ( i < out.n.length ) { // this new "line" is paired with the (out.n[i].row)th old "line" str += out.n[i].text; // output unpaired old rows starting after this new line's partner var m = out.n[i].row + 1; while ( m < out.o.length && out.o[m].text == null ) acc.push ( out.o[m++] ); str += delFmt(acc); acc=[]; } }  return str; }

function diff( o, n ) { var ns = new Object; var os = new Object; // pass 1: make hashtable ns with new rows as keys for ( var i = 0; i < n.length; i++ ) { if ( ns[ n[i] ] == null ) ns[ n[i] ] = { rows: new Array, o: null }; ns[ n[i] ].rows.push( i ); } // pass 2: make hashtable os with old rows as keys for ( var i = 0; i < o.length; i++ ) { if ( os[ o[i] ] == null ) os[ o[i] ] = { rows: new Array, n: null }; os[ o[i] ].rows.push( i ); } // pass 3: pair unique new rows and matching unique old rows for ( var i in ns ) { if ( ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1 ) { n[ ns[i].rows[0] ] = { text: n[ ns[i].rows[0] ], row: os[i].rows[0] }; o[ os[i].rows[0] ] = { text: o[ os[i].rows[0] ], row: ns[i].rows[0] }; } }  // pass 4: pair matching rows immediately following paired rows (not necessarily unique) for ( var i = 0; i < n.length - 1; i++ ) { if ( n[i].text != null && n[i+1].text == null &&         n[i].row < o.length - 1 && o[ n[i].row + 1 ].text == null &&          n[i+1] == o[ n[i].row + 1 ] ) { n[i+1] = { text: n[i+1], row: n[i].row + 1 }; o[n[i].row+1] = { text: o[n[i].row+1], row: i + 1 }; } }  // pass 5: pair matching rows immediately preceding paired rows (not necessarily unique) for ( var i = n.length - 1; i > 0; i-- ) { if ( n[i].text != null && n[i-1].text == null &&         n[i].row > 0 && o[ n[i].row - 1 ].text == null &&          n[i-1] == o[ n[i].row - 1 ] ) { n[i-1] = { text: n[i-1], row: n[i].row - 1 }; o[n[i].row-1] = { text: o[n[i].row-1], row: i - 1 }; } }  return { o: o, n: n }; }

//

mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript');

// User:Zocky/PicturePopups.js document.write(' ');

// install User:Cacycle/diff text diff code document.write(' ');

// install User:Pilaf/Live_Preview page preview tool document.write(' ');

// install User:Cacycle/editor edit tool document.write(' ');

//Please leave the following line //user:Where/usertabs

$(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=move&user=" + username, "page moves", "ca-pagemoves", "page moves", "");     addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=" + username, "block log", "ca-blog", "blog", "");     addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=" + username, "edit count", "ca-kate", "kate", "");  } });

function inc (file) { mw.loader.load('/w/index.php?title='+file+'&action=raw&ctype=text/javascript&dontcountme=s'); } inc("User:Lightdarkness/aiv.js");

// Script from User:ais523/editcount.js document.write(' ');