User:Arashiryuu0/wikia.js

window.onload = function { importScriptPage('MediaWiki:Tooltips.js', 'bloodborne'); window.tagList = { 'Founder': 'Wiki Creator', 'Bureaucrat': 'Wiki Administration', 'Administrator': 'Wiki Administration', 'Admin': 'Wiki Administration', 'Content Moderator': 'Wiki Content Moderator', 'Chat Moderator': 'Wiki Chat Moderator', 'Discussions Moderator': 'Wiki Discussions Moderator', 'Elkian': '16th Ranked Exceed', 'Old Deus': 'Wiki Administration', 'Staff': 'Fandom Staff', 'Tet': 'The One True God', '『　』': 'Blank' };   /***********************     ********** 0 **********     ***********************/    (function {        var profile = $_('.UserProfileMasthead'),            hgroup, rights, tags, len, n, e, i, j,            name;        if (!profile) return;        rights = {            'Arashiryuu0': ['Elkian', '『　』'],            'Robyn Grayson': ['Old Deus']        };        hgroup = $_('.masthead-info hgroup');        name = hgroup.children[0].textContent;        if (rights.hasOwnProperty(name)) {            tags = $$('.masthead-info .tag');            if (tags.length) {                n = 0; j = tags.length - 1;                for (j; j >= n; j--) tags[j].parentElement.removeChild(tags[j]);            }            i = 0; len = rights[name].length;            for (i; i < len; i++) {                e = createElement('span', { className: 'tag', textContent: rights[name][i] });               $a(hgroup, e);            }        }    });

/***********************    ********** 1 **********     ***********************/    (function {        if (!wgPageName.includes('WikiActivity')) return;        var article = $_('.WikiaArticle'),            options = { childList: true, subtree: true }, e;        function iterate {            var i = 0,            sel = $$('.activity-ns-1201 > table, .activity-ns-2001 > table'),            len = sel.length;            for (i; i < len; i++) {                if (sel[i].classList && sel[i].classList.contains('wallfeed')) continue;                sel[i].classList.add('wallfeed');                log('iteration complete: ' + i, sel[i]);            }        }        function handleMutation(changes) {            var change, node, len, i;            for (change in changes) {                change = changes[change];                if (change.addedNodes.length) {                    i = 0;                    len = change.addedNodes.length; for (i; i < len; i++) { node = change.addedNodes[i]; if (node.classList && node.classList.contains('activityfeed')) iterate; }               }            }        }

e = new MutationObserver(handleMutation); log('iterating...'); iterate; e.observe(article, options); });   /***********************     ********** 2 **********     ***********************/    (function { var headTarget, header, wrapper, $wrapper, toggle; function isHidden(x) { return x.classList.contains('hidden') ? 'show' : 'hide'; }       try { headTarget = $_('.wds-community-header__wiki-buttons.wds-button-group'); $a(headTarget,               createElement('a', { class: 'wds-button wds-is-squished wds-is-secondary', id: 'jsReturn', textContent: '\u2111', style: 'font-size: 20px; font-weight: 400;', href: '/wiki/User:Arashiryuu0/wikia.js', title: 'Return to Personal JS' })           );            setTimeout(function {                headTarget.append( createElement('a', {                        class: 'wds-button wds-is-squished wds-is-secondary',                        id: 'cssReturn',                        textContent: '\u212D',                        style: 'font-size: 20px; font-weight: 400;',                        href: '/wiki/User:Arashiryuu0/wikia.css',                         title: 'Return to Personal CSS'                    }) );           }, 250);            setTimeout(function {                headTarget.append( createElement('a', {                        class: 'wds-button wds-is-squished wds-is-secondary',                         id: 'purgePageButton',                        textContent: '\u262F',                        style: 'font-size: 20px; font-weight: 400;',                        href: '?action=purge',                         title: 'Purge Page'                    }) );           }, 300);            setTimeout(function {                headTarget.append( createElement('a', {                        class: 'wds-button wds-is-squished wds-is-secondary',                         id: 'returnButton',                        textContent: '↩',                        style: 'font-size: 20px; font-weight: 600;',                        href: '/wiki/User:Arashiryuu0',                         title: 'Return to User Page'                    }) );           }, 350);            setTimeout(function {                headTarget.append( createElement('a', {                        class: 'wds-button wds-is-squished wds-is-secondary',                         id: 'randomPageButton',                        textContent: '?',                         style: 'font-size: 20px;',                         'data-tracking': 'Special:Random',                         href: '/wiki/Special:Random',                         title: 'Random Page'                    }) );           }, 450);            if (wgNamespaceNumber !== 0) return; function onClick { var hidden = $wrapper.css('display'), state = { 'inline-block': 'inline-block', 'inline-flex': 'inline-flex', 'initial': 'initial', 'block': 'block', 'flex': 'flex' };               if (state.hasOwnProperty(hidden)) { $wrapper.hide('slow'); wrapper.classList.add('hidden'); this.textContent = isHidden(wrapper); } else { $wrapper.show('slow'); wrapper.classList.remove('hidden'); this.textContent = isHidden(wrapper); }           }            wrapper = $_('.WikiaPageContentWrapper'); $wrapper = $(wrapper); header = $_('.wds-community-header'); toggle = createElement('a', {                id: 'togglePage',                 textContent: isHidden(wrapper),                style: '\                position: relative;\                left: 2px;\                bottom: 1.22vh;\                color: whitesmoke;\                cursor: pointer;'.replace(/\s+/g, ' ').trim,                click: onClick            }); $a(header, toggle); } catch(e) { console.error(e.stack); }   });    /***********************     ********** 3 **********     ***********************/    (function { var date = new Date, currentDay = date.toLocaleDateString(document.documentElement.lang, {               weekday: 'long'            }); var day = createElement('a', {           id: 'currDay',            title: 'Today',            target: '_blank',            textContent: currentDay        }), style = createElement('style', {           id: 'EllipseFixCSS',            type: 'text/css',            textContent: '.WikiaSiteWrapper .wds-community-header .wds-community-header__wiki-buttons > .wds-dropdown > .wds-dropdown__content, .wds-dropdown.wds-is-active::after, .wds-dropdown.wds-is-active::before, .wds-dropdown:hover::after, .wds-dropdown:hover::before { display: none; } .wds-community-header__wiki-buttons > .wds-dropdown > .wds-button:hover { cursor: pointer; }'        }), stylesheet = createElement('style', {           id: 'ToggleCSS',            type: 'text/css',            textContent: '.wds-community-header__local-navigation .wds-dropdown:hover .wds-dropdown__content { display: none; } .wds-community-header__local-navigation .wds-dropdown:hover .wds-dropdown__toggle-chevron { transform: none; transition: transform 200ms cubic-bezier(0.6, -0.28, 0.74, 0.05); }'        }); var toggles = $('.wds-community-header__local-navigation .wds-dropdown .wds-dropdown__toggle-chevron'), headerButton = $('.wds-community-header__wiki-buttons > .wds-dropdown > .wds-button');

$a(document.head, style); $a(document.head, stylesheet); $a($_('.wds-community-header__local-navigation'), day); headerButton.css('padding', '11px 3px'); headerButton.on('click.EllipseFix', function {           var root = this.parentElement, content;            content = root.querySelector('.wds-dropdown__content');            $(content).toggle('fast');        }); toggles.on('click.ToggleClick', function {           var rotation = 'rotateX(180deg)', content,                root = this.parentElement.parentElement;

content = root.querySelector('.wds-dropdown__content'); $(content).toggle('fast');

this.style.transform = this.style.transform !== rotation ? rotation : 'none'; });   });    /***********************     ********** 4 **********     ***********************/    $_('.wds-community-header__wiki-buttons .wds-dropdown').setAttribute('title', 'Options'); setTimeout(window.getStarted, 1000); };

/** * Utility */

function createElement(type, properties) { if (typeof type !== 'string' || typeof properties !== 'object') throw new TypeError('First parameter must be a string. Second parameter must be an object with properties.');

var element = document.createElement(type), prop, name, ev, len, i;   var attributes = [ 'text', 'class' ];   var events = { 'click': 'onclick', 'clicks': 'ondblclick', 'context': 'oncontextmenu', 'keyup': 'onkeyup', 'keydown': 'onkeydown', 'keypress': 'onkeypress', 'mouseup': 'onmouseup', 'mousedown': 'onmousedown', 'mousemove': 'onmousemove', 'mouseover': 'onmouseover', 'mouseout': 'onmouseout', 'mouseenter': 'onmouseenter', 'mouseleave': 'onmouseleave' };   for (prop in properties) { name = typeof properties[prop]; if (attributes.includes(prop)) { if (prop === 'text') { element.textContent = properties[prop]; continue; }           element.setAttribute(prop, properties[prop]); } else if (events.hasOwnProperty(prop) && name === 'function') { ev = events[prop]; element[ev] = properties[prop]; } else if (prop === 'dataset' && name === 'object') { for (i in properties[prop]) { element[prop][i] = properties[prop][i]; }       } else if (prop === 'childNodes' && Array.isArray(properties[prop])) { i = 0; len = properties[prop].length; for (i; i < len; i++) { if (![1, 3].includes(properties[prop][i].nodeType)) continue; $a(element, properties[prop][i]); }       } else { element[prop] = properties[prop]; }   }    element.props = properties; return element; }

function log { var args = Array.prototype.slice.call(arguments); args.unshift('%c[Log]', 'color: #C3E88D;'); return console.log.apply(this, args); }

function $$(selector) { return document.querySelectorAll.call(document, selector); }

function $_(selector) { return document.querySelector.call(document, selector); }

function $a(target, element) { return Node.prototype.appendChild.call(target, element); }

/*@end@*/