User:Arashiryuu0/wikia.js

window.onload = function { importScriptPage('MediaWiki:Tooltips.js', 'bloodborne'); window.tagList = { 'Founder':'Wiki Creator', 'Bureaucrat':'Wiki Administration', 'Administrator':'Wiki Administration', 'Chat Moderator':'Wiki Chat Moderator', 'Chat moderator':'Wiki Chat Moderator', 'Content Moderator':'Wiki Content Moderator', 'Discussions Moderator':'Wiki Discussions Moderator', 'Staff':'Fandom Staff', 'Klaxosaur Blood':'００２｜아이고' };   /***********************     ********** 0 **********     ***********************/    (function {        var tagContainer, oldTags, name,            profile = $_('.UserProfileMasthead'),            rights, hgroup, len, el, i;        if (!profile) return;        rights = {            'Arashiryuu0': ['Klaxosaur Blood'],            'Mai Is Me': ['Founder', 'Bureaucrat']        };        hgroup = $_('.masthead-info hgroup');        name = hgroup.children[0].textContent;        if (rights.hasOwnProperty(name)) {            tagContainer = createElement('h2', { id: 'tagContainer', className: 'tags' });           oldTags = $$('.tag');            i = oldTags.length - 1; len = 0;            for (i; i >= len; i--) oldTags[i].parentElement.removeChild(oldTags[i]);            $a(hgroup, tagContainer);            i = 0; len = rights[name].length;            for (i; i < len; i++) {                el = createElement('span', { className: 'superTag', textContent: rights[name][i] });               $a(tagContainer, el);            }        } else {            oldTags = $$('.tag');            tagContainer = createElement('h2', { id: 'tagContainer', className: 'tags' });           i = oldTags.length - 1; len = 0;            for (j; j >= l; j--) oldTags[j].parentElement.removeChild(oldTags[j]);            $a(hgroup, tagContainer);            name = hgroup.children[0].textContent;            i = 0; len = rights[name].length;            for (i; i < len; i++) {                el = createElement('span', { className: 'superTag', textContent: rights[name][i] });               $a(tagContainer, el);            }        }    }); (function {       if (!wgPageName.includes('WikiActivity')) return;        var article = $_('.WikiaArticle'), e,            options = { childList: true, subtree: true };        function iterate {            var i = 0,            selection = $$('.activity-ns-1201 > table, .activity-ns-2001 > table'),            len = selection.length;            for (i; i < len; i++) {                if ($(selection[i]).hasClass('wallfeed')) continue;                $(selection[i]).addClass('wallfeed');                log('iteration complete: ' + i, selection[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); });   /***********************     ********** 1 **********     ***********************/    (function { if (!['Thread', 'Message_Wall'].includes(wgPageName.split(':')[0])) return; var btn = $_('li.edit-topic'), sec = $$('.wikia-button-secondary, .wikia-menu-button.secondary'), len = sec.length, i;       btn.classList.add('button'); btn.children[0].cssText += 'position: relative; bottom: 3px; color: #FFF;'; if (!len) return; i = 0; for (i; i < len; i++) sec[i].classList.remove('secondary'); });

/***********************    ********** 2 **********     ***********************/    (function {        var profile = $_('.UserProfileMasthead'),            people, oTags, tags;        if (!profile) return;        tags = {            'Klaxosaur Blood':'klb',            'Administrator':'admin',            'Bureaucrat':'crat',            'Founder':'founder'        };        people = [            'Arashiryuu0',            'Mai Is Me'        ];        oTags = $$('.masthead-info .tags span');        function getTag(text) {            if (tags.hasOwnProperty(text)) return tags[text];            return null;        }        function run {            var tagList = window.tagList ? window.tagList : {},                tiptext, text, len = oTags.length,                tag, i = 0;            for (i; i < len; i++) {                text = oTags[i].textContent;                tag = getTag(text); tiptext = tagList.hasOwnProperty(text) ? tagList[text] : ''; if (tag && !oTags[i].classList.contains(tag)) { oTags[i].classList.add(tag); }               if (!text || !tiptext) continue; tooltip(oTags[i], tiptext, 'top'); }           setTimeout(function {                var tipcss = $('#tooltipCSS');                if (tipcss.length) {                    tipcss.text(tipcss[0].textContent += ' .superTag:hover { cursor: help; }');                }            }, 100); }       function cycle { var state = document.readyState; if (state !== 'complete') { return setTimeout(function {                   cycle;                }, 500); }           setTimeout(function {                run;            }, 1000); }       cycle; });   /***********************     ********** 3 **********     ***********************/    (function { var headTarget = $_('.wds-community-header__wiki-buttons.wds-button-group'); if (!headTarget) return; $a(headTarget,           createElement('a', { class: 'wds-button wds-is-squished wds-is-secondary', id: 'jsReturn', text: '\u2111', style: 'font-size: 20px; font-weight: 400;', href: '/wiki/User:Arashiryuu0/wikia.js', title: 'Return to Personal JS' })       );        setTimeout(function {            $a(headTarget, createElement('a', {                    class: 'wds-button wds-is-squished wds-is-secondary',                    id: 'cssReturn',                    text: '\u212D',                    style: 'font-size: 20px; font-weight: 400;',                    href: '/wiki/User:Arashiryuu0/wikia.css',                     title: 'Return to Personal CSS'                }) );       }, 250);        setTimeout(function {            $a(headTarget, createElement('a', {                    class: 'wds-button wds-is-squished wds-is-secondary',                     id: 'purgePageButton',                    text: '\u262F',                    style: 'font-size: 20px; font-weight: 400;',                    href: '?action=purge',                     title: 'Purge Page'                }) );       }, 300);        setTimeout(function {            $a(headTarget, createElement('a', {                    class: 'wds-button wds-is-squished wds-is-secondary',                     id: 'returnButton',                    text: '↩',                    style: 'font-size: 20px; font-weight: 600;',                    href: '/wiki/User:Arashiryuu0',                     title: 'Return to User Page'                }) );       }, 350);        setTimeout(function {            $a(headTarget, createElement('a', {                    class: 'wds-button wds-is-squished wds-is-secondary',                     id: 'randomPageButton',                    text: '?',                     style: 'font-size: 20px;',                     dataset: { tracking: 'Special:Random' },                     href: '/wiki/Special:Random',                     title: 'Random Page'                }) );       }, 450);    });    (function { if (wgNamespaceNumber !== 0) return; var header = $_('.wds-community-header'), wrapper = $_('.WikiaPageContentWrapper'), $wrapper = $(wrapper); function isHidden(x) { return x.classList.contains('hidden') ? 'show' : 'hide'; }       function onClick { var hidden = $wrapper.css('display'), state = { initial:'initial', block:'block', flex:'flex', 'inline-block':'inline-block', 'inline-flex':'inline-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); }       }        toggle = createElement('a', {             id: 'togglePage',             textContent: isHidden(wrapper),             style: '\            position: relative;\            left: 2px;\            bottom: 1.2vh;\            color: whitesmoke;\            cursor: pointer;'.replace(/\s+/g, ' ').trim,            click: onClick        }); $a(header, toggle); });   /***********************     ********** 4 **********     ***********************/    (function { var script = 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, script); $a(document.head, stylesheet); 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';        }); });   /***********************     ********** 5 **********     ***********************/    (function { var date = new Date, currentDay = date.toLocaleDateString(document.documentElement.lang, {               weekday: 'long'            }), day = createElement('a', {               id: 'currDay',                title: 'Today',                target: '_blank',                textContent: currentDay            });

$a($_('.wds-community-header__local-navigation'), day); });   /***********************     ********** 6 **********     ***********************/    $_('.wds-community-header__wiki-buttons .wds-dropdown').setAttribute('title', 'Options');    /***********************     ********** 7 **********     ***********************/ };

/*********************** ********* 000 ********* ***********************/ function createElement(type, properties) { var attributes, element, events, prop, name, len, val, ev, ty, pr, i;   ty = type ? type.constructor.name : null; pr = properties ? properties.constructor.name : null; if (!ty || !pr) return; if (ty !== 'String' || pr !== 'Object') throw new TypeError('Expected: String, Object. Received: ' + ty + ', ' + pr); element = document.createElement(type); attributes = [ 'text', 'class' ];   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) { val = properties[prop]; if (val && typeof val !== 'undefined') name = val.constructor.name; else continue; if (attributes.includes(prop)) { if (prop === 'text') { element.textContent = val; continue; }           element.setAttribute(prop, val); } else if (events.hasOwnProperty(prop) && name === 'Function') { ev = events[prop]; element[ev] = val; } else if (prop === 'dataset' && name === 'Object') { for (i in val) { element[prop][i] = val[i]; }       } else if (prop === 'childNodes' && name === 'Array') { i = 0; len = val.length; for (i; i < len; i++) { if (![1, 3].includes(val[i].nodeType)) continue; $a(element, val[i]); }       } else { element[prop] = val; }   }    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.querySelector.call(document, selector); }

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

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

/*@end@*/