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 = null; var A = line.match(/\d+\/\d+/);                            /* Find A: 1234/12345 */ var B = line.match(/\d+\.\d+s/);                           /* Find B: 1.234s */ var C = line.match(/\d+\.?\d* M?K?B/);                     /* Find C: 123 KB */ if (A !== null) {                                          /* If A */ pct = eval(A[0]);                                      /* Do the math */ } else if (B !== null) {                                   /* Else If B */ pct = B[0].match(/\d+\.\d+/)[0]/10;                    /* Max time is 10s */ } else if (C !== null) {                                   /* Else If C */ var b = C[0].match(/M?K?B/)[0];                        /* Measured in B or KB or MB */ pct = C[0].match(/\d+\.?\d*/)[0]/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 */ 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+pct+"\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) ");