User:Arashiryuu0/global.js

/** * Global code - affects all wikias/fandoms I use. * @namespace Global.js */ var has = Object.prototype.hasOwnProperty; 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 filter = Array.prototype.filter;            function hasChild(target) {                return has.call(target.attributes, 'itemprop');            }            var videos = document.querySelectorAll('div[itemprop="video"]'),                children, len = videos.length, i;            if (!len) return;            i = 0;            for (i; i < len; i++) {                children = filter.call(videos[i].parentElement.children, hasChild);                if (children.length) children[i].parentElement.removeChild(children[i]);            }        }); /**        * LineNumbers on Codeblocks * Moved to: https://dev.wikia.com/wiki/CodeblockLineNumbers */   }    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; }

/** * Utility */ function createElement(type, properties) { var attributes, element, events, prop, 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': '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) continue; name = val.constructor.name; 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 $$(selector) { return document.querySelectorAll(selector); }

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

/*@end@*/