User:Random832/common.js

// wikibits customization if(window.histrowinit) window.removeEventListener('load',histrowinit,false); ts_alternate_row_colors = false;

// General library stuff */

/* check if page is discussion */

/* Add a tab for arbitrary actions */

// Alt text */

// User:Random832 script for finding "resolved" tags.

(function submit_validation_hook { // set up submit validation }

// Edit summary check */

// links on CAT:PER */

$(function {  var s = document.createElement('STYLE');   s.textContent = '#edittools_hide_for_script_test {display:none}';   document.getElementsByTagName('HEAD')[0].appendChild(s); });

/* change diff to history in new messages */

// Section organizer for ANI

/* proof of concept for edit summary length. Not yet converted to wikipedia window.onload = function { var box = document.getElementById("editsummary") var len = document.getElementById("length_value") function utfslop(s) { var count = 3; for(var i=0;i '\u007f') count++; if(s[i] > '\u07ff') count++; }		return count; }	box.onkeypress = function(evt) { this.maxLength = 255 - utfslop(this.value); if(this.value.length > this.maxLength) this.value = this.value.substr(0,this.maxLength); } }  

/* addOnloadHook(function {  var item = mw.util.addPortletLink('p-cactions',,'ßsocks','ca-betasocks','Check socks with Betacommand\'s tool',,null);   var link=item.firstChild;   link.onclick = function {       jsMsg(''+ ' ' + ' Master<\/th> <\/td><\/tr>' + ' Socks<\/th> <\/td><\/tr>' + ' Key<\/th> <\/td><\/tr>' + ' <\/td><\/tr><\/table>'+'<\/form>','betasocks');       return false;   } }); */

$(function {  var p = document.getElementById("p-logo");   if(!p) return;   var a = p.firstChild;   while(a.nodeType != 1) a = a.nextSibling;   var done = false;   a.onclick = function {       if(!done) this.style.backgroundImage = 'none';       var ret = done; done = true; return ret;   } });

/* convert this bookmarklet later on. javascript:(function{if(!window['$ssZapClosedXFD']){var x=document.createElement('STYLE');x.textContent='.xfd-closed{display:none} .boilerplate.metadata.vfd{display:none}'; document.getElementsByTagName('HEAD')[0].appendChild(x); window['$ssZapClosedXFD']=x.sheet}else{ window['$ssZapClosedXFD'].disabled=!window['$ssZapClosedXFD'].disabled}}); */

/* snippet for WP:AN semi-protection, look at later if (wgEditRestriction.length > 0) { addOnloadHook(function {   var msg_cantedit = document.getElementById("cantedit-msg");    var msg_isprotected = document.getElementById("isprotected-msg");    if(!msg_cantedit && !msg_isprotected)     var canEdit = false;    for(var i=0;i<wgUserGroups.length;i++) {        for(var ii=0;ii<wgEditRestriction.length;ii++) {            if(wgUserGroups[i] == wgEditRestriction[ii]) canEdit = true;        }    }    if(canEdit) { if(msg_isprotected) msg_isprotected.style.display='block'; }    else { if(msg_cantedit) msg_cantedit.style.display='block'; }  }); }

if(wgPageName == 'Special:Watchlist') { addOnloadHook(function {   document.forms[0].method = 'get'; // TODO make more robust  }); }

function addEditWarnings(warntext) { if(!warntext) warntext = "Are you sure you want to edit this page?"; function do_warn { return confirm(warntext); } var spans = document.getElementsByTagName('SPAN'); for(var i=0;i<spans.length;i++) { if(/\beditsection\b/.test(spans[i].className)) mkEvt(spans[i],'click',do_warn); } mkEvt(document.getElementById('ca-edit'),'click',do_warn); }

function logCalls(obj,prop) { var oldfn = obj[prop]; obj[prop] = (function(ofn,nm) {   return (function {       var ret = ofn.apply(this,arguments); console.debug("called %s on %o with arguments %o, returned %o",nm,this,arguments,ret); });   })(oldfn,prop); }

logCalls(window,'hookEvent'); logCalls(window,'addHandler'); logCalls(window,'addClickHandler');

$(function { var uploadtab = document.getElementById('t-upload');  if(!uploadtab) return  var uploadtablink = uploadtab.getElementsByTagName('a')[0];  if(!uploadtablink) return;  uploadtablink.href = wgArticlePath.replace('\$1','Special:Upload'); });

function shortenTabs { function st(id, text) { try { document.getElementById(id).getElementsByTagName('A')[0].textContent = text; } catch(x) {} }   function img(src,alt) { var x=document.createElement('IMG'); x.src=src; x.alt=alt; return x;   } st('ca-edit','Edit'); st('ca-talk','Talk'); st('ca-delete','Delete'); st('ca-protect','Prot.'); var unprotect = document.getElementById('ca-unprotect'); if(unprotect) { unprotect = unprotect.getElementsByTagName('A')[0]; unprotect.textContent = ''; if(wgRestrictionEdit[0] && wgRestrictionEdit[0] == "autoconfirmed") unprotect.appendChild(img('http://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Padlock-silver-medium.svg/16px-Padlock-silver-medium.svg.png','SP')); if(wgRestrictionEdit[0] && wgRestrictionEdit[0] == "sysop") unprotect.appendChild(img('http://upload.wikimedia.org/wikipedia/en/thumb/5/59/Padlock.svg/16px-Padlock.svg.png','FP')); else if(wgRestrictionMove[0] && wgRestrictionMove[0] == "sysop") unprotect.appendChild(img('http://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Padlock-olive.svg/16px-Padlock-olive.svg.png','MP')) } }

$(shortenTabs);

// Twinkle Lite importScript('User:AzaToth/morebits.js'); importScript('User:AzaToth/twinklefluff.js'); //importScript('User:AzaToth/twinklewarn.js'); //importScript('User:AzaToth/twinklearv.js'); //importScript('User:AzaToth/twinklespeedy.js'); importScript('User:AzaToth/twinklediff.js'); //importScript('User:AzaToth/twinkleprotect.js'); //importScript('User:AzaToth/twinkleprod.js'); //importScript('User:AzaToth/twinklexfd.js'); //importScript('User:AzaToth/twinkleimage.js'); //importScript('User:AzaToth/twinkleunlink.js'); //importScript('User:AzaToth/twinkledelimages.js'); //importScript('User:AzaToth/twinkledeprod.js'); //importScript('User:AzaToth/twinklebatchdelete.js'); //importScript('User:AzaToth/twinklebatchprotect.js'); //importScript('User:AzaToth/twinkleimagetraverse.js');

// install User:Cacycle/wikEdDiff enhanced diff view using ajax document.write('<\/script>');

/* var fractions = { 2:{1:'½'},3:{1:'⅓',2:'⅔'},4:{1:'¼',3:'¾'},8:{1:'⅛',3:'⅜',5:'⅝',7:'⅞'} /*,5:{1:'⅕',2:'⅖',3:'⅗',4:'⅘'},6:{1:'⅙',5:'⅚'}*//* };

function fixfracs { var spans = document.getElementsByTagName('SPAN'); for(var i=0;i<spans.length;i++) { var span=spans[i]; if(span.className != 'template-frac') continue; var den = span.lastChild.textContent; var num = span.firstChild.textContent; if(fractions[den] && fractions[den][num]) { span.textContent = fractions[den][num]; span.className = 'template-frac-vulgarized'; } } }

$(fixfracs);

function toolsbreak { function del(x) { var y = document.getElementById(x); if(!y) return; document.removeElement(y) } del("ca-delete"); del("ca-undelete"); del("ca-protect"); // not removing ca-unprotect since i've configured it to show // accurate information about the current protection status del("t-blockip"); }

$(toolsbreak);