User:Nifky?/monobook.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
importScript('User:EhJJ/twinkle.js');
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Dr pda/prosesize.js&action=raw&ctype=text/javascript');
//
var megaversion = "2.4" // megabook.js V2.4 begins
importScript('User:Microchip08/welcomer.js'); // turns empty talk pages pink; when clicked preloads welcome template
importScript('User:Microchip08/megacheck.js'); // checks to see if you have the current version
importScript('User:Microchip08/pgarequirements.js'); // adds links to usability & references wizards to toolbox
importScript('User:Microchip08/usernamehighlight.js'); // highlights your username on pages
importScript('User:Microchip08/talkblinker.js'); // removes orange new messages banner and blinks "my talk" link instead
importScript('User:Microchip08/viewsource.js'); // view source tab
importScript('User:Microchip08/switcher.js'); // switcher link
importScript('User:Microchip08/cssimport.js'); // adds a gradient to talk pages to make boundaries stand out
importScript('User:Microchip08/histcomb.js'); // tidy history pages (slows down history pages slightly)
importScript('User:Microchip08/stubbifyme.js'); // BETA: Quickly add stubs to articles
// The following script completely screws pretty much everything if you use Vector.
// If you want to enable it, remove the two slashes from the start of the line below.
importScript('User:Microchip08/finderfox.js'); // Adds snazzy icons when you select text (!!!)
// [[User:Microchip08/megabook.js]] (ends)
/*
Gives a character count of the number of letters on a current page before and after removing formatting characters.
It does the following before counting (in this order)
*rm html
*rm headers (==foo==)
*rm bold/italic (''italic'')
*rm Date template
*put template parameters as text outside of template
*remove templates
*put linked text outside of external links
*remove external links
*Put images to there caption/alt text
*make links to text
*make category links to just category name
*rm excess whitespace
Only thing formatting wise that is kept is bullets as arestricks.
maintained by user:Bawolff
*/
mw.loader.load('http://en.wikinews.org/w/index.php?title=User%3ABawolff%2Fmwapilib.js&action=raw&ctype=text/javascript');
$(function () {
mw.util.addPortletLink('p-tb', 'javascript:countThoseChars(wgPageName);', 'Character count', 't-charCount', 'Count the number of characters after removing formating of the current page');
});
function countThoseChars(page) {
//precond page = wgPageName. or it will say its counting wrong page.
var text = document.getElementById('wpTextbox1');
var init;
if (text) {
init = api(text.value);
} else {
init = api(page).getPage();
}
init.push().lift(function (p) { return p.length;}).swap().
replace(/\<[^>]*\>/g, '').
replace(/^\s{0,4}(={1,6})([\s\S]*)\1\s*$/mg, "$2").
replace(/\'{2,5}/g, '').
replace(/\{\{[dD]ate\|[^\}]*\}\}/g, '').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/(\{\{[^\|}]*)\|(\|[^\}=]*\|)?[^\|\}=]*=([^\|}]*)((?:\|[^\}]*)?\}\})/g, '$1$2$4 $3 ').
replace(/\{\{[^\|}]*\}\}/g, '').
replace(/\{\{[^\|}]*\|([^\}]*)\}\}/g, ' $1 ').
replace(/\[http(?:s)?:\/\/\S*\s([^\]]*)]/g, ' $1 ').
replace(/http(?:s)?:\/\/\S*/g, '').
replace(/\[\[[iIfF][mMiI][aAlL][gGeE][eE]?\:[^\]]*\|([^\]]*)\]\]/g, ' $1 ').
replace(/\[\[[cC]ategory\:([^\]]*)\]\]/g, ' $1 ').
replace(/\[\[[^\|\]]*\|([^\]]*)\]\]/g, '$1').
replace(/\[\[([^\]]*)\]\]/g, '$1').
replace(/\s{2,}/g, ' ').
lift2(function (norm, raw) {alert("Normalized article '" + wgTitle + "' has " + norm.length + " characters for " + convertToPoints(norm.length) + " points (" + raw + " characters unnormalized)\n\nNote, this reflects the " + ( text ? "version in the text box, NOT the last saved version" : "last saved version, not what might be unsaved in an edit box somewhere" ) + ". If this article is a photoessay, it may count for more points then mentioned here."); return norm; }).exec();
}
var convertToPoints = function (count) {
var cats = document.getElementById('catlinks').getElementsByTagName('a');
var OR, user, points, catName;
for (var i = 0; i < cats.length; i++) {
catName = cats[i].title
/*if (catName.substring(catName.length - 9, catName.length) === "(WWC2010)") {
user = catName.substring(9, catName.length - 10);
}*/
if (catName === "Category:Original reporting") {
OR = true;
}
}
if (count < 1500) {
points = 1;
} else {
points = 3;
}
if ((count - 1500)/700 > 0) {
points += 2*Math.floor((count - 1500)/700);
}
if (OR) {
points += 3;
}
return points;
}