User:Arashiryuu0/global.js

/** * Global code - affects all wikias/fandoms I use. * @namespace Global.js */ var has = Object.prototype.hasOwnProperty, slice = Array.prototype.slice, config = mw.config.get([           'wgIsEditPage'        ]); importArticles({       type: 'script',        articles: [            'u:bloodborne:MediaWiki:JSHighlightFixes.js',            'u:dev:RelatedDiscussionsModule/code.js',            'u:bloodborne:MediaWiki:DOMTools.js',            'u:dev:CodeblockLineNumbers/code.js',            'u:dev:DifferentSkinEditor/code.js',            'u:dev:YoutubeModal/code.js',            'u:dev:PurgeButton/code.js',            'u:dev:View_Source/code.js',            'u:dev:UTCClock/code.js',            'u:dev:Message/code.js',            'u:dev:AjaxRC/code.js'        ]    }); function wait { if (!has.call(window, 'DOMTools')) return setTimeout(wait, 1000); run; }   function run  { /**        * Purge Button */       window.PurgeButtonText = 'Purge'; /**        * Auto Refresh */       window.AjaxRCRefreshText = 'Auto-refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page'; window.ajaxPages = [ 'Special:RecentChanges', 'Special:WikiActivity', 'Special:AllPages', 'Special:UncategorizedPages' ];       /**         * Remove featured videos */       ;(function  {            var items;            function hasChild (target) {                return has.call(target.attributes, 'itemprop');            }            function removeChild (child) {                return child.parentElement.removeChild(child);            }            function removeChildren (children) {                children.forEach(removeChild);            }            function filterChildren (children) {                return children.filter(hasChild);            }            function handleChildren (children) {                removeChildren(filterChildren(children));            }            function mapVideos (video) {                return slice.call(video.parentElement.children);            }            items = DOMTools.queryAll('div[itemprop="video"]').map(mapVideos);            items.forEach(handleChildren);        }); /**        * LineNumbers on Codeblocks * Moved to: https://dev.wikia.com/wiki/CodeblockLineNumbers */       /**         * Cancel button for edit pages. */       ;(function  {            var button, head, url;            if (!config.wgIsEditPage || window.CancelEditLoaded) return;            head = document.querySelector('#EditPageHeader h2');            if (!head) return;            window.CancelEditLoaded = true;            url = window.location.href.slice(0, -('?action=edit'.length));            button = DOMTools.parseHTML([ '', 'Cancel', '' ].join('').trim);           head.appendChild(button);            mw.util.addCSS('#cancel-button { margin-top: -2px; }');        }); /**        * Copy Code button */       ;(function  {            var init, preload;            importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' });           init = function (i18n) {                var s = [                        'div[class*="source-"]',                        '#theme-solarized-light',                        '#theme-solarized-dark'                    ],                    targets = DOMTools.queryAll(s.join(', ')),                    addButton;                addButton = function (codeblock) {                    var button;                    if (DOMTools.hasClass(codeblock, 'de1')) return;                    button = document.createElement('button');                    button.setAttribute('id', 'CopyCodeButton');                    DOMTools.text(button, i18n.msg('copy').plain);                    DOMTools.on(button, 'click.CopyButton', function (e) { var range = document.createRange, selection, error; window.getSelection.removeAllRanges; range.selectNode(codeblock); codeblock.focus; selection = window.getSelection; selection.addRange(range); try { document.execCommand('copy'); } catch (err) { error = new BannerNotification(                               i18n.msg('error').plain,                                'error',                                null,                                5000                            ); error.show; console.error(err); }                       selection.removeAllRanges; });                   codeblock.prepend(button);                };                targets.forEach(addButton);            };            preload = function (i18n) {                i18n.loadMessages('CopyCodeButton').then(init);            };            mw.hook('dev.i18n').add(preload);        }); }   addOnloadHook(wait); });
 * (function {

/** * Cookies */ function getCookies { if (!window.cookies) { Object.defineProperty(window, 'cookies', {           get: function  {                return document.cookie.split(';').reduce(function (cookies, cookie) { cookies[cookie.split('=')[0].trim] = unescape(cookie.split('=')[1]); return cookies; }, {});           }        });        return window.cookies; }   return window.cookies; }

/*@end@*/