Jump to content

User:Dudemanfellabra/vector.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.
function LoadScript(title) {
    mw.loader.load('/w/index.php?title='+mw.util.wikiUrlencode(title)+'&action=raw&ctype=text/javascript');
}

LoadScript('User:Dr pda/prosesizebytes.js');                 // Adds "Page size" to Toolbox section
LoadScript('User:Shubinator/DYKcheck.js');                   // Adds link to check DYK eligibility
LoadScript('User:קיפודנחש/viewstats.js‎');                    // Adds link for page views
LoadScript('User:Anomie/unwatch.js');                        // Adds unwatch links to watchlist
LoadScript('User:Enterprisey/watchlist-notice.js');          // Notifies me when my watchlist updates
LoadScript('User:Anomie/linkclassifier.js');                 // Colors redirects, dabs, etc. differently than regular links
LoadScript('User:Theopolisme/Scripts/adminhighlighter.js');  // Highlights users if they are admins
LoadScript('User:Equazcion/CatListMainTalkLinks.js');        // Add links to talk pages in categories
LoadScript('User:Anomie/useridentifier.js');                 // Adds info to user pages
LoadScript('User:Dudemanfellabra/diffs.js');                 // Adds time between diffs
LoadScript('User:Writ Keeper/Scripts/commonHistory.js');     // Show inline diffs instead of loading separate page
LoadScript('User:Ais523/bracketmatch.js');                   // Checks template syntax while editing
LoadScript('User:Kephir/gadgets/cksyntax.js');               // Check syntax of JavaScript before saving

var loadTime = new Date();

function CustomMain() {
    if (mw.config.get('wgPageName') == "Main_Page") {
      window.location.replace('http://en.wikipedia.org/wiki/Wikipedia:Main_Page_alternative_(CSS_Update)'); //My custom main page
    }
}

function LoadTime() {
    var mySpan = document.createElement( 'div' );
    mySpan.setAttribute('style', 'float:right; font-size:11px; color:#555; margin-top:3px;')
    mySpan.setAttribute('id', 'loadtime')

    var ul = document.getElementById('pt-logout').parentNode.parentNode;

    var date    = '0' + loadTime.getUTCDate();
        date    = date.substr(date.length-2, date.length);
    var month   = '0' + loadTime.getUTCMonth() + 1;
        month   = month.substr(month.length-2, month.length);
    var year    = loadTime.getUTCFullYear();
    var hours   = '0' + loadTime.getUTCHours();
        hours   = hours.substr(hours.length-2, hours.length);
    var minutes = '0' + loadTime.getUTCMinutes();
        minutes = minutes.substr(minutes.length-2, minutes.length);
    var timestring = "Page loaded at " + year + "-" + month + "-" + date + ", " + hours + ":" + minutes + " (UTC)";
    datePlace = ul.appendChild(mySpan);
    datePlace.innerHTML = timestring;

    TimeSinceLoad();
}

function TimeSinceLoad() { // Adds time since load as tooltip
    var currentTime = new Date();

    var diff = DateSub(loadTime,currentTime);  // inside User:Dudemanfellabra/diffs.js
    document.getElementById('loadtime').title=diff + ' ago';
    var t = setTimeout("TimeSinceLoad()",60000);
}

function Reflinks() {
    mw.util.addPortletLink("p-tb","//toolserver.org/~dispenser/cgi-bin/webreflinks.py/"+mw.config.get('wgPageName')+"?client=script&citeweb=on&overwrite=&limit=20&lang="+mw.config.get('wgContentLanguage'),"Reflinks")
}

function EditCount() {
    document.getElementById("pt-userpage").innerHTML+=" ("+mw.config.get('wgUserEditCount')+" edits)"
}

var WatchListHiddenUsers=["Hmains","Ser_Amantio_di_Nicolao"]

function WatchlistHideUsers() {
    if (mw.config.get('wgPageName')!="Special:Watchlist") return;
    if (Object.prototype.toString.call(WatchListHiddenUsers)!=='[object Array]') return;
    var edits=document.getElementsByClassName("mw-userlink")
    if (edits==null) return;

    var hiddenCount=0
    for (var i=0; i<WatchListHiddenUsers.length; i++) {
        for (var j=0; j<edits.length; j++) {
            if (edits[j].href.search(WatchListHiddenUsers[i])!=-1) {
                if (edits[j].parentNode.parentNode.style.display!="none") {
                    edits[j].parentNode.parentNode.style.display="none"
                    hiddenCount++
                } else {
                    edits[j].parentNode.parentNode.style.display=""
                }
            }
        }
    }

    var title=document.getElementById("firstHeading")
    if (hiddenCount>0) {
        title.innerHTML+=" <small>("+hiddenCount+" edits hidden; <a onclick='WatchlistHideUsers()'>Show them</a>)</small>"
    } else {
        title.innerHTML=title.innerHTML.replace(/ <small>.*?<\/small>/g,"")
    }
}

$(window).load(LoadTime);                                      // Adds UTC clock to top right of page
$(window).load(CustomMain);                                    // My custom Main Page
$(window).load(Reflinks);                                      // Add [[WP:Reflinks]] to toolbox
$(window).load(EditCount);                                     // Show edit count by username in toolbar
$(window).load(WatchlistHideUsers);                            // Hide certain users edits on watchlist

LoadScript('User:Dudemanfellabra/NRHPstats.js');             // Tally up stats on individual NRHP county lists
LoadScript('User:Dudemanfellabra/UpdateNRHPProgress.js');    // Script to automatically update WP:NRHPPROGRESS
LoadScript('User:Dudemanfellabra/NRHPmap.js');               // Generate copy-paste code for SVG map
LoadScript('User:Dudemanfellabra/NRHPProgressHistory.js');   // Extracts data about historical progress from WP:NRHPPROGRESS
LoadScript('User:Dudemanfellabra/NRISOnly.js');              // Script for bot tagging NRIS-only articles
LoadScript('User:Dudemanfellabra/ReorderNRHPlist.js');       // Automate re-ordering of NRHP county lists after addition/deletion
LoadScript('User:Dudemanfellabra/AssessNRHP.js');            // Semi-automates assessment of NRHP articles
LoadScript('User:Dudemanfellabra/AddCommonsCatLinks.js');    // Check for and add links to commons categories on NRHP lists
LoadScript('User:Dudemanfellabra/Sandbox.js');               // Sandbox for testing code