User:Sannse/global.js

//ForcePreview //importScriptURI('https://internal.wikia-inc.com///index.php?title=MediaWiki:ForcePreview.js&action=raw&ctype=text/javascript');

//CU tweak importScriptURI('//internal-vstf.fandom.com/index.php?title=MediaWiki:CU.js&action=raw&ctype=text/javascript');

importArticles({   type: "script",    articles: [        'u:c:User:Sannse/Imagelisttools.js',

'u:dev:AllPagesHideRedirect/code.js', 'u:dev:DiscussionsFeed.js', 'u:dev:EditBio/code.js', 'u:dev:FastDelete/code.js',

'u:vstf:User:Joeyaa/wham.js', 'u:dev:ViewRemoved/code.js', ] });

// ***************************************************************** // Load various external scripts // *****************************************************************

// importScriptPage('User:Sannse/forumtools.js', 'community'); // importScriptPage('User:Splarka/contribtools.js', 'community');

// ***************************************************************** // Custom automatic delete buttons // ***************************************************************** // Adds customizable one-click deletion buttons to any deletable page.

window.FastDeleteNoConfirm = true ;

var fdButtons = []; fdButtons[fdButtons.length] = { 'summary': '* Violation of Fandom\'s Terms of Use ', 'label': 'ToU' }; fdButtons[fdButtons.length] = { 'summary': 'Requested deletion', 'label': 'reqst' }; fdButtons[fdButtons.length] = { 'summary': 'Spam ', 'label': 'Spam' }; fdButtons[fdButtons.length] = { 'summary': 'Removed due to DMCA claim', 'label': 'DMCA' }; fdButtons[fdButtons.length] = { 'summary': 'Housekeeping', 'label': 'hk' }; fdButtons[fdButtons.length] = { 'summary': 'Unused video', 'label': 'vid' }; // end Custom automatic delete buttons

if (wgNamespaceNumber != -1) addOnloadHook(function {   addPortletLink('p-cactions', '/wiki/Special:Prefixindex/' + escape(wgPageName), 'Subpages', 'ca-subpages', 'Show subages of ' + wgPageName); });

//gear fixer (from uberfuzzy) $('a[data-name="customize"]').html(function {   return $(this).parent.find('img').detach; });

//Thingy from Sactage to fix lookupuser $(function {   if (mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' && mw.config.get('wgCityId') != '177') {        var target = mw.util.getParamValue('target') || mw.config.get('wgPageName').split('/', 2)[1] || null;        if (!target) {            return;        }        $('#contentSub > a:nth-child(9)').attr('href', 'http://community.fandom.com/wiki/Special:LookupUser?target=' + encodeURIComponent(target));    } });

/** * @author: Flightmare (http://elderscrolls.wikia.com/wiki/User:Flightmare) * @version: 1.0 * @license: CC-BY-SA 3.0 * @description: Imports biography from discussions to ns:2 if no profile page is present. */

//replace redlink placeholder with discussions bio. function addDProfile(text) { var content = document.getElementsByClassName("noarticletext")[0]; content.innerHTML = text.replace(/(?:\r\n|\r|\n)/g, ' '); }

function getUserBio(userId) { var request = new XMLHttpRequest; request.onreadystatechange = function { if (request.readyState == 4 && request.status == 200) { var arr = JSON.parse(request.responseText); if (Boolean(arr.value)) { //Only continue if there is an actual bio written. addDProfile(arr.value); }       }    };    request.open("GET", "https://services.fandom.com/user-attribute/user/" + userId + "/attr/bio", true); request.send; }

//Is there a better way to get the user id? function getUserIdByName(username) { var request = new XMLHttpRequest; request.onreadystatechange = function { if (request.readyState == 4 && request.status == 200) { var arr = JSON.parse(request.responseText); userId = arr["query"]["allusers"][0].id; if (Boolean(userId)) { getUserBio(userId); }       }    };    request.open("GET", "/api.php?action=query&list=allusers&aufrom=" + username + "&format=json&aulimit=1", true); request.send; }

$(function createDProfiles {   if (wgNamespaceNumber == 2) {        //Test if profile page exists (we want this to 404)        var request = new XMLHttpRequest;        request.onreadystatechange = function {            if (request.readyState == 4 && request.status == 404) {                var username = wgPageName.substring(wgCanonicalNamespace.length + 1); //This should be i18n-safe.                getUserIdByName(username);            }        };        request.open("GET", "/wiki/" + wgPageName, true);        request.send;    } });

// Adds log link to deleted images header $(function {   if ($('#mw-imagepage-nofile').length) {        $('View logs for this page ').insertAfter('.page-header__title');    } });