User:Mavoc/global.js

/* Import Personal Javascript Extensions */ importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:MercuryPreview/code.js',    ] });

/* Edit Modules in Wide Mode */ $("#EditPage").removeClass("editpage-sourcewidemode-off").addClass("editpage-sourcewidemode-on"); $("#EditPageToolbar").addClass("ace-editor-wide");

/* Add Page Load Statistics to the bottom of the page. */ var STATS = $(' ', { style:"padding-left:12px" }); STATS.insertAfter('.license-description'); STATS.text("Page Load Statistics"); var NEWPP = $(' ', { style:"padding-left:12px; padding-bottom:12px" }); NEWPP.insertAfter(STATS); $('#mw-content-text').contents.filter(function {    if (this.nodeType == 8 && /^\s*(NewPP) /.test(this.data)) {        var text = $.trim(this.data);        text = text.replace(/^.+$\n/gm, function(line) { var pct = line.match(/\d+\/\d+/);                          /* Find: 1234/12345 */ if (pct !== null) {pct = eval(pct[0]);                     /* Do the math */ } else {pct = line.match(/\d+\.\d+s/);}                    /* Else Find: 1.234s */ if (pct !== null) {pct = pct[0].match(/\d+\.\d+/)/10;      /* Max time is 10s */ } else {pct = line.match(/\d+ M?K?B/);}                    /* Else Find: 123 KB */ if (pct !== null) {var B = pct[0].match(/M?K?B/);          /* Messured in B or KB or MB */ pct = pct[0].match(/\d+/)/50;                          /* Max of 50 MB */ if (B=="B") {pct = pct/1024/1024;                      /* Might be in bytes */ } else if (B=="KB") {pct = pct/1024}}                  /* ... or kilobytes */ line = line.replace(/\B(?=(\d{3})+(?!\d))/g, ",");         /* Give large numbers some commas */ if (pct !== null) { pct = pct*100;                                         /* Make it a percent style number */ var warn = pct >= 50;                                  /* Is the pct of concern */ var warnStart = ""; var warnEnd = "";                  /* Create placeholder flags */ if (warn) {warnStart = ""; warnEnd = "";}        /* If warn, Apply real falgs */ pct = pct.toFixed(1)+"%";                              /* Trim decimal places and add % sign */ line = line.replace(/\n/, "");                         /* Strip off the new line as we will replace it */ var space = " ";                                       /* Init space var */ space = space.repeat(85 - line.length - pct.length);   /* Add enough spaces to line up percents */ return line+space+warnStart+pct+warnEnd+"\n";          /* Assemble and return the new line */ } else { if (line == "NewPP limit report\n") { return ""; } else if (line == "Lua engine used: Scribunto_LuaSandboxEngine\n") { return ""; } else { return line; }           }        });        NEWPP.text(text);    } });

/* Add Useful Links after Page Load Statistics */ var LINKS = $(' ', { style:"padding-left:12px" }); LINKS.insertAfter(NEWPP); LINKS.text("Useful Links"); var LINKSHERE = $(' ', { style:"font-size:14px; padding-left:12px; padding-bottom:12px" }); LINKSHERE.insertAfter(LINKS); var url = $(location).attr('href'); var regex = /(^.*?fandom.com\/wiki\/)([^\?]*)\??(.*?$)/; var domain = url.replace(regex, "$1"); var page = url.replace(regex, "$2"); var params = url.replace(regex, "$3"); LINKSHERE.append("What Links Here "); LINKSHERE.append("Watchlist ("); LINKSHERE.append("Add - "); LINKSHERE.append("Remove) ");