User:Merlin the Immortal/global.js

/*Time Desplayer Clickable ImportJS page Protection Icons Statistics importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:DisplayTimer/code.js',        'u:dev:MediaWiki:ImportJSPage/code.js',        'u:dev:MediaWiki:ProtectionIcons.js',        'u:dev:MediaWiki:RCStats.js',        'u:dev:MediaWiki:SearchSuggest/code.js',    ] }); //Previous Wiki mw.loader.using('mw.Api', function {   var currWiki = mw.config.get('wgServer'),        prevWiki = mw.user.options.get('userjs-prevWiki'),        params;    if (currWiki != 'https://community.fandom.com' && prevWiki === null) {       //Cond. 1.a.        params = {            action: 'options',            optionname: 'userjs-prevWiki',            optionvalue: currWiki,            format: 'json'        };    } else if (currWiki != 'https://community.fandom.com') {        //Cond. 1.b.        params = {            action: 'options',            change: 'userjs-prevWiki=' + currWiki,            format: 'json'        };    } else {        //Cond. 1.c        var ccButton = document.querySelector('.global-navigation .wds-dropdown__content a[href*="community.fandom.com"]');        ccButton.textContent = 'Previous Wiki';        ccButton.href = (!prevWiki) ? currWiki : prevWiki;    }    if (currWiki != 'https://community.fandom.com') {        //Cond. 2        var api = new mw.Api;        api.postWithToken('csrf', params).done(function(data) { console.log(data); });   } });

//Unvote, Credit to HumansCanWinElves (function unvotePoll(window, $, mw) {   if (window.unvotePollLoaded) return;    window.unvotePollLoaded = true;

var url;

mw.loader.using(['mediawiki.util']).then(function {       var threadId = extractThreadId(mw.util.getParamValue('unvotePoll'));        url = mw.util.wikiScript('wikia');

if (threadId) unvote(threadId);

$('#WikiaBar ul.tools').append(           $('').append( $('') .attr('href', "#") .text('PollUnvote') .on('click', promptBox) )       );    });

function unvote(threadId) { $.getJSON(url, {           controller: 'DiscussionThread',            method: 'getThread',            threadId: threadId        }).error(function {            alert('(UnvotePoll) Error loading thread information');        }).then(function(data) {            var pollId = data.poll && data.poll.id;

if (!pollId) { alert('(UnvotePoll) Failed to retrive poll data or thread is not a poll'); return; }

$.post(url, {               controller: 'DiscussionPoll',                method: 'castVote',                pollId: pollId,                answerIds: ''            }).error(function {                alert('(UnvotePoll) Unvoting failed');            }); });   }

function promptBox { var threadId = prompt('Insert link or thread ID of a poll to unvote:'); if (threadId) { threadId = extractThreadId(threadId); if (threadId) { unvote(threadId); } else { alert('(UnvotePoll) Error: Invalid input'); }       }    }

function extractThreadId(str) { var regex = new RegExp('^(?:' + mw.config.get('wgServer').replace(/(https?:\/\/)/, '(?:https?://)?') + '/f/p/)?(\\d+)(:?/r/\\d+.*)?$');

if (typeof str !== 'string' || !regex.test(str)) return false; return str.replace(regex, '$1'); }

})(this, jQuery, mediaWiki);

// Page shortcut var keys = ""; function short(event) { var x = event.key; keys += x;   if (keys.includes("#go")) { keys = ""; var page = prompt("Which page", "Spe/cial:MyPage"); if (page !== null) {window.location.href = "/" + page} else {alert("You didn't leave the page")} } else if (keys.includes("#san")) {window.location.href = "/Special:MyPage/Sandbox"; } else if (keys.includes("#thr")) {window.location.href = document.location.origin + "/f"; } else if (keys.includes("#api.")) {window.location.href = document.location.origin + "/api.php"; } else if (keys.includes("#foru")) {window.location.href = "/Forum:Index"; } else if (keys.includes("#talk")) { var path = window.location.pathname; var list = path.split("/"); var lis2 = list[(list.length)-1].split(":"); var pagename = lis2[(lis2.length)-1]; if (lis2.length == 2) { var namespace = lis2[0] + "_"; } else {var namespace = "";} window.location.href = "/" + namespace + "talk:" + pagename; } else if (keys.includes("#wiki")) { var wiki = prompt("Which wiki", "community"); if (wiki !== null) {window.location.href = "https://" + wiki + ".fandom.com"} } } document.getElementsByTagName("html")[0].addEventListener("keypress", function{short(event);});

//Shortcuts var shButton = document.querySelector('.global-navigation .wds-dropdown__content ul li'); const shortcuts = 'Harry PotterTrollhunters'; a.outerHTML += b;