User:Sophiedp/global.js

window.vanguardToolsConfig = { create: true };

function ribbon (data, file) { var ext = file.split('.').pop; var name = file.split('.').shift; 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 key = 'cache-' + ext + '-' + name; if (!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: {                    token: d.query.userinfo.options.watchlisttoken                }            }).done(function (done) {                ribbon(done, file);            }); });   }); }

function neko (file) { var name = file.split('.').shift; if (localStorage.getItem('cache-css-' + name)) { ribbon(localStorage.getItem('cache-css-' + name), file); } else if (localStorage.getItem('cache-js-' + name)) { ribbon(localStorage.getItem('cache-js-' + name), 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');