User:Arashiryuu0/wikia.js

/** * @namespace Personal_JS */   var has = Object.prototype.hasOwnProperty; importArticles({       type: 'script',        articles: [            'u:bloodborne:DOMTools.js',            'u:bloodborne:JSHighlightFixes.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 */       importArticles({            type: 'script',            articles: [                'u:bloodborne:MediaWiki:Tooltips.js',                'u:dev:WikiaNotification/code.js',                'u:dev:SearchSuggest/code.js',                'u:dev:HeaderLinks/code.js'            ]        }); window.tagList = { 'Elkian': '16th Ranked Exceed', 'Old Deus': 'Wiki Administration', 'Staff': 'Fandom Staff', 'Tet': 'The One True God', '『　』': 'Blank' };       /**         * Editcount */       (function {            var profile = $_('.UserProfileMasthead'),                username, element, tabs;            if (!profile) return;            username = wgTitle.indexOf('Contributions/') !== -1                ? wgTitle.replace('Contributions/', '') : wgTitle;            element = createElement('li', { dataset: { id: 'editcount' }, childNodes: [ createElement('a', {                       text: 'Editcount',                        href: '/wiki/Special:Editcount/' + username,                        title: 'Special:Editcount/' + username                    }) ]           });            tabs = $_('.tabs-container > ul.tabs');            $a(tabs, element);        }); /***********************        ********** 0 **********         ***********************/        (function {            var profile = $_('.UserProfileMasthead'),                hgroup, rights, tags, name, len, e, i;            if (!profile) return;            rights = {                'Arashiryuu0': ['Elkian', '『　』'],                'Robyn Grayson': ['Old Deus']            };            hgroup = profile.querySelector('.masthead-info hgroup');            name = DOMTools.getProp(hgroup, 'children.0.textContent');            if (!has.call(rights, name)) return;            tags = $$('.masthead-info .tag');            if (tags.length) {                for (i = tags.length - 1, len = 0; i >= len; i--) remove(tags[i]);            }            for (i = 0, len = rights[name].length; i < len; i++) {                e = DOMTools.parseHTML( ' '                    + 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 sel = $$('.activity-ns-1201 > table, .activity-ns-2001 > table'),                    len,                    cur,                    i;                for (i = 0, len = sel.length; i < len; i++) {                    cur = sel[i];                    if (!cur.classList) continue;                    if (DOMTools.hasClass(cur, 'wallfeed')) continue;                    DOMTools.addClass(cur, 'wallfeed');                    log('iteration complete: ' + i, cur);                }            }            function handleMutation(changes) {                var change, node, len, i;                for (change in changes) { change = changes[change]; if (change.addedNodes.length) { for (i = 0, len = change.addedNodes.length; i < len; i++) { node = change.addedNodes[i]; if (!node.classList) continue; DOMTools.hasClass(node, 'activityfeed') && iterate; }                   }                }            }            e = new MutationObserver(handleMutation); log('iterating...'); iterate; e.observe(article, options); });       /***********************         ********** 2 **********         ***********************/        (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, header = $_('.wds-community-header'), wrapper = $_('.WikiaPageContentWrapper'), $wrapper = $(wrapper); function isHidden(x) { return DOMTools.hasClass(x, 'hidden') ? 'show' : 'hide'; }           function onClick { var hidden = DOMTools.css(wrapper, 'display'), state = [ 'inline-block', 'inline-flex', 'initial', 'block', 'flex' ];               if (state.includes(hidden)) { $wrapper.hide('slow'); DOMTools.addClass(wrapper, 'hidden'); return (DOMTools.text(this, isHidden(wrapper)), void 0); }               $wrapper.show('slow'); DOMTools.removeClass(wrapper, 'hidden'); DOMTools.text(this, isHidden(wrapper)); }           toggle = createElement('a', {                 id: 'togglePage',                 textContent: isHidden(wrapper),                style: {                    position: 'relative',                    left: '2px',                    bottom: '2.2vh',                    color: 'whitesmoke',                    cursor: 'pointer',                    textTransform: 'uppercase'                },                'click.toggle-page': onClick            }); $a(header, toggle); });       /***********************         ********** 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-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):not(.wds-is-not-hoverable):hover:not(.wds-no-chevron)::after, .wds-dropdown:not(.wds-is-touch-device):not(.wds-is-not-hoverable):hover:not(.wds-no-chevron)::before, .wds-community-header__local-navigation .wds-dropdown.wds-is-active .wds-dropdown__content, .wds-community-header__local-navigation .wds-dropdown:not(.wds-is-touch-device):not(.wds-is-not-hoverable):hover .wds-dropdown__content, .wds-community-header__local-navigation .wds-dropdown:hover::after { 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); } .wds-community-header__local-navigation .wds-dropdown:hover .wds-dropdown__toggle { transform: none; }' });           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, [style, stylesheet]);            function toggleEllipse {                var root = this.parentElement, content;                content = root.querySelector('.wds-dropdown__content');                $(content).toggle('fast');            }            function toggleChevron {                var rotation = 'rotateX(180deg)',                    root = this.parentElement.parentElement,                    transform, content;                content = root.querySelector('.wds-dropdown__content');                $(content).toggle('fast');                transform = DOMTools.css(this, 'transform'); DOMTools.css(this, 'transform', transform !== rotation ? rotation : 'none'); }           $a($_('.wds-community-header__local-navigation'), day); if (headerButton.length) { for (i = 0, len = headerButton.length; i < len; i++) { DOMTools.css(headerButton[i], 'padding', '11px 3px'); DOMTools.on(headerButton[i], 'click.toggle', toggleEllipse); }           }            if (!toggles.length) return; for (i = 0, len = toggles.length; i < len; i++) DOMTools.on(toggles[i], 'click.toggle', toggleChevron); });       /***********************         ********** 4 **********         ***********************/        (function { var ellipse = $_('.wds-community-header__wiki-buttons .wds-dropdown'); if (ellipse) ellipse.setAttribute('title', 'Options'); });   }    wait; });
 * (function {

/** * Utility */ function createElement(type, properties) { var attributes, element, events, prop, style, styleProp, name, enam, 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; name = val.constructor.name; enam = prop.split('.')[0]; if (prop === 'style') { styleProp = Object.keys(val); for (i = 0, len = styleProp.length; i < len; i++) { style = styleProp[i]; if (!val[style]) continue; element.style[style] = val[style]; }       } else if (attributes.includes(prop)) { if (prop === 'text') { element.textContent = val; continue; }           element.setAttribute(prop, val); } else if (events.includes(enam) && 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 remove(child) { if (!child) return; return child.parentElement.removeChild(child); }

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

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

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

function $a(target, element) { if (!target) return; element = element || document.createDocumentFragment; 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@*/