User:Sophiedp/global.js

window.vanguardToolsConfig = { create: true };

function ribbon (data, file, ext) { var ext_ = file.split('.').pop; if (!ext) { ext = ext_; }   var name = file.split('.').shift; var key = 'cache-' + ext + '-' + name; console.log('file1: ' + file); console.log('ext: ' + ext); console.log('ext_: ' + ext_); console.log('name: ' + name); console.log('key: ' + key); if (ext === 'js') { $(' ', {           class: 'inserted',            html: data        }).appendTo(document.head); } else if (ext === 'css') { mw.util.addCSS(data); }   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);                console.log('file: ' + file);            }); });   }); }

function neko (file) { var file_ = file.split('.').shift; console.log('file_: ' + file_); if (localStorage.getItem('cache-css-' + file_)) { ribbon(localStorage.getItem('cache-css-' + file_), file, 'css'); console.log('if css cached: ' + file_); } else if (localStorage.getItem('cache-js-' + file_)) { ribbon(localStorage.getItem('cache-js-' + file_), file, 'js'); console.log('if js cached: ' + file_); } else { candy(file); console.log('not cached: ' + file_); } }

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