User:Arashiryuu0/wikia.js

/** * @namespace Personal_JS */   var has = Object.prototype.hasOwnProperty; importArticle({       type: 'script',        article: 'u:bloodborne:DOMTools.js'    }); importArticles({       type: 'style',        articles: [            'u:dev:MediaWiki:FontAwesome.css',            'u:dev:MediaWiki:ModernWikiActivity.css',            'u:dev:MediaWiki:ModernProfile/Masthead.css',            'u:dev:MediaWiki:ModernProfile/Wall.css',            'u:dev:MediaWiki:ModernCommentsSection.css',            'u:dev:MediaWiki:ModernWikiActivity.css',            'u:dev:MediaWiki:FandomizedRailModules/code.css'        ]    }); function wait { if (!has.call(window, 'DOMTools')) return setTimeout(wait, 1000); pageLoad; }   function pageLoad { /**        * Setup */       importArticle({            type: 'script',            article: 'u:bloodborne:Tooltips.js'        }); window.tagList = { '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 (has.call(rights, 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++) $a( tagContainer, DOMTools.parseHTML(                       ' '                        + rights[name][i] +                        ' '                    ) );           } 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++) $a( tagContainer, DOMTools.parseHTML(                       ' '                        + rights[name][i] +                        ' '                    ) );           }        });        (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].classList) continue;                    if (DOMTools.hasClass(selection[i], 'wallfeed')) continue;                    DOMTools.addClass(selection[i], '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;           if (btn) { DOMTools.addClass(btn, 'button'); btn.children[0].cssText += 'position: relative; bottom: 3px; color: #FFF;'; }           if (!len) return; i = 0; for (i; i < len; i++) DOMTools.removeClass(sec[i], '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 (has.call(tags, 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 = has.call(tagList, text) ? tagList[text] : ''; if (tag && !oTags[i].classList.contains(tag)) DOMTools.addClass(oTags[i], tag); if (!text || !tiptext) continue; tooltip(oTags[i], tiptext, 'top'); }               setTimeout(function {                    var tipcss = $('#TooltipColorCss');                    if (tipcss.length) {                        tipcss.text(tipcss[0].textContent += ' .superTag { cursor: help; }');                    }                }, 250); }           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; $all(headTarget, [               createElement('a', { className: 'wds-button wds-is-squished wds-is-secondary', id: 'jsReturn', childNodes: [ createElement('span', {                           className: 'jsReturn',                            textContent: '\u2111',                        }) ],                   style: 'font-size: 20px; font-weight: 400;', href: '/wiki/User:Arashiryuu0/wikia.js', title: 'Return to Personal JS' }),               createElement('a', { className: 'wds-button wds-is-squished wds-is-secondary', id: 'cssReturn', childNodes: [ createElement('span', {                           className: 'cssReturn',                            textContent: '\u212D',                        }) ],                   style: 'font-size: 20px; font-weight: 400;', href: '/wiki/User:Arashiryuu0/wikia.css', title: 'Return to Personal CSS' }),               createElement('a', { className: 'wds-button wds-is-squished wds-is-secondary', id: 'purgePageButton', childNodes: [ createElement('span', {                           className: 'purgeButton',                            textContent: '\u262F',                        }) ],                   style: 'font-size: 20px; font-weight: 400;', href: '?action=purge', title: 'Purge Page' }),               createElement('a', { className: 'wds-button wds-is-squished wds-is-secondary', childNodes: [ createElement('span', {                           className: 'userReturn',                            textContent: '↩'                        }) ],                   style: 'font-size: 18px; font-weight: 600;', href: '/wiki/User:Arashiryuu0', title: 'Return to User Page' }),               createElement('a', { className: 'wds-button wds-is-squished wds-is-secondary', childNodes: [ createElement('span', {                           className: 'randomPage',                            textContent: '?'                        }) ],                    style: 'font-size: 18px;', dataset: { tracking: 'Special:Random' }, href: '/wiki/Special:Random', title: 'Random Page' })           ]);        });        (function { if (wgNamespaceNumber !== 0) return; var toggle, toggleCss, header = $_('.wds-community-header'), wrapper = $_('.WikiaPageContentWrapper'), $wrapper = $(wrapper); function isHidden(x) { return x.classList.contains('hidden') ? 'show' : 'hide'; }           function onClick { var hidden = getComputedStyle(wrapper).display, state = { initial:'initial', block:'block', flex:'flex', 'inline-block':'inline-block', 'inline-flex':'inline-flex' };               if (has.call(state, hidden)) { $wrapper.fadeOut('slow'); wrapper.classList.add('hidden'); this.textContent = isHidden(wrapper); } else { $wrapper.fadeIn(1800); wrapper.classList.remove('hidden'); this.textContent = isHidden(wrapper); }           }            toggleCss = createElement('style', {                id: 'togglePageCss',                textContent: '#togglePage {'                    + 'position: relative;'                    + 'left: 2px;'                    + 'bottom: 1.2vh;'                    + 'color: whitesmoke;'                    + 'cursor: pointer;'                    + '}'            }); toggle = createElement('a', {                id: 'togglePage',                 textContent: isHidden(wrapper),                click: onClick            }); $every(document.head, toggleCss], [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-dropdown.wds-is-active:not(.wds-no-chevron)::after, .wds-dropdown.wds-is-active:not(.wds-no-chevron)::before, .wds-dropdown:not(.wds-is-touch-device):hover:not(.wds-no-chevron)::after, .wds-dropdown:not(.wds-is-touch-device):hover:not(.wds-no-chevron)::before, .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'); var len, i;           $all(document.head, [script, stylesheet]); function toggleChevron { 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'; }           function toggleEllipse { var root = this.parentElement, content; content = root.querySelector('.wds-dropdown__content'); $(content).toggle('fast'); }           if (headerButton.length) { len = headerButton.length; i = 0; for (i; i < len; i++) { headerButton[i].style.cssText += 'padding: 11px 3px;'; DOMTools.on(headerButton[i], 'click.toggle', toggleEllipse); }           }            if (toggles.length) { len = toggles.length; i = 0; for (i; i < len; i++) DOMTools.on(toggles[i], 'click.toggle', toggleChevron); }       });        /***********************         ********** 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 **********         ***********************/        (function { var ellipse = $_('.wds-community-header__wiki-buttons .wds-dropdown'); if (ellipse) ellipse.setAttribute('title', 'Options'); setTimeout(window.getStarted, 1000); });       /***********************         ********** 7 **********         ***********************/        (function { var profile = $_('#UserProfileMasthead'), element, username, tabs; if (!profile) return; tabs = $_('.tabs-container > ul.tabs'); username = wgTitle.indexOf('Contributions/') !== -1 ? wgTitle.replace('Contributions/', '') : wgTitle; element = createElement('li', {               dataset: { id: 'editcount' },                childNodes: [                    createElement('a', { href: '/wiki/Special:Editcount/' + username, title: 'Special:Editcount/' + username, textContent: 'Editcount' })               ]            });            $a(tabs, element); });   }    wait; });
 * (function {

/*********************** ********* 000 ********* ***********************/ function createElement(type, properties) { var attributes, element, events, prop, evName, name, len, val, ev, ty, pr, i;   type = type || ''; properties = properties || {}; ty = type.constructor.name; pr = properties.constructor.name; if (ty !== 'String' || pr !== 'Object') throw new TypeError('Expected: String, Object. Received: ' + ty + ', ' + pr); element = document.createElement(type); attributes = [ 'text', 'class' ];   events = [ 'click', 'dblclick', 'contextmenu', 'keyup', 'keydown', 'keypress', 'mouseup', 'mousedown', 'mousemove', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave' ];   for (prop in properties) { val = properties[prop] || 0; if (!val) continue; evName = prop.split('.')[0]; name = val.constructor.name; if (attributes.includes(prop)) { if (prop === 'text') { element.textContent = val; continue; }           element.setAttribute(prop, val); } else if (events.includes(evName) && name === 'Function') { DOMTools.on(element, prop, 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] %c%s\n\u2014', 'color: #FFCB6B;', 'color: #F78C6A;', new Date.toUTCString); return console.log.apply(this, args); }

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

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

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

function $all(target, elements) { var len, i;   target = target || 0; if (!target) return; elements = elements || []; if ((target.constructor && !(target.constructor.name.includes('Node') || target.constructor.name.includes('Element'))) || elements.constructor.name !== 'Array') throw new TypeError('First parameter must be a target element. Second parameter must be an array!'); len = elements.length; i = 0; for (i; i < len; i++) $a(target, elements[i]); } function $every(targets) { var targetType, elementType, elements, target, tLen, eLen, i, j;   targets = targets || []; if (!targets) return; targetType = targets.constructor.name; if (targetType !== 'Array') throw new TypeError('Must provide a 2d array.'); tLen = targets.length; i = 0; for (i; i < tLen; i++) { elements = targets[i] || 0; if (!elements) continue; elementType = elements.constructor.name; if (elementType !== 'Array') throw new TypeError('Must provide a 2d array.'); target = elements.shift; eLen = elements.length; j = 0; for (j; j < eLen; j++) $a(target, elements[j]); } }

/*@end@*/