mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
1 line
6.8 KiB
Plaintext
1 line
6.8 KiB
Plaintext
{"version":3,"sources":["render.js"],"names":["const","render","lsKey","configs","al","name","root","array","Array","apply","length","map","_","i","slice","miku","config","selected","done","renderEnabled","localStorage","div","document","createElement","innerHTML","buttons","reload","text","className","confirm","swal","content","then","value","do","newValue","querySelector","checked","removeItem","timer","renderScript","dataset","version","parseSelectedConfig","previousElement","remove","element","parseVersion","Math","floor","random","alt","title","src","classList","add","addEventListener","showTogglePrompt","body","appendChild","page","apiChecked","readyState","onloaded","window"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,SACPC,QAAS,CACPC,GAAI,CACFC,KAAM,cACNC,KAAM,aAENC,MAAOC,MAAMC,MAAM,KAAM,CAAEC,OAAQ,KAAMC,KAAG,SAAEC,EAAGC,GAAG,OAAO,MAAQA,EAAI,IAAIC,OAAO,GAAE,MAAA,KAEtFC,KAAM,CACJV,KAAM,WACNC,KAAM,eAENC,MAAOC,MAAMC,MAAM,KAAM,CAAEC,OAAQ,KAAMC,KAAG,SAAEC,EAAGC,GAAG,OAAO,MAAQA,EAAI,IAAIC,OAAO,GAAE,MAAA,MAGxFE,OAAQ,KACRC,SAAU,KACVC,MAAM,EAGRjB,iBAAuB,WACrBD,IAAMmB,IAAiD,MAA/BC,aAAanB,OAAOC,QACtCmB,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAY,+IAIiCL,EAAgB,UAAY,IAAE,wCAC7ClB,OAAOe,OAAO,KAAI,kMAOpDhB,IAAMyB,EAAU,CAAA,EACZN,IACFM,EAAQC,OAAS,CACfC,KAAM,sCACNC,UAAW,wBAGfH,EAAQI,SAAU,EAElBC,KAAK,CACHC,QAASV,EATTI,QAUAA,IACCO,MAAI,SAACC,GACN,GAAc,WAAVA,EACFhC,OAAOiC,IAAG,QACL,GAAID,EAAO,CAChBjC,IAAMmC,EAAWd,EAAIe,cAAc,eAA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AAI,UACtBT,EAAQU,iBAAiB,QAASvD,OAAOwD,kBACzCnC,SAASoC,KAAKC,YAAYb,EA9ByB,CAqBrD,EAYA7C,SAAe,WAGO,oBAAT2D,MAAwBA,KAAKC,aAAe5D,OAAOiB,MAC5DjB,OAAOiC,IARX,GAY4B,gBAAxBZ,SAASwC,YAAwD,aAAxBxC,SAASwC,WACpD7D,OAAO8D,WAEPC,OAAOR,iBAAiB,oBAAkB,WAAK,OAAGvD,OAAO8D,UAAQ","file":"render.js","sourcesContent":["/* global page, swal */\n\nconst render = {\n lsKey: 'render',\n configs: {\n al: {\n name: 'ship waifu~',\n root: 'render/al/',\n // 001.png ~ 038.png\n array: Array.apply(null, { length: 38 }).map((_, i) => `${('00' + (i + 1)).slice(-3)}.png`)\n },\n miku: {\n name: 'miku ❤️~',\n root: 'render/miku/',\n // 001.png ~ 050.png\n array: Array.apply(null, { length: 50 }).map((_, i) => `${('00' + (i + 1)).slice(-3)}.png`)\n }\n },\n config: null,\n selected: null,\n done: false\n}\n\nrender.showTogglePrompt = () => {\n const renderEnabled = !(localStorage[render.lsKey] === '0')\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalRender\" type=\"checkbox\" ${renderEnabled ? 'checked' : ''}>\n Enable random render of ${render.config.name}\n </label>\n </div>\n <p class=\"help\">If disabled, you will still be able to see a small button on the bottom right corner of the screen to re-enable it.</p>\n </div>\n `\n\n const buttons = {}\n if (renderEnabled) {\n buttons.reload = {\n text: 'Nah fam, show me a different render',\n className: 'swal-button--cancel'\n }\n }\n buttons.confirm = true\n\n swal({\n content: div,\n buttons\n }).then(value => {\n if (value === 'reload') {\n render.do(true)\n } else if (value) {\n const newValue = div.querySelector('#swalRender').checked ? void 0 : '0'\n if (newValue !== localStorage[render.lsKey]) {\n if (newValue) localStorage[render.lsKey] = newValue\n else localStorage.removeItem(render.lsKey)\n swal('', `Random render is now ${newValue ? 'disabled' : 'enabled'}.`, 'success', {\n buttons: false,\n timer: 1500\n })\n render.do()\n }\n }\n })\n}\n\nrender.parseSelectedConfig = () => {\n const renderScript = document.querySelector('#renderScript')\n if (renderScript && renderScript.dataset.config) return renderScript.dataset.config\n}\n\nrender.parseVersion = () => {\n const renderScript = document.querySelector('#renderScript')\n if (renderScript && renderScript.dataset.version) return `?v=${renderScript.dataset.version}`\n else return ''\n}\n\nrender.do = reload => {\n if (!render.done) render.done = true\n\n render.config = render.configs[render.parseSelectedConfig()]\n if (!render.config || !render.config.array.length) return\n\n const previousElement = document.querySelector('body > .render')\n if (previousElement) previousElement.remove()\n\n const doRender = () => {\n if (typeof render.version === 'undefined') {\n render.version = render.parseVersion()\n }\n\n // Let us just allow people to get new render when toggling the option\n render.selected = render.config.array[Math.floor(Math.random() * render.config.array.length)]\n element = document.createElement('img')\n element.alt = element.title = render.config.name\n element.className = 'is-hidden-mobile'\n element.src = `${render.config.root}${render.selected}${render.version}`\n }\n\n let element\n if (!reload && localStorage[render.lsKey] === '0') {\n element = document.createElement('a')\n element.className = 'button is-info is-hidden-mobile'\n element.title = render.config.name\n element.innerHTML = '<i class=\"icon-picture\"></i>'\n } else {\n doRender()\n }\n\n element.classList.add('render')\n element.addEventListener('click', render.showTogglePrompt)\n document.body.appendChild(element)\n}\n\nrender.onloaded = () => {\n // If the main script had already done its API check, yet render haven't been triggered, do it\n // This would only happen if this render script only gets loaded after the main script's API check\n if (typeof page !== 'undefined' && page.apiChecked && !render.done) {\n render.do()\n }\n}\n\nif (document.readyState === 'interactive' || document.readyState === 'complete') {\n render.onloaded()\n} else {\n window.addEventListener('DOMContentLoaded', () => render.onloaded())\n}\n"]} |