User:Arashiryuu0/wikia.js

/** * @namespace Personal_JS */   var has = Object.prototype.hasOwnProperty, config = mw.config.get([           'wgPageName',            'wgNamespaceNumber'        ]); window.tagList = { 'Klaxosaur Blood': '００２｜아이고' };   importArticles({        type: 'script',        articles: [            'u:dev:GlobalEditcount/code.js',            'u:bloodborne:ColorConverter.js',            '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'        }); /***********************        ********** 0 **********         ***********************/        ;(function {            var tagContainer, oldTags, name,                profile = $_('.UserProfileMasthead'),                rights, hgroup, html, 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');                len = 0;                for (i = oldTags.length - 1; i >= len; i--) {                    oldTags[i].parentElement.removeChild(oldTags[i]);                }                $a(hgroup, tagContainer);                len = rights[name].length;                for (i = 0; i < len; i++) $a( tagContainer, DOMTools.parseHTML(                       ''                        + rights[name][i] +                        ' '                    ) );           } else {                oldTags = $$('.tag');                tagContainer = createElement('h2', { id: 'TagContainer', className: 'tags' });               len = 0;                for (i = oldTags.length - 1; i >= len; i--) {                    oldTags[i].parentElement.removeChild(oldTags[i]);                }                $a(hgroup, tagContainer);                len = oldTags.length;                for (i = 0; i < len; i++) {                    html = createElement('span', { 'class': 'tag super', 'text': oldTags[i].textContent });                   $a(tagContainer, html);                }            }        }); ;(function {           if (!config.wgPageName.includes('WikiActivity')) return;            var article = $_('.WikiaArticle'),                options = { childList: true, subtree: true };            function iterate {                var i,                    sel = $$('.activity-ns-1201 > table, .activity-ns-2001 > table'),                    len = sel.length;                function handleClass(element, index) {                    if (element.nodeType !== 1) return;                    if (DOMTools.hasClass(element, 'wallfeed')) return;                    DOMTools.addClass(element, 'wallfeed');                    info('iteration complete: ' + i, element);                }                for (i = 0; i < len; i++) handleClass(sel[i], i);            }            function filterUpper(upper) {                var i, len;                if (!upper.addedNodes) return;                len = upper.addedNodes.length; for (i = 0; i < len; i++) filterNode(upper.addedNodes[i]); }           function filterNode(node) { if (node.nodeType !== 1) return; if (!DOMTools.hasClass(node, 'activityfeed')) return; iterate; }           function processMutation(change) { filterUpper(change); }           function handleMutation(changes) { for (var change in changes) processMutation(changes[change]); }           var e = new MutationObserver(handleMutation); info('iterating...'); iterate; e.observe(article, options); });       /***********************         ********** 1 **********         ***********************/        ;(function { var pageType = config.wgPageName.split(':')[0]; if (!['Thread', 'Message_Wall'].includes(pageType)) return; var e = { edit_topic: $_('li.edit-topic'), related_topic: $_('.related-topics .related-topic'), seconds: $$('.wikia-button.secondary, .wikia-menu-button.secondary'), getButton: function { return DOMTools.getProp(e, 'edit_topic.children.0'); }           }, css = [ 'position: relative;', 'bottom: 3px', 'color: white;' ], l = e.seconds.length, i;           for (i = 0; i < l; i++) DOMTools.removeClass(e.seconds[i], 'secondary'); if (e.edit_topic) { DOMTools.addClass(e.edit_topic, 'button'); DOMTools.css(e.getButton, 'cssText', css.join(' ')); }           if (e.related_topic) DOMTools.css(                e.related_topic,                'background-color',                '#201C10'            ); });       /***********************         ********** 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 .tag'); function getTag(text) { if (has.call(tags, text)) return tags[text]; return null; }           function run { var tiptext, text, len = oTags.length, tag, i;               for (i = 0; i < len; i++) { text = oTags[i].textContent; tag = getTag(text); if (!tag || oTags[i].dataset.id) continue; oTags[i].dataset.id = tag; }               setTimeout(function {                    var tipcss = $('#TooltipColorCss');                    if (tipcss.length) {                        tipcss.text( tipcss[0].textContent +                           ' .tag.super { 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 selectors = [ '.wds-community-header__wiki-buttons', '.wds-button-group' ];           var headTarget = DOMTools.query(selectors.join(''), document); if (!headTarget) return; DOMTools.appendAll(headTarget, [               createElement('a', { className: 'wds-button wds-is-squished wds-is-secondary', id: 'jsReturn', childNodes: [ createElement('span', {                           className: 'jsReturn',                            textContent: '\u2111',                        }) ],                   style: { fontSize: '20px', fontWeight: 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: { fontSize: '20px', fontWeight: 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: { fontSize: '20px', fontWeight: 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: { fontSize: '18px', fontWeight: 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: { fontSize: '18px' },                    dataset: { tracking: 'Special:Random' }, href: '/wiki/Special:Random', title: 'Random Page' })           ]);        });        ;(function { if (config.wgNamespaceNumber !== 0) return; var element = { target: $_('.wds-community-header'), wrapper: $_('.WikiaPageContentWrapper'), $wrapper: $('.WikiaPageContentWrapper'), toggle: function(t) { element.$wrapper.toggle(200); DOMTools.toggleClass(element.wrapper, 'hidden'); DOMTools.text(t, this.getText); },               getText: function { return DOMTools.hasClass(element.wrapper, 'hidden') ? 'show' : 'hide'; }           };            function onClick { element.toggle(this); }           var toggle = createElement('a', {                 id: 'toggle-page',                 textContent: element.getText,                style: {                    position: 'relative',                    left: '2px',                    bottom: '1.2vh',                    color: 'whitesmoke',                    cursor: 'pointer',                    textTransform: 'uppercase'                },                'click.toggle-page': onClick            }); $a(element.target, toggle); });       /***********************         ********** 4 **********         ***********************/        ;(function { var lang = document.documentElement.lang; var date = { obj: new Date, target: $_('.wds-community-header__local-navigation'), };           Object.defineProperty(date, 'current_day', {                writable: false,                configurable: false,                value: date.obj.toLocaleDateString(lang, { weekday: 'long' })            }); Object.defineProperty(date, 'day', {               configurable: false,                value: createElement('a', { id: 'current-day', title: 'Today', target: '_blank', textContent: date.current_day })           });            var css = { ellipse: { id: 'EllipseFixCSS', type: 'text/css', selectors: [ [                           '.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' ],                       [                            '.wds-community-header__wiki-buttons', '>',                           '.wds-dropdown', '>',                           '.wds-button:hover' ]                   ]                },                toggle: { id: 'ToggleCSS', type: 'text/css', selectors: [ [                           '.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.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' ],                       [                            '.wds-community-header__local-navigation', '.wds-dropdown:hover', '.wds-dropdown__toggle-chevron' ],                       [                            '.wds-community-header__local-navigation', '.wds-dropdown:hover', '.wds-dropdown__toggle' ]                   ]                },                target: document.head };           Object.defineProperty(css.ellipse, 'rules', {                configurable: false,                value: [                    css.ellipse.selectors[0].join(' ') + ' { display: none; }',                    css.ellipse.selectors[1].join(' ') + ' { cursor: pointer; }'                ]            }); Object.defineProperty(css.ellipse, 'stylesheet', {               configurable: false,                value: createElement('style', { id: css.ellipse.id, type: css.ellipse.type, textContent: css.ellipse.rules.join('\n') })           });            Object.defineProperty(css.toggle, 'rules', {                configurable: false,                value: [                    css.toggle.selectors[0].join(' ') + ' { display: none; }',                    css.toggle.selectors[1].join(' ') + ' { transform: none; '                    + 'transition: transform 200ms '                    + 'cubic-bezier(0.6, -0.28, 0.74, 0.05); }',                    css.toggle.selectors[2].join(' ') + ' { transform: none; }'                ]            }); Object.defineProperty(css.toggle, 'stylesheet', {               configurable: false,                value: createElement('style', { id: css.toggle.id, type: css.toggle.type, textContent: css.toggle.rules.join('\n') })           });            var selectors = { toggles: [ '.wds-community-header__local-navigation', '.wds-dropdown', '.wds-dropdown__toggle-chevron' ],               headerButton: [ '.wds-community-header__wiki-buttons', '>',                   '.wds-dropdown', '>',                   '.wds-button' ]           };            var toggles = $$(selectors.toggles.join(' ')), headerButton = $_(selectors.headerButton.join(' ')); function ellipse { var root = this.parentElement, content; content = root.querySelector('.wds-dropdown__content'); $(content).toggle('fast'); }           function chevron { var rotation = 'rotateX(180deg)', root = this.parentElement.parentElement; var content = root.querySelector('.wds-dropdown__content'); $(content).toggle('fast'); var transform = this.style.transform; var text = transform !== rotation ? rotation : 'none'; DOMTools.css(this, 'transform', text); }           DOMTools.appendAll(css.target, [css.ellipse.stylesheet, css.toggle.stylesheet]); $a(date.target, date.day); if (headerButton) { headerButton.setAttribute('title', 'Options'); headerButton.style.cssText += 'padding: 11px 3px;'; DOMTools.on(headerButton, 'click.toggle', ellipse); }           var len = toggles.length, i;            for (i = 0; i < len; i++) DOMTools.on(toggles[i], 'click.toggle', chevron); });       /***********************         ********** 5 **********         ***********************/        ;(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); });       ;(function { var fixDimensions, avatars, len, i;           if (!DOMTools.query('.WallHistory', document)) return; fixDimensions = function(avatar) { var src = avatar.getAttribute('src'); avatar.setAttribute('height', '50'); avatar.setAttribute('width', '50'); if (src.endsWith('20')) avatar.setAttribute('src', src.slice(0, -2) + '50'); };           avatars = DOMTools.queryAll('.WallHistory #WallThreadHistory .avatar', document); len = avatars.length; for (i = 0; i < len; i++) fixDimensions(avatars[i]); });       /***********************         ********** 6 **********         ***********************/        ;(function { var base = DOMTools.query('#UserProfileMasthead'), user, url; if (!base) return; user = DOMTools.text(DOMTools.query('hgroup h1', base)); url = mw.util.wikiScript('api'); url += '?action=query&list=users&usprop=registration'; url += '&ususers=' + user + '&format=json'; function getData { function cb(resolve, reject) { var xhr = new XMLHttpRequest; function load { resolve(JSON.parse(xhr.responseText)); }                   function error(e) { reject(e, xhr); }                   xhr.addEventListener('load', load); xhr.addEventListener('error', error); xhr.open('GET', url, true); xhr.send; }               return new Promise(cb); }           function appendToGlobalCount(data) { var d = DOMTools.getProp(data, 'query.users.0.registration'), date = new Date(d).toLocaleDateString('en-us', {                       day: '2-digit',                        month: 'long',                        year: 'numeric'                    }), target = DOMTools.query('.globaledit-label', base), clone; if (!target) return Promise.reject(new Error('Couldn\'t find label.')); clone = target.cloneNode(true); DOMTools.text(clone, 'global edits since account creation'); DOMTools.appendAll(clone, [                   document.createElement('br'),                    document.createTextNode(date)                ]); target.replaceWith(clone); return Promise.resolve(clone); }           function removeLinkedCSS { var links = DOMTools.queryAll('link[type="text/css"][rel="stylesheet"]'), link; function filterLinks(linkElement) { return linkElement.href && linkElement.href.includes('GlobalEditcount'); }               link = links.find(filterLinks); try { link.parentElement.removeChild(link); return Promise.resolve(true); } catch(e) { return Promise.reject(e); }           }            getData .then(appendToGlobalCount, console.error) .then(removeLinkedCSS, console.error); });   }    addOnloadHook(wait); });
 * (function {

/*********************** ********* 000 ********* ***********************/ function isNil(anything) { return typeof anything === 'undefined' || anything === null; } function createElement(type, properties) { var nodeTypes = [1, 3], element; if (typeof type !== 'string') return; if (typeof properties !== 'object') return; if (properties.constructor.name !== 'Object') return; function addStyle(element, _, styles) { var keys = Object.keys(styles), len = keys.length, style, i;       for (i = 0; i < len; i++) { style = keys[i]; DOMTools.css(element, style, styles[style]); }       return element; }   function setText(element, _, value) { element.textContent = value; return element; }   function addAttribute(element, attribute, value) { if (attribute === 'text') return setText(element, value); element.setAttribute(attribute, value); return element; }   function addEvent(element, event, callback) { DOMTools.on(element, event, callback); return element; }   function addData(element, _, data) { for (var i in data) element[_][i] = data[i]; return element; }   function addChildren(element, _, children) { for (var i = 0, len = children.length; i < len; i++) { if (!nodeTypes.includes(children[i].nodeType)) continue; $a(element, children[i]); }       return element; }   function processProps(element, props) { var keys = Object.keys(props), len = keys.length, prop, name, val, ns, i;       var actions = { 'text': setText, 'style': addStyle, 'class': addAttribute, 'dataset': addData, 'childNodes': addChildren };       for (i = 0; i < len; i++) { prop = keys[i]; val = props[prop]; if (isNil(val)) continue; name = prop.split('.')[0]; ns = prop.split('.')[1]; if (!isNil(actions[name])) { actions[name](element, prop, val); continue; } else if (!isNil(ns)) { addEvent(element, prop, val); continue; }           element[prop] = val; }       Object.defineProperty(element, 'props', {            value: props,            configurable: false        }); return element; }   element = document.createElement(type); return processProps(element, properties); }

function log { var args = Array.prototype.slice.call(arguments), time = new Date.toUTCString; args.unshift('%c[LOG] %c%s\n\u2014', 'color: #FFCB6B;', 'color: #F78C6A;', time); 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); }

/*@end@*/