User:Tvx1/common.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* User:Technical_13/Scripts/OneClickArchiver */
importScript( 'User:Technical_13/Scripts/OneClickArchiver.js' );// Backlink: [[User:Technical_13/Scripts/OneClickArchiver]]
mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3ADr_pda%2Fprosesize.js&action=raw&ctype=text/javascript'); // [[User:Dr_pda/prosesize.js]]
importScript('User:Cameltrader/Advisor.js');
/* User:Joeytje50/AWB.js/load.js */
importScript( 'User:Joeytje50/AWB.js/load.js' );

function awbscript(){
          mw.util.addPortletLink("p-tb", "https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Script", "AWB script", "tb-awbscript", "Run AWB script");
}
 
addOnloadHook(awbscript);
importScript('Wikipedia:AutoEd/formatter.js');
importScript('User:Ucucha/duplinks.js'); // [[User:Ucucha/duplinks]]
function linkcheck() {
	mw.util.addPortletLink("p-tb", "https://dispenser.info.tm/~dispenser/cgi-bin/webchecklinks.py?page=" + mw.config.get("wgPageName"), "Check Links");
}

if (mw.config.get("wgNamespaceNumber") === 0) {
	$.when(
		mw.loader.using("mediawiki.util"),
		$.ready
	).then(linkcheck);
}
importScript( 'User:Enterprisey/reply-link.js' ); // Backlink: [[User:Enterprisey/reply-link.js]]

// // This function shamelessly copied from https://stackoverflow.com/a/11348383/274460
$.fn.ignore = function(sel){
  return this.clone().find(sel||">*").remove().end();
};

function countWords(h) {
 $(h).each(function(i, match) {
  var elements = $(match).nextUntil(h);
  elements.find(':hidden').addClass('wordcount-ignore');
  elements.find('*').filter(function() { return $(this).css('text-decoration').match(/line-through/); }).addClass('wordcount-ignore');
  elements.find('div#siteSub').addClass('wordcount-ignore');
  elements.find('div#contentSub').addClass('wordcount-ignore');
  elements.find('div#jump-to-nav').addClass('wordcount-ignore');
  elements = elements.not('.wordcount-ignore');
  var text = elements.ignore('span.localcomments').ignore('.wordcount-ignore').text();
  var search = /(\d{1,2}):(\d{2}), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g;
  text = text.replace(search, '');
  text = text.split(/\s/).filter(function(d) { return d.length > 0; })
                                        .filter(function(d) { return d.match(/[a-zA-Z0-9]/); });
  var count = text.length;
  $(match).append($('<span class="mw-editsection">' + count.toLocaleString() + ' words</span>'));
 });
}

$(document).ready(function() {
    $('#p-cactions').children('ul.menu').append($('<li><a id="ca-wordcount" title="Add word counts to each section [alt-shift-c]" accesskey="c">Word Count</a></li>'));
    $('#ca-wordcount').click(function() {
	countWords('h1');
	countWords('h2');
	countWords('h3');
    });
});
importScript('User:Enterprisey/cv-revdel.js'); // Backlink: [[User:Enterprisey/cv-revdel.js]]