User:Darkbitlike/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:View Source/code.js',        'u:dev:MediaWiki:ViewRemoved/code.js',        'u:dev:MediaWiki:RevealAnonIP/usercode.js',        'u:dev:MediaWiki:LastEdited/code.js',        'u:dev:MediaWiki:UnhideUserMasthead/code.js',        'u:dev:MediaWiki:AjaxRC/code.js',        'u:dev:MediaWiki:Discussions Delete All/code.js',        'u:dev:MediaWiki:UserAndIPTools.js',        'u:dev:WHAM/code.js',    ] });

if (wgPageName == 'Special:Imagelist') { addOnloadHook(imagelistTools); } function imagelistTools { addPortletLink('p-cactions', 'javascript:showFLimages(0)', 'Show images (full)', 'ca-showim0', 'loads the images in a full sized image tag'); addPortletLink('p-cactions', 'javascript:showFLimages(1)', 'Show images (small)', 'ca-showim1', 'loads the images in a 200x200 image tag'); addPortletLink('p-cactions', 'javascript:filelistprune', 'Desc links only', 'ca-prune', 'turns the whole page into just a list of links'); } function showFLimages(full) { var links = document.getElementById('bodyContent').getElementsByTagName('a'); var img; for (var i = 0; i < links.length; i++) { if (links[i].firstChild.nodeValue == 'file') { links[i].firstChild.nodeValue = ''; links[i].parentNode.setAttribute('class', 'plainlinks'); img = document.createElement('img'); img.setAttribute('src', links[i].href); if (full == 0) { img.setAttribute('style', 'border:2px outset blue;'); } else { img.setAttribute('style', 'width:200px;height:200px;border:2px outset blue;'); }           links[i].appendChild(img); }   }    document.getElementById('ca-showim0').style.display = 'none'; document.getElementById('ca-showim1').style.display = 'none'; } function filelistprune { var descs = getElementsByClassName(document, 'td', 'TablePager_col_img_name'); var dlist = ' '; for (var i = 0; i < descs.length; i++) { dlist += '' + descs[i].firstChild.title + '\n'; }   dlist += ' \n'; document.getElementById('bodyContent').innerHTML = dlist; document.getElementById('ca-prune').style.display = 'none'; } $(function {   if (mw.config.get('wgNamespaceNumber') == 6) {        $('#WikiaPageHeader').append(' ');        if ($('#ca-undelete').length) {            $('#WikiaPageHeader').append('Undelete | ');        }        $('#WikiaPageHeader').append('Log');        mw.util.addPortletLink('p-cactions', mw.util.wikiGetlink( 'Special:Log?page=' + mw.config.get('wgPageName')), 'Log');    } });

// ***************************************************************** // Load various external scripts // ***************************************************************** // importScriptPage('User:Sannse/forumtools.js', 'community'); // importScriptPage('User:Splarka/contribtools.js', 'community'); // importScriptPage('FastDelete/code.js', 'dev'); /** * Ajax Fast Delete * * @author Splarka * @author Uberfuzzy * @author Grunny * * @version 2.3 */ /*global jQuery, mediaWiki */ "use strict"; window.dev = window.dev || {}; // Don't load twice... if (window.dev.ajaxFastDelete !== undefined) { return false; }   var conf = mw.config.get([            'wgNamespaceNumber',            'wgPageName',            'skin'        ]), self = { version: '2.3', init: function { if (conf.wgNamespaceNumber === -1 || !window.fdButtons || !$('#ca-delete').length) { return; }               var deleteButtons = ''; switch (conf.skin) { case 'uncyclopedia': case 'wowwiki': case 'monobook': deleteButtons = window.fdButtons.map(function (b) {                           var sum = b.summary;                            return '' + b.label + '';                        }).join(''); $('#p-cactions > .pBody > ul').append(deleteButtons); break; case 'oasis': case 'wikia': var $profile = $('.UserProfileActionButton'); deleteButtons = window.fdButtons.map(function (b) {                           var sum = b.summary;                            return '' + b.label + '';                        }).join(' '); if ($profile.exists) { $profile.append(deleteButtons); } else if ($('.page-header__subtitle-blog-post').exists) { $('.page-header__subtitle-blog-post').append(deleteButtons); $('.page-header__blog-post-details').css('margin-right', '5px'); } else { $('.page-header__title').append(deleteButtons); mw.util.addCSS('a[data-id="fastdelete"]:nth-child(1){margin-left:5px}'); }                       break; }               if ($('a[data-id="fastdelete"]').length) { $('a[data-id="fastdelete"]').click(function {                       self.deletePage($(this).attr('data-summary'));                    }); }               mw.hook('fastdelete.init').fire(deleteButtons); },           deletePage: function (deleteReason) { (new mw.Api) .post({                       action: 'delete',                        title: conf.wgPageName,                        reason: deleteReason,                        token: mw.user.tokens.get('editToken')                    }) .done(function (res) {                       location.reload;                    }); }       };    window.dev.ajaxFastDelete = self; mw.loader.using(['mediawiki.util', 'mediawiki.api'], function {        $(self.init);    }); }(window, jQuery, mediaWiki)); // ***************************************************************** // Custom automatic delete buttons // ***************************************************************** // Adds customizable one-click deletion buttons to any deletable page. // Requires w:User:Splarka/fastdelete.js in appendScript; var fdButtons = []; fdButtons[fdButtons.length] = {   'summary': '* Violation of Fandom\'s Terms of Use ',    'label': 'ToU-Violation' }; fdButtons[fdButtons.length] = {    'summary': 'Requested deletion',    'label': 'request-deletion' }; fdButtons[fdButtons.length] = {    'summary': 'Spam ',    'label': 'Spam' }; fdButtons[fdButtons.length] = {    'summary': 'Removed due to DMCA claim',    'label': 'DMCA' }; fdButtons[fdButtons.length] = {    'summary': 'Housekeeping',    'label': 'house-keep' }; fdButtons[fdButtons.length] = {    'summary': 'Unused video', 'label': 'unused-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.wikia.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.wikia.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');    } });
 * (function (window, $, mw, undefined) {