User:JzG/monobook.js

var remSpamSummary = { 'de' : 'Externer Link __LINK__ gemäß __REPORT__ entfernt.', 'en' : 'Removing external link: __LINK__ -- per __REPORT__.', 'es' : 'Eliminando enlace externo __LINK__ por __REPORT__.', 'fr' : 'Lien externe __LINK__ enlevé par __REPORT__.', 'nb' : 'Fjerner ekstern lenke __LINK__ per __REPORT__.', 'nl' : 'Link naar __LINK__ verwijderd per __REPORT__.', 'nn' : 'Fjernar utlenkja __LINK__ per __REPORT__.', 'no' : 'Fjerner ekstern lenke __LINK__ per __REPORT__.', 'ru' : 'Удалена внешняя ссылка __LINK__ согласно __REPORT__.', 'uk' : 'Вилучена зовнішня посилання __LINK__ згідно __REPORT__.' }; if(mw.config.get('wgCanonicalNamespace') == "Special" && mw.config.get('wgCanonicalSpecialPageName') == "Linksearch") { addOnloadHook(function {       addPortletLink('p-cactions', "javascript:rem_spam", "Remove external links", 'ca-remspam', 'Alter all the links on this page to automatically remove the given external link from the linked page.');    }); } if(mw.config.get('wgAction') == 'edit' && location.href.indexOf('remspam=') != -1) { addOnloadHook(function {       var tag = query_get('remspam');        var box = document.getElementById('wpTextbox1');        var txt = box.value;        var reg = tag.replace('http://', ).replace(/\./g, '\\.').replace(/\*\\?\./g, '(?:.*?\\.)?');        var newtext = +txt;        if(!query_get('options') || (',' + query_get('options') + ',').indexOf(',lines,') != -1) newtext = newtext.replace(new RegExp('^\\s*\\*.*?\\[?https?\\://'+reg+'/?.+?(?:\\s+(.+?)\\]|.*?)\n', 'igm'), );        if(!query_get('options') || (',' + query_get('options') + ',').indexOf(',citeweb,') != -1) newtext = newtext.replace(new RegExp('(?:\\s*)?\\{\\{\\s*cite[_ ]web\\s*\\|(?:.*?\\|)*\\s*url\\s*=\\s*https?\\://'+reg+'/?.*?\\s*(?:\\|.*?)?\\}\\}(?:\\s*<\/ref>)?', 'ig'), );        if(!query_get('options') || (',' + query_get('options') + ',').indexOf(',inline,') != -1) newtext = newtext.replace(new RegExp('(?:\\s*)?\\[?https?\\://'+reg+'/?.+?(?:\\s+(.+?)\\]|(\\s))(?:\\s*<\/ref>)?', 'ig'), '$1'); box.value = newtext; if (query_get('usesummary')) { summary = query_get('usesummary').replace(/__LINK__/g, tag); } else if (query_get('remspam') && query_get('report')) { summary = remSpamSummary[mw.config.get('wgContentLanguage')] || 'Removing external link: __LINK__ -- per __REPORT__. Translate this summary.'; summary = summary.replace(/__LINK__/g, tag) summary = summary.replace(/__REPORT__/g, 'm:' + query_get('report') + ''); } else { summary = 'Removing external link: '+tag+' per m:Talk:Spam_blacklist'; }       document.getElementById('wpSummary').value = summary; document.getElementById('wpMinoredit').checked = true; document.getElementById('wpWatchthis').checked = false; document.getElementById('wpDiff').click; }); } function rem_spam {   var targ = query_get('target') || unescape(location.href).split('/').reverse[0].split('?')[0].split('#')[0];    var tag = prompt('Please insert a link (without http://) to remove from\nall pages listed here. Example (and default if textbox is blank):\n'+targ);   if(tag == null) { alert('Action canceled.'); return; }    if(tag == "") tag = targ;    var options = prompt('Please enter the option modes you would want.\nEnter each one in the textbox (without any seperation marker)\ne=Remove lines that contain the link\ni=Remove links inline in text\nc=Remove Cite_web templates using the link\nExample: ci\nLeave the box blank for all modes');    if(options == null) { alert('Action canceled.'); return; }    if(options == "") options = 'eic';    options = options.split(new RegExp());    var opt = ;    for(var x in options) {        var y = options[x];        if(y == 'c') opt += ',citeweb';        if(y == 'i') opt += ',inline';        if(y == 'e') opt += ',lines';    }    opt = opt.substring(1);    options = opt;    var usesummary = prompt('Please enter a summary to use\nDefault: Removing external link: __LINK__ per m:Talk:Spam blacklist'); if(usesummary == null) { alert('Action canceled.'); return; } if(usesummary == '') usesummary = 'Removing external link: __LINK__ -- per m:Talk:Spam blacklist'; var links = getElementsByClassName(document, 'ol', 'special')[0].getElementsByTagName('a'); for(var i=0; i]+)>)/g, ''); }   var btn = document.getElementById('ca-remspam').firstChild; btn.href = 'javascript:unrem_spam;'; btn.innerHTML = 'Un-highlight links'; btn.title = ''; } function unrem_spam { var links = document.getElementById('bodyContent').getElementsByTagName('a'); for(var i=0; i<links.length; i++) { var link = links[i]; link.href = link.href.split('linkmodified=yes')[0]; link.style.color = ""; }   alert('All links will now be safe to click...'); var btn = document.getElementById('ca-remspam').firstChild; btn.href = 'javascript:rem_spam;'; btn.innerHTML = 'Remove external links'; btn.title = ''; } //parse paramName out of query string //stolen from Lupin's popups function query_get(paramName) { var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)'); var h=document.location; var m; if (m=cmdRe.exec(h)) { try { return unescape(m[1]); } catch (someError) {} } return null; };

function importAnyScript(lang,family,script) { //use importScriptURI with the full-qualified source, else importScript; runs in the context of the remote wiki, finding nothing. mw.loader.load('http://'		+ encodeURIComponent(lang) + '.'		+ encodeURIComponent(family) + '.org/w/index.php?title='		+ encodeURIComponent(script) + '&action=raw&ctype=text/javascript'); } importAnyScript('meta','wikimedia','User:Mike.lifeguard/remote.js');

// Add WP:Reflinks launcher in the toolbox on left $(function { mw.util.addPortletLink( "p-tb",    // toolbox portlet "http://dispenser.homenet.org/~dispenser/cgi-bin/webreflinks.py/" + mw.config.get('wgPageName') + "?client=script&citeweb=on&overwrite=&limit=20&lang=" + mw.config.get('wgContentLanguage'), "Reflinks" // link label )});