User:Arashiryuu0/wikia.js

window.onload = function { importScriptPage('MediaWiki:Tooltips.js', 'bloodborne'); window.tagList = { '全王':'King of All', '拳王':'King of the Fist', '人殺し合':'Murderer', 'Administrator':'Wiki Administration', 'Bureaucrat':'Wiki Administration', 'Vampiric Overlord':'Girlycard', 'Chat Moderator':'Wiki Chat Moderator', 'Chat moderator':'Wiki Chat Moderator', 'Discussions Moderator':'Wiki Discussions Moderator', 'Content Moderator':'Wiki Content Moderator', 'Staff':'Fandom Staff' };   /***********************     ********** 0 **********     ***********************/    (function {        var profile = $_('.UserProfileMasthead'), t,            rights, hgroup, name, len, el, i;        if (!profile) return;        rights = {            Arashiryuu0: ['全王', '拳王', '人殺し合'],            ShadowBeast109: ['Administrator', 'Vampiric Overlord'],            Matsczon: ['Bureaucrat', 'Duckman'],            Filename: ['Emoji Dab Lad', 'Fallout: Las Vegas'],            IronChaos: ['Lad', 'One of The Boys', 'Ginger', 'TheseHands™']        };        hgroup = $_('.masthead-info hgroup');        name = hgroup.children[0].textContent;        t = $$('.tag');        if (rights.hasOwnProperty(name)) {            i = t.length - 1; len = 0;

for (i; i >= len; i--) t[i].parentElement.removeChild(t[i]); i = 0; len = rights[name].length; for (i; i < len; i++) { el = createElement('span', {                   className: 'tag',                    textContent: rights[name][i]                }); $a(hgroup, el); }       }    });    /***********************     ********** 1 **********     ***********************/    (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'); info('iteration complete: ' + i, selection[i]); }       }        function handleMutation(changes) { var change, node, i, len; for (change in changes) { change = changes[change]; if (!change.addedNodes.length) continue; 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); info('iterating...'); iterate; e.observe(article, options); });   (function { if (!['Thread', 'Message_Wall'].includes(wgPageName.split(':')[0])) return; var fb = $_('li.edit-topic'), se = $$('.wikia-button.secondary, .wikia-menu-button.secondary'), to = $_('.related-topics .related-topic'), ln = se.length, i;

fb.classList.add('button'); fb.children[0].style.cssText = 'position: relative; bottom: 3px; color: white;'; to.style.backgroundColor = '#201C10'; if (!ln) return; i = 0; for (i; i < len; i++) se[i].classList.remove('secondary'); });   /***********************     ********** 2 **********     ***********************/    (function { var profile = $_('.UserProfileMasthead'), oldtags, people, user, tags; if (!profile) return; tags = { '全王':'zen-ou', '拳王':'ken-ou', '人殺し合':'murderer', 'Administrator':'admin', 'Bureaucrat':'crat', 'Duckman':'duck', 'Emoji Dab Lad':'emoji-dab', 'Fallout: Las Vegas':'las-vegas', 'Ginger':'ginger', 'Lad':'lad', 'One of The Boys':'boys', 'TheseHands™':'these-hands', 'Vampiric Overlord':'vamp' };       people = [ 'Arashiryuu0', 'ShadowBeast109', 'Matsczon', 'Filename', 'IronChaos' ];       user = profile.querySelector('hgroup h1'); oldtags = $$('span.tag'); function getWord(text) { if (tags.hasOwnProperty(text)) return tags[text]; return null; }       function loop { var j = 0, len = oldtags.length; for (j; j < len; j++) { var text = oldtags[j].textContent; var word = getWord(text); if (!word || oldtags[j].classList.contains(word)) continue; oldtags[j].classList.add(word); }       }        if (people.includes(user.textContent)) loop; });   /***********************     ********** 3 **********     ***********************/    (function { var headTarget = $_('.wds-community-header__wiki-buttons.wds-button-group'); if (!headTarget) return; try { $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 {                $a(headTarget, 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 {                $a(headTarget, 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 {                $a(headTarget, 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 {                $a(headTarget, createElement('a', {                        class: 'wds-button wds-is-squished wds-is-secondary',                         id: 'randomPageButton',                        textContent: '?',                         style: 'font-size: 20px;',                         dataset: { tracking: 'Special:Random' },                         href: '/wiki/Special:Random',                         title: 'Random Page'                    }) );           }, 450);        } catch(e) { console.error(e); }   });    (function { if (wgNamespaceNumber !== 0) return; var header = $_('.wds-community-header'), wrapper = $_('.WikiaPageContentWrapper'), $wrapper = $(wrapper), toggle; 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 date = new Date, toggles = $('.wds-community-header__local-navigation .wds-dropdown .wds-dropdown__toggle-chevron'), currentDay = date.toLocaleDateString(document.documentElement.lang, { weekday: 'long' }), headerButton = $('.wds-community-header__wiki-buttons > .wds-dropdown > .wds-button'); var day = createElement('a', {           id: 'currDay',            title: 'Today',            target: '_blank',            textContent: currentDay        }); 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; }'        }); var 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); }'        }); $a(document.head, script); $a(document.head, stylesheet); 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';        }); headerButton.on('click.EllipseFix', function {           var root = this.parentElement, content;            content = root.querySelector('.wds-dropdown__content');            $(content).toggle('fast');        }).css({            padding: '11px 3px'        }); $a($_('.wds-community-header__local-navigation'), day); $_('.wds-community-header__wiki-buttons .wds-dropdown').setAttribute('title', 'Options'); setTimeout(window.getStarted, 1000); }); };

/** * Utility */

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 info { var args = Array.prototype.slice.call(arguments); args.unshift('%c[Info]', '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@*/