Jump to content

User:Anomie/PP-report-Greasemonkey-script

From Wikipedia, the free encyclopedia

This is a Greasemonkey script that extracts the "NewPP limit report" and displays it in an ugly yellow box in the upper-right corner of the page. If someone wants to clean it up into an actual gadget, please do!

// ==UserScript==
// @name           Display NewPP report
// @namespace      http://anomie.local/
// @description    Display the NewPP limits report on-screen
// @include        https://en.wikipedia.org/*
// @include        http://localhost/w/*
// @include        http://localhost/wiki/*
// @grant          none
// ==/UserScript==
(function(){
    var tw=document.createTreeWalker(document.getElementById('bodyContent'), 128, null, false);
    while(tw.nextNode()){
        var m=tw.currentNode.nodeValue.match(/NewPP limit report\n([\s\S]*)/);
        if(m){
            var d=document.createElement('DIV');
            d.style.position='absolute';
            d.style.top=0;
            d.style.left=0;
            d.style.fontSize='8pt';
            d.style.color='black';
            d.style.background='yellow';
            d.style.border='1px solid black';
            d.style.zIndex=10000;
            d.style.whiteSpace='pre';
            d.appendChild(document.createTextNode(m[1]));
            document.body.appendChild(d);
        }
    }
})();