User:Brantmeierz/User scripts

From Simple English Wikipedia, the free encyclopedia
Jump to navigation Jump to search

User Tab Improvements[change | change source]

// ==UserScript==
// @name         User Tab Improvements
// @version      1.0
// @description  Adds more tabs for extra information on pages relating to a user
// @author       brantmeierz
// @match        https://simple.wikipedia.org/wiki/User:*
// @match        https://simple.wikipedia.org/wiki/User_talk:*
// @match        https://simple.wikipedia.org/wiki/Special:Contributions/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var username = window.location.href.match(/(?=)https:\/\/simple.wikipedia.org\/wiki\/User:(.*)(?<=)\//);
    if (username != null) {
        username = username[1];
    } else {
        username = window.location.href.match(/(?=)https:\/\/simple.wikipedia.org\/wiki\/User:(.*)/);
        if (username != null) {
            username = username[1];
        } else {
            username = window.location.href.match(/(?=)https:\/\/simple.wikipedia.org\/wiki\/User_talk:(.*)/);
            if (username != null) {
                username = username[1];
            } else {
                username = window.location.href.match(/(?=)https:\/\/simple.wikipedia.org\/wiki\/Special:Contributions\/(.*)/)[1];
            }
        }
    }
    var pageElement = 'ca-talk';
    if (document.getElementById('ca-talk') == null) {
        pageElement = 'ca-nstab-special';
        document.getElementById(pageElement).parentElement.innerHTML += '<li><a href="https://simple.wikipedia.org/wiki/User:' + username + '">User page</a></li>';
        document.getElementById(pageElement).parentElement.innerHTML += '<li><a href="https://simple.wikipedia.org/wiki/User_talk:' + username + '">User talk</a></li>';
    } else {
        document.getElementById(pageElement).parentElement.innerHTML += '<li><a href="https://simple.wikipedia.org/wiki/Special:Contributions/' + username + '">Contributions</a></li>';
    }
    document.getElementById(pageElement).parentElement.innerHTML += '<li><a href="https://xtools.wmflabs.org/ec/simple.wikipedia.org/' + username + '">Statistics</a></li>';
})();