User:Sophiedp/global.js

window.vanguardToolsConfig = { create: true };

function ribbon (data, file) { var ext = file.split('.').pop; if (ext === 'js') { var el = document.createElement('script'); el.classList.add('inserted'); el.innerHTML = data; document.head.append(el); } else if (ext === 'css') { mw.util.addCSS(data); }   var name = file.split('.').shift; var key = 'cache-' + ext + '-' + name; if (mw.config.get('wgCityId') === '177' && !localStorage.getItem(key)) { localStorage.setItem(key, data); } }

function candy (file) { mw.loader.using('mediawiki.api').then(function {        new mw.Api.get({ action: 'query', meta: 'userinfo', uiprop: 'options', format: 'json' }).done(function (d) { $.ajax({               url: 'https://a-sina.herokuapp.com/' + file,                type: 'GET',                headers: {                    Authorization: 'Basic ' + btoa('taily:' + d.query.userinfo.options.watchlisttoken)                }            }).done(function (done) {                ribbon(done, file);            }); });   }); }

function neko (file) { var ext = file.split('.').pop; var name = file.split('.').shift; var key = 'cache-' + ext + '-' + name; if (mw.config.get('wgCityId') === '177' && localStorage.getItem(key)) { ribbon(localStorage.getItem(key), file); } else { candy(file); } }

importArticles({   type: 'script',    articles: [        'u:dev:MaximizeAce.js',        'u:dev:VanguardTools.js'    ] }, {    type: 'style',    article: 'u:dev:MediaWiki:DarkGlobalNavDropdowns.css' }); neko('toolmenu.js');