Greasy Fork is available in English.

Magic Userscript+ : サイトをすべて表示 UserJS

サイトのユーザー スクリプト (UserJS) を表示します。 Tampermonkey のカスタム スクリプトをインストールする簡単な方法。

2024/03/01のページです。最新版はこちら。

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Magic Userscript+ : Show Site All UserJS
  3. // @name:es Magic Userscript+: Mostrar sitio todos los UserJS
  4. // @name:fr Magic Userscript+ : Afficher le site Tous les UserJS
  5. // @name:ja Magic Userscript+ : サイトをすべて表示 UserJS
  6. // @name:nl Magic Userscript+: Site alle UserJS tonen
  7. // @name:ru Magic Userscript+: показать сайт всем UserJS
  8. // @name:zh Magic Userscript+ :显示站点所有 UserJS
  9. // @name:zh-CN Magic Userscript+ :显示站点所有 UserJS
  10. // @name:zh-TW Magic Userscript+ :显示站点所有 UserJS
  11. // @description Show current site all UserJS, the easier way to install UserJs for Tampermonkey.
  12. // @description:es Mostrar todos los UserJS del sitio actual, la forma más fácil de instalar UserJs para Tampermonkey.
  13. // @description:fr Afficher le site actuel avec tous les UserJS, le moyen le plus simple d'installer UserJs pour Tampermonkey.
  14. // @description:ja サイトのユーザー スクリプト (UserJS) を表示します。 Tampermonkey のカスタム スクリプトをインストールする簡単な方法。
  15. // @description:nl Toon de huidige site alle UserJS, de eenvoudigere manier om UserJs voor Tampermonkey te installeren.
  16. // @description:ru Показать все UserJS текущего сайта — более простой способ установки UserJs для Tampermonkey.
  17. // @description:zh 显示站点的用户脚本 (UserJS)。 为 Tampermonkey 安装自定义脚本的简单方法。
  18. // @description:zh-CN 显示站点的用户脚本 (UserJS)。 为 Tampermonkey 安装自定义脚本的简单方法。
  19. // @description:zh-TW 显示站点的用户脚本 (UserJS)。 为 Tampermonkey 安装自定义脚本的简单方法。
  20. // @author Magic <magicoflolis@tuta.io>
  21. // @icon data:image/png;base64,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
  22. // @version 6.3.0
  23. // @namespace https://github.com/magicoflolis/Userscript-Plus
  24. // @homepageURL https://github.com/magicoflolis/Userscript-Plus
  25. // @supportURL https://github.com/magicoflolis/Userscript-Plus/issues/new
  26. // @license MIT
  27. // @compatible chrome
  28. // @compatible firefox
  29. // @compatible edge
  30. // @compatible opera
  31. // @compatible safari
  32. // @connect greatest.deepsurf.us
  33. // @connect sleazyfork.org
  34. // @connect github.com
  35. // @connect openuserjs.org
  36. // @grant GM.xmlHttpRequest
  37. // @grant GM.openInTab
  38. // @grant GM.getValue
  39. // @grant GM.setValue
  40. // @grant GM.info
  41. // @grant GM_xmlhttpRequest
  42. // @grant GM_openInTab
  43. // @grant GM_getValue
  44. // @grant GM_setValue
  45. // @grant GM_info
  46. // @match https://*/*
  47. // @noframes
  48. // @run-at document-start
  49. // ==/UserScript==
  50. 'use strict';
  51. (() => {
  52. /**
  53. * To compile this CSS `pnpm run build:Sass`
  54. *
  55. * Link to uncompiled Cascading Style Sheet
  56. * @link https://github.com/magicoflolis/Userscript-Plus/tree/master/src/sass
  57. */
  58. const main_css = `mujs-root{--mujs-even-row: hsl(222, 14%, 22%);--mujs-odd-row: hsl(222, 14%, 11%);--mujs-background-color: hsl(222, 14%, 33%);--mujs-gf-color: hsl(204, 100%, 40%);--mujs-sf-color: hsl(12, 86%, 50%);--mujs-border-b-color: hsla(0, 0%, 0%, 0);--mujs-gf-btn-color: hsl(211, 87%, 56%);--mujs-sf-btn-color: hsl(12, 86%, 50%);--mujs-sf-txt-color: hsl(12, 79%, 55%);--mujs-txt-color: hsl(0, 0%, 100%);--mujs-chck-color: hsla(0, 0%, 100%, 0.568);--mujs-chck-gf: hsla(197, 100%, 50%, 0.568);--mujs-chck-git: hsla(213, 13%, 16%, 0.568);--mujs-chck-open: hsla(12, 86%, 50%, 0.568);--mujs-placeholder: hsl(81, 56%, 54%)}mujs-root *{scrollbar-color:var(--mujs-txt-color, hsl(0, 0%, 100%)) #2e323d;scrollbar-width:thin}@supports not (scrollbar-width: thin){mujs-root * ::-webkit-scrollbar{width:1.4vw;height:3.3vh}mujs-root * ::-webkit-scrollbar-track{background-color:#2e323d;border-radius:16px;margin-top:3px;margin-bottom:3px;box-shadow:inset 0 0 6px rgba(0,0,0,.3)}mujs-root * ::-webkit-scrollbar-thumb{border-radius:16px;background-color:var(--mujs-txt-color, hsl(0, 0%, 100%));background-image:-webkit-linear-gradient(45deg, hsla(0, 0%, 100%, 0.2) 25%, transparent 25%, transparent 50%, hsla(0, 0%, 100%, 0.2) 50%, hsla(0, 0%, 100%, 0.2) 75%, transparent 75%, transparent)}mujs-root * ::-webkit-scrollbar-thumb:hover{background-color:var(--mujs-txt-color, hsl(0, 0%, 100%))}}mu-js{line-height:normal}.mujs-cfg{line-height:1.5}mu-js{color:var(--mujs-txt-color, hsl(0, 0%, 100%))}body.webext-page,.main{font-size:14px}mujs-section>label,.mujs-homepag e,td.mujs-list,.install{font-size:16px}.install,.mujs-homepage{font-weight:700}mujs-section>label,td.mujs-list{font-weight:500}.mujs-fltlist{width:170px}.mujs-searcher{width:100px}.mujs-sty-flex>mujs-btn{margin:auto}.mujs-invalid{border-radius:8px !important;border-width:2px !important;border-style:solid !important;border-color:red !important}mujs-column,mujs-row,.mujs-sty-flex{display:flex}mujs-column,mujs-row{gap:.5em}@media screen and (max-width: 800px){mujs-column{flex-flow:row wrap}}mujs-column count-frame:nth-child(1){background-color:var(--mujs-gf-color, hsl(204, 100%, 40%))}mujs-column count-frame:nth-child(2){background-color:var(--mujs-sf-color, hsl(12, 86%, 50%))}mujs-row{flex-flow:column wrap}mu-js{cursor:default}.hidden{display:none !important;z-index:-1 !important}.main{width:100%;width:-moz-available;width:-webkit-fill-available;background:var(--mujs-background-color, hsl(222, 14%, 33%)) !important;border:1px solid var(--mujs-border-b-color, hsla(0, 0%, 0%, 0));border-radius:16px;font-family:Arial,Helvetica,sans-serif}@media screen and (max-height: 720px){.main:not(.webext-page){height:100% !important;bottom:0rem !important;right:0rem !important;margin:0rem !important}}.main.expanded{height:100% !important;bottom:0rem !important}.main:not(.webext-page){position:fixed;height:492px}.main:not(.webext-page):not(.expanded){margin-left:1rem;margin-right:1rem;right:1rem;bottom:1rem}.main:not(.webext-page):not(.expanded).auto-height{height:auto}.main:not(.hidden){z-index:100000000000000000 !important;display:flex !important;flex-direction:column !important}.main mujs-btn,.main input{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.main input{background:var(--mujs-background-color, hsl(222, 14%, 33%));color:var(--mujs-txt-color, hsl(0, 0%, 100%))}.main input:not([type=checkbox]){border:rgba(0,0,0,0);outline:none !important}.main textarea{overflow-y:auto;color:var(--mujs-placeholder, hsl(81, 56%, 54%));background-color:var(--mujs-even-row, hsl(222, 14%, 18%));border:1px solid rgba(0,0,0,0);border-radius:10px;resize:vertical;outline:none;font-family:monospace;font-size:14px}.main textarea:focus{outline:none}.main th,.main .mujs-cfg *:not(input[type=password],input[type=text],input[type=number]){-webkit-user-select:none !important;-moz-user-select:none !important;-ms-user-select:none !important;user-select:none !important}.mainframe{background:rgba(0,0,0,0);position:fixed;bottom:1rem;right:1rem}.mainframe count-frame{width:fit-content;width:-moz-fit-content;width:-webkit-fit-content;height:auto;padding:14px 16px}.mainframe:not(.hidden){z-index:100000000000000000 !important;display:block}count-frame{border-radius:1000px;margin:0px 3px;padding:4px 6px;border:2px solid var(--mujs-border-b-color, hsla(0, 0%, 0%, 0));font-size:16px;font-weight:400;display:inline-block;text-align:center;min-width:1em;background:var(--mujs-background-color, hsl(222, 14%, 33%));color:var(--mujs-txt-color, hsl(0, 0%, 100%));-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.mujs-header-prim{order:0;display:flex;border-bottom:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%));border-top-left-radius:10px;border-top-right-radius:10px;padding:.5em;font-size:1em;place-content:space-between;height:fit-content;height:-moz-fit-content;height:-webkit-fit-content;width:100%;width:-moz-available;width:-webkit-fill-available}.mujs-body{overflow-x:hidden;order:1;padding:0px;width:100%;width:-moz-available;width:-webkit-fill-available}.mujs-body .mujs-ratings{padding:0 .25em;border:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%));border-radius:1000px}.mujs-body mu-jsbtn{color:var(--mujs-txt-color, hsl(0, 0%, 100%))}.mujs-body table,.mujs-body th,.mujs-body td{border-collapse:collapse}.mujs-body table{width:100%;width:-moz-available;width:-webkit-fill-available}@media screen and (max-width: 1180px){.mujs-body table thead>tr{display:table-column}.mujs-body table .frame:not(.webext-page){width:100%;display:flex;flex-flow:row wrap;align-items:center;border-bottom:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%));padding-top:.5em;padding-bottom:.5em}.mujs-body table .frame:not(.webext-page) td{margin:auto;border-bottom:1px solid rgba(0,0,0,0)}.mujs-body table .frame:not(.webext-page) td>mujs-a,.mujs-body table .frame:not(.webext-page) td>mu-js,.mujs-body table .frame:not(.webext-page) td>mujs-column{text-align:center;justify-content:center}.mujs-body table .frame:not(.webext-page) td:not(.mujs-name,.install-btn){width:25%}.mujs-body table .frame:not(.webext-page) .mujs-name{width:100%}}.mujs-body table th,.mujs-body table td{border-bottom:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%))}.mujs-body table th{position:-webkit-sticky;position:sticky;top:0;background:rgba(72,79,96,.75)}.mujs-body table th.mujs-header-name{width:50%}@media screen and (max-width: 800px){.mujs-body table th.mujs-header-name{width:auto !important}}.mujs-body table .frame:nth-child(even){background-color:var(--mujs-even-row, hsl(222, 14%, 18%)) !important}.mujs-body table .frame:nth-child(odd){background-color:var(--mujs-odd-row, hsl(222, 14%, 33%)) !important}.mujs-body table .frame.sf mujs-a{color:var(--mujs-sf-txt-color, hsl(12, 79%, 55%))}.mujs-body table .frame.sf mu-jsbtn{background-color:var(--mujs-sf-btn-color, hsl(12, 86%, 50%));border-color:var(--mujs-sf-btn-color, hsl(12, 86%, 50%))}.mujs-body table .frame.sf mu-jsbtn:hover{background-color:var(--mujs-sf-txt-color, hsl(12, 79%, 55%));border-color:var(--mujs-sf-txt-color, hsl(12, 79%, 55%))}.mujs-body table .frame:not(.sf) mujs-a{color:var(--mujs-gf-color, hsl(197, 100%, 50%))}.mujs-body table .frame:not(.sf) mujs-a:hover{color:var(--mujs-gf-btn-color, hsl(211, 87%, 56%))}.mujs-body table .frame:not(.sf) mu-jsbtn{color:var(--mujs-txt-color, hsl(0, 0%, 100%));background-color:var(--mujs-gf-color, hsl(204, 100%, 40%));border-color:var(--mujs-gf-color, hsl(204, 100%, 40%))}.mujs-body table .frame:not(.sf) mu-jsbtn:hover{background-color:var(--mujs-gf-btn-color, hsl(211, 87%, 56%));border-color:var(--mujs-gf-btn-color, hsl(211, 87%, 56%))}.mujs-body table .frame[data-good] mujs-a,.mujs-body table .frame[data-author] mujs-a{color:var(--mujs-placeholder, hsl(81, 56%, 54%))}.mujs-body table .frame[data-good] mujs-a:hover,.mujs-body table .frame[data-author] mujs-a:hover{color:#80ab30}.mujs-body table .frame[data-good] .mujs-list,.mujs-body table .frame[data-author] .mujs-list{color:#fff}.mujs-body table .frame[data-good] mu-jsbtn,.mujs-body table .frame[data-author] mu-jsbtn{color:#20385a;background-color:var(--mujs-placeholder, hsl(81, 56%, 54%));border-color:var(--mujs-placeholder, hsl(81, 56%, 54%))}.mujs-body table .frame[data-good] mu-jsbtn:hover,.mujs-body table .frame[data-author] mu-jsbtn:hover{background-color:#b5d874;border-color:#b5d874}.mujs-body table .frame svg{fill:currentColor;width:14px;height:14px;background:rgba(0,0,0,0)}.mujs-body table .frame>td:not(.mujs-name){text-align:center}.mujs-body table .frame>.mujs-name>mujs-a{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}.mujs-body table .frame>.mujs-name mu-jsbtn,.mujs-body table .frame>.mujs-name mu-js{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.mujs-body table .frame>.mujs-name>mu-jsbtn{margin:auto}.mujs-body table .frame>.mujs-name>mujs-column>mu-jsbtn{padding:0px 7px}.mujs-body table .frame>.mujs-name>textarea{background-color:inherit;border:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%));border-radius:14px}.mujs-body table .frame>.mujs-uframe>mujs-a{font-size:16px;font-weight:500;padding-left:.5rem;padding-right:.5rem}.mujs-cfg,.mujs-body{border:1px solid var(--mujs-border-b-color, hsla(0, 0%, 0%, 0));border-bottom-left-radius:16px;border-bottom-right-radius:16px}@media screen and (max-width: 1150px){.mujs-cfg{margin:0px auto 1rem auto !important}}.mujs-cfg{height:fit-content;height:-moz-fit-content;height:-webkit-fit-content}@media screen and (max-height: 720px){.mujs-cfg:not(.webext-page){height:100%;height:-moz-available;height:-webkit-fill-available;width:100%;width:-moz-available;width:-webkit-fill-available;overflow-x:auto;padding:.5em}}.mujs-cfg mujs-section{border-radius:16px;padding:.5em}.mujs-cfg mujs-section:nth-child(even){background-color:var(--mujs-even-row, hsl(222, 14%, 18%)) !important}.mujs-cfg mujs-section:nth-child(odd){background-color:var(--mujs-odd-row, hsl(222, 14%, 33%)) !important}.mujs-cfg mujs-section>label{display:flex;justify-content:space-between}.mujs-cfg mujs-section>label input:not([type=checkbox]){font-size:14px;position:relative;border-radius:4px;border:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%))}.mujs-cfg mujs-section>label input[type=text]::-webkit-input-placeholder{color:var(--mujs-placeholder, hsl(81, 56%, 54%))}.mujs-cfg mujs-section>label input[type=text]::-moz-placeholder{color:var(--mujs-placeholder, hsl(81, 56%, 54%))}.mujs-cfg mujs-section>label input[type=text]:-ms-input-placeholder{color:var(--mujs-placeholder, hsl(81, 56%, 54%))}.mujs-cfg mujs-section>label input[type=text]::-ms-input-placeholder{color:var(--mujs-placeholder, hsl(81, 56%, 54%))}.mujs-cfg mujs-section>label input[type=text]::placeholder{color:var(--mujs-placeholder, hsl(81, 56%, 54%))}.mujs-cfg .mujs-inlab{position:relative;width:38px}.mujs-cfg .mujs-inlab input[type=checkbox]{display:none}.mujs-cfg .mujs-inlab input[type=checkbox]:checked+label{margin-left:0;background-color:var(--mujs-chck-color, hsla(0, 0%, 100%, 0.568))}.mujs-cfg .mujs-inlab input[type=checkbox]:checked+label:before{right:0px}.mujs-cfg .mujs-inlab input[type=checkbox][data-name=greasyfork]:checked+label,.mujs-cfg .mujs-inlab input[type=checkbox][data-name=sleazyfork]:checked+label{background-color:var(--mujs-chck-gf, hsla(197, 100%, 50%, 0.568))}.mujs-cfg .mujs-inlab input[type=checkbox][data-name=openuserjs]:checked+label{background-color:var(--mujs-chck-open, hsla(12, 86%, 50%, 0.568))}.mujs-cfg .mujs-inlab input[type=checkbox][data-name=github]:checked+label{background-color:var(--mujs-chck-git, hsla(213, 13%, 16%, 0.568))}.mujs-cfg .mujs-inlab label{padding:0;display:block;overflow:hidden;height:16px;border-radius:20px;border:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%));background-color:var(--mujs-background-color, hsl(222, 14%, 33%))}.mujs-cfg .mujs-inlab label:before{content:"";display:block;width:20px;height:20px;margin:-2px;background:var(--mujs-txt-color, hsl(0, 0%, 100%));position:absolute;top:0;right:20px;border-radius:20px}.mujs-cfg [data-name=blacklist]{background-color:var(--mujs-even-row, hsl(222, 14%, 18%));border:1px solid rgba(0,0,0,0);border-radius:10px}.mujs-cfg .mujs-sty-flex mujs-btn{color:var(--mujs-txt-color, hsl(0, 0%, 100%))}.mujs-cfg .mujs-sty-flex mujs-btn[data-command=reset]{background-color:var(--mujs-sf-btn-color, hsl(12, 86%, 50%));border-color:var(--mujs-sf-btn-color, hsl(12, 86%, 50%))}.mujs-cfg .mujs-sty-flex mujs-btn[data-command=reset]:hover{background-color:var(--mujs-sf-txt-color, hsl(12, 79%, 55%));border-color:var(--mujs-sf-txt-color, hsl(12, 79%, 55%))}.mujs-cfg .mujs-sty-flex mujs-btn[data-command=save]{background-color:var(--mujs-gf-color, hsl(204, 100%, 40%));border-color:var(--mujs-gf-color, hsl(204, 100%, 40%))}.mujs-cfg .mujs-sty-flex mujs-btn[data-command=save]:hover{background-color:var(--mujs-gf-btn-color, hsl(211, 87%, 56%));border-color:var(--mujs-gf-btn-color, hsl(211, 87%, 56%))}.mujs-cfg:not(.webext-page){order:2;margin:0px 25rem 1rem 25rem}mujs-a{display:inline-block}.mujs-name{display:flex;flex-flow:column wrap;gap:.5em}.mujs-name span{font-size:.8em !important}mujs-btn{font-style:normal;font-weight:500;font-variant:normal;text-transform:none;text-rendering:auto;text-align:center;border:1px solid var(--mujs-txt-color, hsl(0, 0%, 100%));font-size:16px;border-radius:4px;line-height:1;padding:6px 15px}mujs-btn svg{fill:var(--mujs-txt-color, hsl(0, 0%, 100%));width:14px;height:14px}mu-jsbtn{font-size:14px;border-radius:4px;font-style:normal;padding:7px 15%;font-weight:400;font-variant:normal;line-height:normal;display:block;text-align:center}mujs-a,mu-jsbtn,.mujs-pointer,.mujs-cfg mujs-section *:not(input[type=password],input[type=text],input[type=number]),.mainbtn,.mainframe,mujs-btn{cursor:pointer !important}`;
  59. /**
  60. * Link to uncompressed languages
  61. * @link https://github.com/magicoflolis/Userscript-Plus/tree/master/src/_locales
  62. */
  63. const languageList = {"en":{"legacy":"PLEASE RESET YOUR CONFIG!","createdby":"Created by","name":"Name","daily":"Daily Installs","close":"Close","filterA":"Filter","max":"Maximize","min":"Minimize","search":"Search","searcher":"Title | Description | Author...","install":"Install","issue":"New Issue","version":"Version","updated":"Last Updated","total":"Total Installs","rating":"Ratings","good":"Good","ok":"Ok","bad":"Bad","created":"Created","redirect":"Greasy Fork for adults","filter":"Filter out other languages","dtime":"Display Timeout","save":"Save","reset":"Reset"},"es":{"legacy":"¡POR FAVOR RESTABLECE TU CONFIGURACIÓN!","createdby":"Creado por","name":"Nombre","daily":"Instalaciones diarias","close":"Ya no se muestra","filterA":"Filtro","max":"Maximizar","min":"Minimizar","search":"Busque en","searcher":"Título | Descripción | Autor...","install":"Instalar","issue":"Nueva edición","version":"Versión","updated":"Última actualización","total":"Total de instalaciones","rating":"Clasificaciones","good":"Bueno","ok":"Ok","bad":"Malo","created":"Creado","redirect":"Greasy Fork para adultos","filter":"Filtrar otros idiomas","dtime":"Mostrar el tiempo de espera","save":"Guardar","reset":"Reiniciar"},"fr":{"legacy":"VEUILLEZ RÉINITIALISER VOTRE CONFIG !","createdby":"Créé par","name":"Nom","daily":"Installations quotidiennes","close":"Ne plus montrer","filterA":"Filtre","max":"Maximiser","min":"Minimiser","search":"Recherche","searcher":"Titre | Description | Auteur...","install":"Installer","issue":"Nouveau numéro","version":"Version","updated":"Dernière mise à jour","total":"Total des installations","rating":"Notations","good":"Bon","ok":"Ok","bad":"Mauvais","created":"Créé","redirect":"Greasy Fork pour les adultes","filter":"Filtrer les autres langues","dtime":"Délai d'affichage","save":"Sauvez","reset":"Réinitialiser"},"ja":{"legacy":"設定をリセットしてください。","createdby":"によって作成された","name":"名前","daily":"デイリーインストール","close":"表示されなくなりました","filterA":"フィルター","max":"最大化","min":"ミニマム","search":"検索","searcher":"タイトル|説明|著者...","install":"インストール","issue":"新刊のご案内","version":"バージョン","updated":"最終更新日","total":"総インストール数","rating":"レーティング","good":"グッド","ok":"良い","bad":"悪い","created":"作成","redirect":"大人のGreasyfork","filter":"他の言語をフィルタリングする","dtime":"表示タイムアウト","save":"拯救","reset":"リセット"},"nl":{"legacy":"RESET UW CONFIG!","createdby":"Gemaakt door","name":"Naam","daily":"Dagelijkse Installaties","close":"Sluit","filterA":"Filter","max":"Maximaliseer","min":"Minimaliseer","search":"Zoek","searcher":"Titel | Beschrijving | Auteur...","install":"Installeer","issue":"Nieuw Issue","version":"Versie","updated":"Laatste Update","total":"Totale Installaties","rating":"Beoordeling","good":"Goed","ok":"Ok","bad":"Slecht","created":"Aangemaakt","redirect":"Greasy Fork voor volwassenen","filter":"Filter andere talen","dtime":"Weergave timeout","save":"Opslaan","reset":"Opnieuw instellen"},"ru":{"legacy":"ПОЖАЛУЙСТА, СБРОСЬТЕ КОНФИГ!","createdby":"Сделано","name":"Имя","daily":"Ежедневные установки","close":"Больше не показывать","filterA":"Фильтр","max":"Максимизировать","min":"Минимизировать","search":"Поиск","searcher":"Название | Описание | Автор...","install":"Установите","issue":"Новый выпуск","version":"Версия","updated":"Последнее обновление","total":"Всего установок","rating":"Рейтинги","good":"Хорошо","ok":"Хорошо","bad":"Плохо","created":"Создано","redirect":"Greasy Fork для взрослых","filter":"Отфильтровать другие языки","dtime":"Тайм-аут отображения","save":"Сохранить","reset":"Перезагрузить"},"zh":{"legacy":"请重置您的配置!","createdby":"由...制作","name":"姓名","daily":"日常安装","close":"不再显示","filterA":"过滤器","max":"最大化","min":"最小化","search":"搜索","searcher":"标题|描述|作者...","install":"安装","issue":"新问题","version":"版本","updated":"最后更新","total":"总安装量","rating":"评级","good":"好的","ok":"好的","bad":"不好","created":"创建","redirect":"大人的Greasyfork","filter":"过滤掉其他语言","dtime":"显示超时","save":"拯救","reset":"重置"}};
  64. let userjs = (self.userjs = {});
  65. let cfg = {};
  66. let lang = {};
  67. let legacyMsg = null;
  68. /** Skip text/plain documents */
  69. if (
  70. (document instanceof Document ||
  71. (document instanceof XMLDocument && document.createElement('div') instanceof HTMLDivElement)) &&
  72. /^image\/|^text\/plain/.test(document.contentType || '') === false &&
  73. (self.userjs instanceof Object === false || userjs.UserJS !== true)
  74. ) {
  75. userjs = self.userjs = { UserJS: true };
  76. }
  77.  
  78. // Lets highlight me :)
  79. const authorID = 166061;
  80. // Some UserJS I personally enjoy
  81. const goodUserJS = [
  82. 423001,
  83. 376510,
  84. 23840,
  85. 40525,
  86. 6456,
  87. 'https://github.com/TagoDR/MangaOnlineViewer/raw/master/Manga_OnlineViewer.user.js',
  88. 'https://github.com/jesus2099/konami-command/raw/master/INSTALL-USER-SCRIPT.user.js',
  89. 'https://github.com/TagoDR/MangaOnlineViewer/raw/master/dist/Manga_OnlineViewer_Adult.user.js'
  90. ];
  91.  
  92. const isMobile = /Mobile|Tablet/.test(navigator.userAgent);
  93. const Supports = {
  94. gm: typeof GM !== 'undefined'
  95. };
  96. //#region Console
  97. const dbg = (...msg) => {
  98. const dt = new Date();
  99. console.debug(
  100. '[%cUserJS%c] %cDBG',
  101. 'color: rgb(29, 155, 240);',
  102. '',
  103. 'color: rgb(255, 212, 0);',
  104. `[${dt.getHours()}:${('0' + dt.getMinutes()).slice(-2)}:${('0' + dt.getSeconds()).slice(-2)}]`,
  105. ...msg
  106. );
  107. };
  108. const err = (...msg) => {
  109. console.error(
  110. '[%cUserJS%c] %cERROR',
  111. 'color: rgb(29, 155, 240);',
  112. '',
  113. 'color: rgb(249, 24, 128);',
  114. ...msg
  115. );
  116. let alertBrowser = false;
  117. for (const ex of msg) {
  118. if (typeof ex === 'object' && 'cause' in ex) {
  119. alertBrowser = true;
  120. break;
  121. }
  122. }
  123. if (isMobile || alertBrowser) {
  124. alert(...msg);
  125. }
  126. };
  127. const info = (...msg) => {
  128. console.info(
  129. '[%cUserJS%c] %cINF',
  130. 'color: rgb(29, 155, 240);',
  131. '',
  132. 'color: rgb(0, 186, 124);',
  133. ...msg
  134. );
  135. };
  136. // eslint-disable-next-line no-unused-vars
  137. const log = (...msg) => {
  138. console.log(
  139. '[%cUserJS%c] %cLOG',
  140. 'color: rgb(29, 155, 240);',
  141. '',
  142. 'color: rgb(219, 160, 73);',
  143. ...msg
  144. );
  145. };
  146. //#endregion
  147. const MU = {};
  148. const hasOwn = Object.hasOwn || Object.prototype.hasOwnProperty.call;
  149. /**
  150. * Object is typeof `Element`
  151. * @template O
  152. * @param { O } obj
  153. * @returns { boolean }
  154. */
  155. const isElem = (obj) => {
  156. // const s = /** @type { string } */ (Object.prototype.toString.call(obj));
  157. /** @type { string } */
  158. const s = Object.prototype.toString.call(obj);
  159. return s.includes('Element');
  160. };
  161. /**
  162. * Object is typeof `Function`
  163. * @template O
  164. * @param { O } obj
  165. * @returns { boolean }
  166. */
  167. const isFN = (obj) => {
  168. /** @type { string } */
  169. const s = Object.prototype.toString.call(obj);
  170. return s.includes('Function');
  171. };
  172. /**
  173. * Object is typeof `object` / JSON Object
  174. * @template O
  175. * @param { O } obj
  176. * @returns { boolean }
  177. */
  178. const isObj = (obj) => {
  179. /** @type { string } */
  180. const s = Object.prototype.toString.call(obj);
  181. return s.includes('Object');
  182. };
  183. /**
  184. * Object is `null` or `undefined`
  185. * @template O
  186. * @param { O } obj
  187. * @returns { boolean }
  188. */
  189. const isNull = (obj) => {
  190. return Object.is(obj, null) || Object.is(obj, undefined);
  191. };
  192. /**
  193. * Object is Blank
  194. * @template O
  195. * @param { O } obj
  196. * @returns { boolean }
  197. */
  198. const isBlank = (obj) => {
  199. return (
  200. (typeof obj === 'string' && Object.is(obj.trim(), '')) ||
  201. ((obj instanceof Set || obj instanceof Map) && Object.is(obj.size, 0)) ||
  202. (Array.isArray(obj) && Object.is(obj.length, 0)) ||
  203. (isObj(obj) && Object.is(Object.keys(obj).length, 0))
  204. );
  205. };
  206. /**
  207. * Object is Empty
  208. * @template O
  209. * @param { O } obj
  210. * @returns { boolean }
  211. */
  212. const isEmpty = (obj) => {
  213. return isNull(obj) || isBlank(obj);
  214. };
  215. /**
  216. * @template B
  217. * @param { {} } objA
  218. * @param { B } objB
  219. * @returns { B }
  220. */
  221. const setObj = (objA = {}, objB = {}) => {
  222. objA = objA || {};
  223. objB = objB || {};
  224. for (const [key, value] of Object.entries(objA)) {
  225. if (!hasOwn(objB, key)) {
  226. objB[key] = value;
  227. } else if (typeof value === 'object') {
  228. setObj(value, objB[key]);
  229. }
  230. }
  231. return objB;
  232. };
  233. /**
  234. * @template T
  235. * @param { T } target
  236. * @param { Element } root
  237. * @param { boolean } toQuery
  238. * @returns { T[] }
  239. */
  240. const normalizeTarget = (target, root = document, toQuery = true) => {
  241. if (isNull(target)) {
  242. return [];
  243. }
  244. if (Array.isArray(target)) {
  245. return target;
  246. }
  247. if (typeof target === 'string') {
  248. return toQuery ? Array.from(root.querySelectorAll(target)) : [target];
  249. }
  250. if (isElem(target)) {
  251. return [target];
  252. }
  253. return Array.from(target);
  254. };
  255. class dom {
  256. /**
  257. * @template { HTMLElement } T
  258. * @param { T } target
  259. * @param { string } attr
  260. * @param { * } [value=undefined]
  261. */
  262. static attr(target, attr, value = undefined) {
  263. for (const elem of normalizeTarget(target)) {
  264. if (value === undefined) {
  265. return elem.getAttribute(attr);
  266. }
  267. if (value === null) {
  268. elem.removeAttribute(attr);
  269. } else {
  270. elem.setAttribute(attr, value);
  271. }
  272. }
  273. }
  274. /**
  275. * @template { HTMLElementTagNameMap } K
  276. * @param { K } a
  277. * @returns { HTMLElementTagNameMap[K] }
  278. */
  279. static create(a) {
  280. if (typeof a === 'string') {
  281. return document.createElement(a);
  282. }
  283. throw new Error('"a" must be a typeof "String"');
  284. }
  285. /**
  286. * @template { HTMLElement } T
  287. * @param { T } target
  288. * @param { string } prop
  289. * @param { * } [value=undefined]
  290. * @returns { keyof T | void }
  291. */
  292. static prop(target, prop, value = undefined) {
  293. for (const elem of normalizeTarget(target)) {
  294. if (value === undefined) {
  295. return elem[prop];
  296. }
  297. elem[prop] = value;
  298. }
  299. }
  300. /**
  301. * @template { HTMLElement } T
  302. * @param { T } target
  303. * @param { string } text
  304. */
  305. static text(target, text) {
  306. const targets = normalizeTarget(target);
  307. if (text === undefined) {
  308. return targets.length !== 0 ? targets[0].textContent : undefined;
  309. }
  310. for (const elem of targets) {
  311. elem.textContent = text;
  312. }
  313. }
  314. }
  315. dom.cl = class {
  316. static add(target, name) {
  317. if (Array.isArray(name)) {
  318. for (const elem of normalizeTarget(target)) {
  319. elem.classList.add(...name);
  320. }
  321. } else {
  322. for (const elem of normalizeTarget(target)) {
  323. elem.classList.add(name);
  324. }
  325. }
  326. }
  327.  
  328. static remove(target, name) {
  329. if (Array.isArray(name)) {
  330. for (const elem of normalizeTarget(target)) {
  331. elem.classList.remove(...name);
  332. }
  333. } else {
  334. for (const elem of normalizeTarget(target)) {
  335. elem.classList.remove(name);
  336. }
  337. }
  338. }
  339.  
  340. static toggle(target, name, state) {
  341. let r;
  342. for (const elem of normalizeTarget(target)) {
  343. r = elem.classList.toggle(name, state);
  344. }
  345. return r;
  346. }
  347.  
  348. static has(target, name) {
  349. for (const elem of normalizeTarget(target)) {
  350. if (elem.classList.contains(name)) {
  351. return true;
  352. }
  353. }
  354. return false;
  355. }
  356. };
  357. class Language {
  358. static get cache() {
  359. return languageList[cfg.language] ?? languageList[Language.navLang];
  360. }
  361.  
  362. static navLang = navigator.language.split('-')[0] ?? 'en';
  363. }
  364. class Task {
  365. static queue(func, timeout = 5000) {
  366. if (typeof requestIdleCallback === 'undefined') {
  367. return setTimeout(func, 1);
  368. }
  369. return requestIdleCallback(func, { timeout });
  370. }
  371.  
  372. /**
  373. * requestIdleCallback or setTimeout w/ Promise
  374. * @param {number} timeout - Timeout in milliseconds (ms)
  375. * @returns {Promise<void>} Promise object
  376. */
  377. static delay(timeout = 5000) {
  378. return new Promise((resolve) => Task.queue(resolve, timeout));
  379. }
  380.  
  381. static drop(id) {
  382. if (typeof cancelIdleCallback === 'undefined') {
  383. return clearTimeout(id);
  384. }
  385. return cancelIdleCallback(id);
  386. }
  387.  
  388. static timeout(timeout = 5000) {
  389. return new Promise((resolve) => setTimeout(resolve, timeout));
  390. }
  391.  
  392. static requestAFrame() {
  393. return new Promise((resolve) => requestAnimationFrame(resolve));
  394. }
  395. }
  396. const alang = [];
  397. const defcfg = {
  398. cache: true,
  399. codePreview: false,
  400. autoexpand: false,
  401. filterlang: false,
  402. sleazyredirect: false,
  403. time: 10000,
  404. blacklist: [
  405. {
  406. enabled: true,
  407. regex: true,
  408. flags: '',
  409. name: 'Blacklist 1',
  410. url: '(gov|cart|checkout|login|join|signin|signup|sign-up|password|reset|password_reset)'
  411. },
  412. {
  413. enabled: true,
  414. regex: true,
  415. flags: '',
  416. name: 'Blacklist 2',
  417. url: '(pay|bank|money|localhost|authorize|checkout|bill|wallet|router)'
  418. },
  419. {
  420. enabled: true,
  421. regex: false,
  422. flags: '',
  423. name: 'Blacklist 3',
  424. url: 'https://home.bluesnap.com'
  425. },
  426. {
  427. enabled: true,
  428. regex: false,
  429. flags: '',
  430. name: 'Blacklist 4',
  431. url: ['zalo.me', 'skrill.com']
  432. }
  433. ],
  434. engines: [
  435. {
  436. enabled: true,
  437. name: 'greasyfork',
  438. url: 'https://greatest.deepsurf.us'
  439. },
  440. {
  441. enabled: true,
  442. name: 'sleazyfork',
  443. url: 'https://sleazyfork.org'
  444. },
  445. {
  446. enabled: false,
  447. name: 'openuserjs',
  448. url: 'https://openuserjs.org/?q='
  449. },
  450. {
  451. enabled: false,
  452. name: 'github',
  453. url: 'https://api.github.com/search/code?q=',
  454. token: ''
  455. }
  456. ],
  457. recommend: {
  458. author: true,
  459. others: true,
  460. }
  461. };
  462. /**
  463. * Add Event Listener
  464. * @template { HTMLElement } E
  465. * @template { keyof HTMLElementEventMap } K
  466. * @param { E } el
  467. * @param { K } event
  468. * @param { (this: E, ev: HTMLElementEventMap[K]) => any } callback
  469. * @param { boolean | AddEventListenerOptions } options
  470. */
  471. const ael = (el, event, callback, options = {}) => {
  472. try {
  473. for (const elem of normalizeTarget(el)) {
  474. if (!elem) {
  475. continue;
  476. }
  477. if (isMobile && event === 'click') {
  478. // event = 'mouseup';
  479. elem.addEventListener('touchstart', callback);
  480. // elem.addEventListener('touchend', callback);
  481. return;
  482. }
  483. if (event === 'fclick') {
  484. event = 'click';
  485. }
  486. elem.addEventListener(event, callback, options);
  487. }
  488. } catch (ex) {
  489. err(ex);
  490. }
  491. };
  492. /**
  493. * Prefix for `document.querySelectorAll()`
  494. * @template { Element } E
  495. * @param { string } selectors - Elements for query selection
  496. * @param { E } root - Root selector Element
  497. * @returns { NodeListOf<E> }
  498. */
  499. const qsA = (selectors, root) => {
  500. try {
  501. return (root || document).querySelectorAll(selectors);
  502. } catch (ex) {
  503. err(ex);
  504. }
  505. return [];
  506. };
  507. /**
  508. * Prefix for `document.querySelector()`
  509. * @template { Element } E
  510. * @param { string } selector - Element for query selection
  511. * @param { E } root - Root selector Element
  512. * @returns { E | null }
  513. */
  514. const qs = (selector, root) => {
  515. try {
  516. return (root || document).querySelector(selector);
  517. } catch (ex) {
  518. err(ex);
  519. }
  520. return null;
  521. };
  522. /**
  523. * Prefix for `document.querySelector()` w/ Promise
  524. * @template { Element } E
  525. * @param { string } selector - Element for query selection
  526. * @param { E } root - Root selector Element
  527. * @returns { Promise<E | null> }
  528. */
  529. const query = async (selector, root) => {
  530. let el = null;
  531. try {
  532. el = root || document;
  533. while (isNull(el.querySelector(selector))) {
  534. await Task.requestAFrame();
  535. }
  536. return el.querySelector(selector);
  537. } catch (ex) {
  538. err(ex);
  539. }
  540. return el;
  541. };
  542. /**
  543. * Form Attributes of Element
  544. * @template { keyof HTMLElementTagNameMap } K
  545. * @param { K } elem
  546. * @param { keyof HTMLElement } attr
  547. */
  548. const formAttrs = (elem, attr = {}) => {
  549. for (const key in attr) {
  550. if (typeof attr[key] === 'object') {
  551. formAttrs(elem[key], attr[key]);
  552. } else if (isFN(attr[key])) {
  553. if (key === 'container') {
  554. key();
  555. continue;
  556. }
  557. if (/^on/.test(key)) {
  558. elem[key] = attr[key];
  559. continue;
  560. }
  561. ael(elem, key, attr[key]);
  562. } else if (key === 'class') {
  563. elem.className = attr[key];
  564. } else {
  565. elem[key] = attr[key];
  566. }
  567. }
  568. };
  569. /**
  570. * Make Element
  571. * @template { keyof HTMLElementTagNameMap } K
  572. * @param { K } tagName
  573. * @param { string } cname
  574. * @param { keyof HTMLElement } attrs
  575. * @returns { HTMLElementTagNameMap[K] }
  576. */
  577. const make = (tagName, cname, attrs = {}) => {
  578. let el = null;
  579. try {
  580. el = document.createElement(tagName);
  581. if (typeof cname === 'string' && !isEmpty(cname)) {
  582. el.className = cname;
  583. }
  584. if (!isEmpty(attrs)) {
  585. formAttrs(el, attrs);
  586. }
  587. } catch (ex) {
  588. err(ex);
  589. }
  590. return el;
  591. };
  592. /**
  593. * Inject CSS (Cascading Style Sheet Document) into `document.head`
  594. * @param { string } css - CSS to inject
  595. * @param { string } name - (optional) Name of stylesheet `mph-`
  596. * @param { * } root - (optional) Custom `document.head` path
  597. * @return { HTMLStyleElement | null } Style element
  598. */
  599. const loadCSS = (css, name = 'CSS', root = document) => {
  600. /** @type {Element} */
  601. let el;
  602. try {
  603. if (typeof css !== 'string') {
  604. throw new Error('[loadCSS] "css" must be a typeof "String"');
  605. }
  606. if (typeof name !== 'string') {
  607. throw new Error('[loadCSS] "name" must be a typeof "String"');
  608. }
  609. el = root || document.head;
  610. if (isBlank(css)) {
  611. throw new Error(`[loadCSS] "${name}" contains empty CSS string`);
  612. }
  613. for (const s of normalizeTarget(el.querySelectorAll('style[data-role]'))) {
  614. if (Object.is(s.dataset.role, name)) {
  615. return s;
  616. }
  617. }
  618. const sty = make('style', `mujs-${name}`, {
  619. textContent: css,
  620. dataset: {
  621. insertedBy: 'userscript-plus',
  622. role: name
  623. }
  624. });
  625. if (!isEmpty(el.shadowRoot)) {
  626. el.shadowRoot.appendChild(sty);
  627. } else {
  628. el.appendChild(sty);
  629. }
  630. return sty;
  631. } catch (ex) {
  632. err(ex);
  633. }
  634. return null;
  635. };
  636. const iconSVG = {
  637. cfg: '<svg viewBox="0 0 24 24"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7848 0.449982C13.8239 0.449982 14.7167 1.16546 14.9122 2.15495L14.9991 2.59495C15.3408 4.32442 17.1859 5.35722 18.9016 4.7794L19.3383 4.63233C20.3199 4.30175 21.4054 4.69358 21.9249 5.56605L22.7097 6.88386C23.2293 7.75636 23.0365 8.86366 22.2504 9.52253L21.9008 9.81555C20.5267 10.9672 20.5267 13.0328 21.9008 14.1844L22.2504 14.4774C23.0365 15.1363 23.2293 16.2436 22.7097 17.1161L21.925 18.4339C21.4054 19.3064 20.3199 19.6982 19.3382 19.3676L18.9017 19.2205C17.1859 18.6426 15.3408 19.6754 14.9991 21.405L14.9122 21.845C14.7167 22.8345 13.8239 23.55 12.7848 23.55H11.2152C10.1761 23.55 9.28331 22.8345 9.08781 21.8451L9.00082 21.4048C8.65909 19.6754 6.81395 18.6426 5.09822 19.2205L4.66179 19.3675C3.68016 19.6982 2.59465 19.3063 2.07505 18.4338L1.2903 17.1161C0.770719 16.2436 0.963446 15.1363 1.74956 14.4774L2.09922 14.1844C3.47324 13.0327 3.47324 10.9672 2.09922 9.8156L1.74956 9.52254C0.963446 8.86366 0.77072 7.75638 1.2903 6.8839L2.07508 5.56608C2.59466 4.69359 3.68014 4.30176 4.66176 4.63236L5.09831 4.77939C6.81401 5.35722 8.65909 4.32449 9.00082 2.59506L9.0878 2.15487C9.28331 1.16542 10.176 0.449982 11.2152 0.449982H12.7848ZM12 15.3C13.8225 15.3 15.3 13.8225 15.3 12C15.3 10.1774 13.8225 8.69998 12 8.69998C10.1774 8.69998 8.69997 10.1774 8.69997 12C8.69997 13.8225 10.1774 15.3 12 15.3Z" fill="#ffffff"></path> </g></svg>',
  638. close:
  639. '<svg viewBox="0 0 24 24"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M4.70718 2.58574C4.31666 2.19522 3.68349 2.19522 3.29297 2.58574L2.58586 3.29285C2.19534 3.68337 2.19534 4.31654 2.58586 4.70706L9.87877 12L2.5859 19.2928C2.19537 19.6834 2.19537 20.3165 2.5859 20.7071L3.293 21.4142C3.68353 21.8047 4.31669 21.8047 4.70722 21.4142L12.0001 14.1213L19.293 21.4142C19.6835 21.8047 20.3167 21.8047 20.7072 21.4142L21.4143 20.7071C21.8048 20.3165 21.8048 19.6834 21.4143 19.2928L14.1214 12L21.4143 4.70706C21.8048 4.31654 21.8048 3.68337 21.4143 3.29285L20.7072 2.58574C20.3167 2.19522 19.6835 2.19522 19.293 2.58574L12.0001 9.87865L4.70718 2.58574Z" fill="#ffffff"></path></g></svg>',
  640. filter:
  641. '<svg viewBox="0 0 24 24"><g stroke-width="0"/><g stroke-linecap="round" stroke-linejoin="round"/><g><path d="M4.22657 2C2.50087 2 1.58526 4.03892 2.73175 5.32873L8.99972 12.3802V19C8.99972 19.3788 9.21373 19.725 9.55251 19.8944L13.5525 21.8944C13.8625 22.0494 14.2306 22.0329 14.5255 21.8507C14.8203 21.6684 14.9997 21.3466 14.9997 21V12.3802L21.2677 5.32873C22.4142 4.03893 21.4986 2 19.7729 2H4.22657Z" fill="#ffffff"/> </g></svg>',
  642. fsClose:
  643. '<svg viewBox="0 0 24 24"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M7 9.5C8.38071 9.5 9.5 8.38071 9.5 7V2.5C9.5 1.94772 9.05228 1.5 8.5 1.5H7.5C6.94772 1.5 6.5 1.94772 6.5 2.5V6.5H2.5C1.94772 6.5 1.5 6.94772 1.5 7.5V8.5C1.5 9.05228 1.94772 9.5 2.5 9.5H7Z" fill="#ffffff"></path> <path d="M17 9.5C15.6193 9.5 14.5 8.38071 14.5 7V2.5C14.5 1.94772 14.9477 1.5 15.5 1.5H16.5C17.0523 1.5 17.5 1.94772 17.5 2.5V6.5H21.5C22.0523 6.5 22.5 6.94772 22.5 7.5V8.5C22.5 9.05228 22.0523 9.5 21.5 9.5H17Z" fill="#ffffff"></path> <path d="M17 14.5C15.6193 14.5 14.5 15.6193 14.5 17V21.5C14.5 22.0523 14.9477 22.5 15.5 22.5H16.5C17.0523 22.5 17.5 22.0523 17.5 21.5V17.5H21.5C22.0523 17.5 22.5 17.0523 22.5 16.5V15.5C22.5 14.9477 22.0523 14.5 21.5 14.5H17Z" fill="#ffffff"></path> <path d="M9.5 17C9.5 15.6193 8.38071 14.5 7 14.5H2.5C1.94772 14.5 1.5 14.9477 1.5 15.5V16.5C1.5 17.0523 1.94772 17.5 2.5 17.5H6.5V21.5C6.5 22.0523 6.94772 22.5 7.5 22.5H8.5C9.05228 22.5 9.5 22.0523 9.5 21.5V17Z" fill="#ffffff"></path></g></svg>',
  644. fsOpen:
  645. '<svg viewBox="0 0 24 24"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M4 1.5C2.61929 1.5 1.5 2.61929 1.5 4V8.5C1.5 9.05228 1.94772 9.5 2.5 9.5H3.5C4.05228 9.5 4.5 9.05228 4.5 8.5V4.5H8.5C9.05228 4.5 9.5 4.05228 9.5 3.5V2.5C9.5 1.94772 9.05228 1.5 8.5 1.5H4Z" fill="#ffffff"></path> <path d="M20 1.5C21.3807 1.5 22.5 2.61929 22.5 4V8.5C22.5 9.05228 22.0523 9.5 21.5 9.5H20.5C19.9477 9.5 19.5 9.05228 19.5 8.5V4.5H15.5C14.9477 4.5 14.5 4.05228 14.5 3.5V2.5C14.5 1.94772 14.9477 1.5 15.5 1.5H20Z" fill="#ffffff"></path> <path d="M20 22.5C21.3807 22.5 22.5 21.3807 22.5 20V15.5C22.5 14.9477 22.0523 14.5 21.5 14.5H20.5C19.9477 14.5 19.5 14.9477 19.5 15.5V19.5H15.5C14.9477 19.5 14.5 19.9477 14.5 20.5V21.5C14.5 22.0523 14.9477 22.5 15.5 22.5H20Z" fill="#ffffff"></path> <path d="M1.5 20C1.5 21.3807 2.61929 22.5 4 22.5H8.5C9.05228 22.5 9.5 22.0523 9.5 21.5V20.5C9.5 19.9477 9.05228 19.5 8.5 19.5H4.5V15.5C4.5 14.9477 4.05228 14.5 3.5 14.5H2.5C1.94772 14.5 1.5 14.9477 1.5 15.5V20Z" fill="#ffffff"></path></g></svg>',
  646. fullscreen:
  647. '<svg viewBox="0 0 96 96"><g><path d="M30,0H6A5.9966,5.9966,0,0,0,0,6V30a6,6,0,0,0,12,0V12H30A6,6,0,0,0,30,0Z"/><path d="M90,0H66a6,6,0,0,0,0,12H84V30a6,6,0,0,0,12,0V6A5.9966,5.9966,0,0,0,90,0Z"/><path d="M30,84H12V66A6,6,0,0,0,0,66V90a5.9966,5.9966,0,0,0,6,6H30a6,6,0,0,0,0-12Z"/><path d="M90,60a5.9966,5.9966,0,0,0-6,6V84H66a6,6,0,0,0,0,12H90a5.9966,5.9966,0,0,0,6-6V66A5.9966,5.9966,0,0,0,90,60Z"/></g></svg>',
  648. gf: '<svg viewBox="0 0 510.4 510.4"><g><path d="M505.2,80c-6.4-6.4-16-6.4-22.4,0l-89.6,89.6c-1.6,1.6-6.4,3.2-12.8,1.6c-4.8-1.6-9.6-3.2-14.4-6.4L468.4,62.4 c6.4-6.4,6.4-16,0-22.4c-6.4-6.4-16-6.4-22.4,0L343.6,142.4c-3.2-4.8-4.8-9.6-4.8-12.8c-1.6-6.4-1.6-11.2,1.6-12.8L430,27.2 c6.4-6.4,6.4-16,0-22.4c-6.4-6.4-16-6.4-22.4,0L290.8,121.6c-16,16-20.8,40-14.4,62.4l-264,256c-16,16-16,43.2,0,59.2 c6.4,6.4,16,11.2,27.2,11.2c11.2,0,22.4-4.8,30.4-12.8L319.6,232c8,3.2,16,4.8,24,4.8c16,0,32-6.4,44.8-17.6l116.8-116.8 C511.6,96,511.6,86.4,505.2,80z M46,475.2c-3.2,3.2-9.6,3.2-14.4,0c-3.2-3.2-3.2-9.6,1.6-12.8l257.6-249.6c0,0,1.6,1.6,1.6,3.2 L46,475.2z M316.4,192c-14.4-14.4-16-35.2-4.8-48c4.8,11.2,11.2,22.4,20.8,32c9.6,9.6,20.8,16,32,20.8 C351.6,208,329.2,206.4,316.4,192z"/></g></svg>',
  649. gh: '<svg viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>',
  650. hide: '<svg viewBox="0 0 24 24"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g> <path fill-rule="evenodd" clip-rule="evenodd" d="M2 11.5C2 10.9477 2.44772 10.5 3 10.5L21 10.5C21.5523 10.5 22 10.9477 22 11.5V12.5C22 13.0523 21.5523 13.5 21 13.5H3C2.44772 13.5 2 13.0523 2 12.5V11.5Z" fill="#ffffff"></path></g></svg>',
  651. install:
  652. '<svg viewBox="0 0 16 16"><g><path d="M8.75 1.75a.75.75 0 00-1.5 0v6.59L5.3 6.24a.75.75 0 10-1.1 1.02L7.45 10.76a.78.78 0 00.038.038.748.748 0 001.063-.037l3.25-3.5a.75.75 0 10-1.1-1.02l-1.95 2.1V1.75z"/><path d="M1.75 9a.75.75 0 01.75.75v3c0 .414.336.75.75.75h9.5a.75.75 0 00.75-.75v-3a.75.75 0 011.5 0v3A2.25 2.25 0 0112.75 15h-9.5A2.25 2.25 0 011 12.75v-3A.75.75 0 011.75 9z"/></g></svg>',
  653. issue:
  654. '<svg viewBox="0 0 24 24"><path fill="none" stroke="#ffff" stroke-width="2" d="M23,20 C21.62,17.91 20,17 19,17 M5,17 C4,17 2.38,17.91 1,20 M19,9 C22,9 23,6 23,6 M1,6 C1,6 2,9 5,9 M19,13 L24,13 L19,13 Z M5,13 L0,13 L5,13 Z M12,23 L12,12 L12,23 L12,23 Z M12,23 C8,22.9999998 5,20.0000002 5,16 L5,9 C5,9 8,6.988 12,7 C16,7.012 19,9 19,9 C19,9 19,11.9999998 19,16 C19,20.0000002 16,23.0000002 12,23 L12,23 Z M7,8 L7,6 C7,3.24 9.24,1 12,1 C14.76,1 17,3.24 17,6 L17,8"/></svg>',
  655. nav: '<svg viewBox="0 0 24 24"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path d="M2 5.5C2 4.94772 2.44772 4.5 3 4.5H21C21.5523 4.5 22 4.94772 22 5.5V6.5C22 7.05228 21.5523 7.5 21 7.5H3C2.44772 7.5 2 7.05228 2 6.5V5.5Z" fill="#ffffff"></path> <path d="M2 11.5C2 10.9477 2.44772 10.5 3 10.5H21C21.5523 10.5 22 10.9477 22 11.5V12.5C22 13.0523 21.5523 13.5 21 13.5H3C2.44772 13.5 2 13.0523 2 12.5V11.5Z" fill="#ffffff"></path> <path d="M3 16.5C2.44772 16.5 2 16.9477 2 17.5V18.5C2 19.0523 2.44772 19.5 3 19.5H21C21.5523 19.5 22 19.0523 22 18.5V17.5C22 16.9477 21.5523 16.5 21 16.5H3Z" fill="#ffffff"></path> </g></svg>',
  656. verified:
  657. '<svg fill="currentColor" stroke="currentColor" viewBox="0 0 56 56"><g stroke-width="0"/><g stroke-linecap="round" stroke-linejoin="round"/><g><path d="M 23.6641 52.3985 C 26.6407 55.375 29.3594 55.3516 32.3126 52.3985 L 35.9219 48.8125 C 36.2969 48.4610 36.6250 48.3203 37.1172 48.3203 L 42.1797 48.3203 C 46.3749 48.3203 48.3204 46.3985 48.3204 42.1797 L 48.3204 37.1172 C 48.3204 36.625 48.4610 36.2969 48.8124 35.9219 L 52.3749 32.3125 C 55.3749 29.3594 55.3514 26.6407 52.3749 23.6641 L 48.8124 20.0547 C 48.4610 19.7031 48.3204 19.3516 48.3204 18.8829 L 48.3204 13.7969 C 48.3204 9.625 46.3985 7.6563 42.1797 7.6563 L 37.1172 7.6563 C 36.6250 7.6563 36.2969 7.5391 35.9219 7.1875 L 32.3126 3.6016 C 29.3594 .6250 26.6407 .6485 23.6641 3.6016 L 20.0547 7.1875 C 19.7032 7.5391 19.3516 7.6563 18.8828 7.6563 L 13.7969 7.6563 C 9.6016 7.6563 7.6563 9.5782 7.6563 13.7969 L 7.6563 18.8829 C 7.6563 19.3516 7.5391 19.7031 7.1876 20.0547 L 3.6016 23.6641 C .6251 26.6407 .6485 29.3594 3.6016 32.3125 L 7.1876 35.9219 C 7.5391 36.2969 7.6563 36.625 7.6563 37.1172 L 7.6563 42.1797 C 7.6563 46.3750 9.6016 48.3203 13.7969 48.3203 L 18.8828 48.3203 C 19.3516 48.3203 19.7032 48.4610 20.0547 48.8125 Z M 26.2891 49.7734 L 21.8828 45.3438 C 21.3672 44.8047 20.8282 44.5938 20.1016 44.5938 L 13.7969 44.5938 C 11.7110 44.5938 11.3828 44.2656 11.3828 42.1797 L 11.3828 35.875 C 11.3828 35.1719 11.1719 34.6329 10.6563 34.1172 L 6.2266 29.7109 C 4.7501 28.2109 4.7501 27.7891 6.2266 26.2891 L 10.6563 21.8829 C 11.1719 21.3672 11.3828 20.8282 11.3828 20.1016 L 11.3828 13.7969 C 11.3828 11.6875 11.6876 11.3829 13.7969 11.3829 L 20.1016 11.3829 C 20.8282 11.3829 21.3672 11.1953 21.8828 10.6563 L 26.2891 6.2266 C 27.7891 4.7500 28.2110 4.7500 29.7110 6.2266 L 34.1172 10.6563 C 34.6328 11.1953 35.1719 11.3829 35.8750 11.3829 L 42.1797 11.3829 C 44.2657 11.3829 44.5938 11.7109 44.5938 13.7969 L 44.5938 20.1016 C 44.5938 20.8282 44.8282 21.3672 45.3439 21.8829 L 49.7733 26.2891 C 51.2498 27.7891 51.2498 28.2109 49.7733 29.7109 L 45.3439 34.1172 C 44.8282 34.6329 44.5938 35.1719 44.5938 35.875 L 44.5938 42.1797 C 44.5938 44.2656 44.2657 44.5938 42.1797 44.5938 L 35.8750 44.5938 C 35.1719 44.5938 34.6328 44.8047 34.1172 45.3438 L 29.7110 49.7734 C 28.2110 51.2500 27.7891 51.2500 26.2891 49.7734 Z M 24.3438 39.2266 C 25.0235 39.2266 25.5391 38.9453 25.8907 38.5234 L 38.8985 20.3360 C 39.1563 19.9609 39.2969 19.5391 39.2969 19.1407 C 39.2969 18.1094 38.5001 17.2891 37.4219 17.2891 C 36.6485 17.2891 36.2266 17.5469 35.7579 18.2266 L 24.2735 34.3985 L 18.3438 27.8594 C 17.9454 27.4141 17.5001 27.2266 16.9141 27.2266 C 15.7657 27.2266 14.9454 28.0000 14.9454 29.0782 C 14.9454 29.5469 15.1094 29.9922 15.4376 30.3203 L 22.8907 38.6172 C 23.2423 38.9922 23.6876 39.2266 24.3438 39.2266 Z"/></g></svg>',
  658. search:
  659. '<svg viewBox="0 0 24 24"><g stroke-width="0"/><g stroke-linecap="round" stroke-linejoin="round"/><g><path fill-rule="evenodd" clip-rule="evenodd" d="M10 0.5C4.75329 0.5 0.5 4.75329 0.5 10C0.5 15.2467 4.75329 19.5 10 19.5C12.082 19.5 14.0076 18.8302 15.5731 17.6944L20.2929 22.4142C20.6834 22.8047 21.3166 22.8047 21.7071 22.4142L22.4142 21.7071C22.8047 21.3166 22.8047 20.6834 22.4142 20.2929L17.6944 15.5731C18.8302 14.0076 19.5 12.082 19.5 10C19.5 4.75329 15.2467 0.5 10 0.5ZM3.5 10C3.5 6.41015 6.41015 3.5 10 3.5C13.5899 3.5 16.5 6.41015 16.5 10C16.5 13.5899 13.5899 16.5 10 16.5C6.41015 16.5 3.5 13.5899 3.5 10Z" fill="currentColor"/> </g></svg>'
  660. };
  661. const Timeout = class {
  662. constructor() {
  663. this.ids = [];
  664. }
  665.  
  666. set(delay, reason) {
  667. return new Promise((resolve, reject) => {
  668. const id = setTimeout(() => {
  669. isNull(reason) ? resolve() : reject(reason);
  670. this.clear(id);
  671. }, delay);
  672. this.ids.push(id);
  673. });
  674. }
  675.  
  676. clear(...ids) {
  677. this.ids = this.ids.filter((id) => {
  678. if (ids.includes(id)) {
  679. clearTimeout(id);
  680. return false;
  681. }
  682. return true;
  683. });
  684. }
  685. };
  686. /**
  687. * @template { string } S
  688. * @param { S } str
  689. * @param { boolean } lowerCase
  690. * @returns { S }
  691. */
  692. const bscStr = (str = '', lowerCase = true) => {
  693. const txt = str[lowerCase ? 'toLowerCase' : 'toUpperCase']();
  694. return txt.replaceAll(/\W/g, '');
  695. };
  696. const Network = {
  697. /**
  698. * Fetch a URL with fetch API as fallback
  699. *
  700. * When GM is supported, makes a request like XMLHttpRequest, with some special capabilities, not restricted by same-origin policy
  701. * @link https://violentmonkey.github.io/api/gm/#gm_xmlhttprequest
  702. * @link https://developer.mozilla.org/docs/Web/API/Fetch_API
  703. * @param { RequestInfo | URL } url - The URL to fetch
  704. * @param { GM.Request['method'] | Request['method'] } method - Fetch method
  705. * @param { GM.Request['responseType'] | 'buffer' | 'json' | 'text' | 'blob' | 'document' } responseType - Response type
  706. * @param { RequestInit | GM.Request | XMLHttpRequest } data - Fetch parameters
  707. * @param { boolean } useFetch
  708. * @returns { Promise<Response> } Fetch results
  709. */
  710. async req(url, method = 'GET', responseType = 'json', data = {}, useFetch = false) {
  711. try {
  712. if (isEmpty(url)) {
  713. throw new Error('"url" parameter is empty');
  714. }
  715. method = bscStr(method, false);
  716. responseType = bscStr(responseType);
  717. const params = {
  718. method,
  719. ...data
  720. };
  721. if (Supports.gm && !useFetch) {
  722. if (params.credentials) {
  723. Object.assign(params, {
  724. anonymous: false
  725. });
  726. if (Object.is(params.credentials, 'omit')) {
  727. Object.assign(params, {
  728. anonymous: true
  729. });
  730. }
  731. delete params.credentials;
  732. }
  733. } else if (params.onprogress) {
  734. delete params.onprogress;
  735. }
  736. return await new Promise((resolve, reject) => {
  737. /**
  738. * @param { Response } response
  739. * @returns { Response | Document }
  740. */
  741. const fetchResp = (response_1) => {
  742. if (!response_1.ok) reject(response_1);
  743. const check = (str_2 = 'text') => {
  744. return isFN(response_1[str_2]) ? response_1[str_2]() : response_1;
  745. };
  746. if (responseType.match(/buffer/i)) {
  747. resolve(check('arrayBuffer'));
  748. } else if (responseType.match(/json/i)) {
  749. resolve(check('json'));
  750. } else if (responseType.match(/text/i)) {
  751. resolve(check('text'));
  752. } else if (responseType.match(/blob/i)) {
  753. resolve(check('blob'));
  754. } else if (responseType.match(/formdata/i)) {
  755. resolve(check('formData'));
  756. } else if (responseType.match(/clone/i)) {
  757. resolve(check('clone'));
  758. } else if (responseType.match(/document/i) && isFN(response_1.text)) {
  759. const domParser = new DOMParser();
  760. const respTxt = response_1.text();
  761. if (respTxt instanceof Promise) {
  762. respTxt.then((txt) => {
  763. const doc = domParser.parseFromString(txt, 'text/html');
  764. resolve(doc);
  765. });
  766. } else {
  767. const doc = domParser.parseFromString(respTxt, 'text/html');
  768. resolve(doc);
  769. }
  770. } else {
  771. resolve(response_1);
  772. }
  773. };
  774. if (responseType.match(/buffer/i)) {
  775. fetch(url, params).then(fetchResp).catch(reject);
  776. } else if (Supports.gm && !useFetch) {
  777. Network.xmlRequest({
  778. url,
  779. responseType,
  780. ...params,
  781. onerror: reject,
  782. onload: (r_1) => {
  783. if (r_1.status !== 200) reject(new Error(`${r_1.status} ${url}`));
  784. if (responseType.match(/basic/i)) resolve(r_1);
  785. resolve(r_1.response);
  786. }
  787. });
  788. } else {
  789. fetch(url, params).then(fetchResp).catch(reject);
  790. }
  791. });
  792. } catch (ex) {
  793. return err(ex);
  794. }
  795. },
  796. format(bytes, decimals = 2) {
  797. if (Number.isNaN(bytes)) return '0 Bytes';
  798. const k = 1024;
  799. const dm = decimals < 0 ? 0 : decimals;
  800. const i = Math.floor(Math.log(bytes) / Math.log(k));
  801. return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${Network.sizes[i]}`;
  802. },
  803. prog(evt) {
  804. return Object.is(evt.total, 0)
  805. ? Network.format(evt.loaded)
  806. : `${+((evt.loaded / evt.total) * 100).toFixed(2)}%`;
  807. },
  808. sizes: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  809. /**
  810. * @param { GM.Request } details
  811. * @returns { Promise<void> }
  812. */
  813. xmlRequest(details) {
  814. if (Supports.gm) {
  815. return GM.xmlHttpRequest(details);
  816. }
  817. try {
  818. return new Promise((resolve, reject) => {
  819. const req = new XMLHttpRequest();
  820. let method = 'GET';
  821. let url = 'about:blank';
  822. let body;
  823. for (const [key, value] of Object.entries(details)) {
  824. if (key === 'onload') {
  825. req.addEventListener('load', () => {
  826. if (isFN(value)) {
  827. value(req);
  828. }
  829. resolve(req);
  830. });
  831. } else if (key === 'onerror') {
  832. req.addEventListener('error', (evt) => {
  833. if (isFN(value)) {
  834. value(evt);
  835. }
  836. reject(evt);
  837. });
  838. } else if (key === 'onabort') {
  839. req.addEventListener('abort', (evt) => {
  840. if (isFN(value)) {
  841. value(evt);
  842. }
  843. reject(evt);
  844. });
  845. } else if (key === 'onprogress') {
  846. req.addEventListener('progress', value);
  847. } else if (key === 'responseType') {
  848. if (value.match(/buffer|blob|document|json|text/i)) {
  849. if (value.match(/buffer/i)) {
  850. req.responseType = 'arraybuffer';
  851. } else {
  852. req.responseType = value;
  853. }
  854. }
  855. } else if (key === 'method') {
  856. method = value;
  857. } else if (key === 'url') {
  858. url = value;
  859. } else if (key === 'body') {
  860. body = value;
  861. }
  862. }
  863. req.open(method, url);
  864.  
  865. if (isEmpty(req.responseType)) {
  866. req.responseType = 'text';
  867. }
  868.  
  869. if (body) {
  870. req.send(body);
  871. } else {
  872. req.send();
  873. }
  874. });
  875. } catch (ex) {
  876. err(ex);
  877. }
  878. }
  879. };
  880. /**
  881. * Get info of script
  882. * @returns { GM["info"] } Script info
  883. * @link https://violentmonkey.github.io/api/gm/#gm_info
  884. */
  885. MU.info = Supports.gm
  886. ? isFN(GM.info)
  887. ? GM.info
  888. : GM_info
  889. : {
  890. script: {
  891. icon: '',
  892. name: 'Magic Userscript+',
  893. namespace: 'https://github.com/magicoflolis/Userscript-Plus',
  894. updateURL: 'https://github.com/magicoflolis/Userscript-Plus/releases',
  895. version: 'Bookmarklet'
  896. }
  897. };
  898.  
  899. MU.tab = {
  900. /**
  901. * Open a new window
  902. * @param { string } url - URL of webpage to open
  903. * @param { object } params - GM parameters
  904. * @returns { WindowProxy | null | void } `GM.openInTab` or `GM_openInTab` with `window.open` as a fallback
  905. * @link https://violentmonkey.github.io/api/gm/#gm_openintab
  906. * @link https://developer.mozilla.org/docs/Web/API/Window/open
  907. */
  908. open(
  909. url,
  910. params = {
  911. active: true,
  912. insert: true
  913. },
  914. features
  915. ) {
  916. if (!Supports.gm && isBlank(params)) {
  917. params = '_blank';
  918. }
  919. if (features) {
  920. return window.open(url, params, features);
  921. }
  922. if (Supports.gm) {
  923. return isFN(GM.openInTab) ? GM.openInTab(url, params) : GM_openInTab(url, params);
  924. }
  925. return window.open(url, params);
  926. }
  927. };
  928. MU.storage = {
  929. getItem(key) {
  930. return window.localStorage.getItem(key);
  931. },
  932. has(key) {
  933. return !isNull(this.getItem(key));
  934. },
  935. setItem(key, value) {
  936. window.localStorage.setItem(key, value);
  937. },
  938. remove(key) {
  939. window.localStorage.removeItem(key);
  940. },
  941. /**
  942. * Set value - Saves key to either GM managed storage or `window.localStorage`
  943. * @param { string } key - Key to set the value of
  944. * @param { object } v - Value of key
  945. * @link https://violentmonkey.github.io/api/gm/#gm_setvalue
  946. * @link https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
  947. */
  948. async setValue(key, v) {
  949. v = typeof v === 'string' ? v : JSON.stringify(v ?? {});
  950. if (Supports.gm) {
  951. let GMType;
  952. if (isFN(GM.setValue)) {
  953. GMType = GM.setValue(key, v);
  954. } else {
  955. GMType = Promise.resolve(GM_setValue(key, v));
  956. }
  957. await GMType;
  958. } else {
  959. this.setItem(`MUJS-${key}`, v);
  960. }
  961. },
  962. /**
  963. * Get Value
  964. * @link https://violentmonkey.github.io/api/gm/#gm_getvalue
  965. * @link https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
  966. */
  967. async getValue(key, def = {}) {
  968. try {
  969. if (Supports.gm) {
  970. let GMType;
  971. if (isFN(GM.getValue)) {
  972. GMType = await GM.getValue(key, JSON.stringify(def));
  973. } else {
  974. GMType = GM_getValue(key, JSON.stringify(def));
  975. }
  976. return JSON.parse(GMType);
  977. }
  978. return this.has(`MUJS-${key}`) ? JSON.parse(this.getItem(`MUJS-${key}`)) : def;
  979. } catch (ex) {
  980. err(ex);
  981. }
  982. }
  983. };
  984. const Container = class {
  985. constructor() {
  986. this.remove = this.remove.bind(this);
  987. this.onFrameLoad = this.onFrameLoad.bind(this);
  988. this.ready = false;
  989. this.supported = isFN(document.createElement('main-userjs').attachShadow);
  990. if (this.supported) {
  991. this.frame = make('main-userjs', '', {
  992. dataset: {
  993. insertedBy: 'userscript-plus',
  994. role: 'primary-container'
  995. }
  996. });
  997. /**
  998. * @type { ShadowRoot }
  999. */
  1000. this.root = this.frame.attachShadow({ mode: 'open' });
  1001. this.ready = true;
  1002. } else {
  1003. this.frame = make('iframe', 'mujs-iframe', {
  1004. dataset: {
  1005. insertedBy: 'userscript-plus',
  1006. role: 'primary-iframe'
  1007. },
  1008. loading: 'lazy',
  1009. src: 'about:blank',
  1010. style:
  1011. 'position: fixed;bottom: 1rem;right: 1rem;height: 525px;width: 90%;margin: 0px 1rem;z-index: 100000000000000020 !important;',
  1012. onload: this.onFrameLoad
  1013. });
  1014. }
  1015. ael(window.self, 'beforeunload', this.remove);
  1016. // dbg('Container:', this);
  1017. }
  1018. /**
  1019. * @param { Function } callback
  1020. * @param { document } doc
  1021. */
  1022. async inject(callback, doc) {
  1023. if (!doc) {
  1024. return;
  1025. }
  1026. while (this.ready === false) {
  1027. await Task.requestAFrame();
  1028. }
  1029.  
  1030. doc.documentElement.appendChild(this.frame);
  1031.  
  1032. if (isFN(callback)) {
  1033. callback.call({}, this.root);
  1034. }
  1035. }
  1036.  
  1037. remove() {
  1038. this.frame.remove();
  1039. }
  1040.  
  1041. onFrameLoad(iFrame) {
  1042. /**
  1043. * @type { HTMLIFrameElement }
  1044. */
  1045. const target = iFrame.target;
  1046. this.root = target.contentDocument.documentElement;
  1047. this.ready = true;
  1048.  
  1049. dom.cl.add([this.root, target.contentDocument.body], 'mujs-iframe');
  1050. // this.root.classList.add('mujs-iframe');
  1051. // target.contentDocument.body.classList.add('mujs-iframe');
  1052. }
  1053. };
  1054. const container = new Container();
  1055. const sleazyRedirect = () => {
  1056. if (!/greasyfork\.org/.test(window.location.hostname) && cfg.sleazyredirect) {
  1057. return;
  1058. }
  1059. const otherSite = /greasyfork\.org/.test(window.location.hostname) ? 'sleazyfork' : 'greasyfork';
  1060. qs('span.sign-in-link')
  1061. ? /scripts\/\d+/.test(window.location.href)
  1062. ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a'))
  1063. ? window.location.assign(
  1064. window.location.href.replace(
  1065. /\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/,
  1066. '//$1' + otherSite + '.org'
  1067. )
  1068. )
  1069. : false
  1070. : false
  1071. : false;
  1072. };
  1073. const primaryFN = (injCon) => {
  1074. try {
  1075. //#region Static Elements
  1076. const mujsRoot = make('mujs-root');
  1077. const injectedCore = loadCSS(main_css, 'primary-stylesheet', mujsRoot);
  1078. if (!injectedCore) {
  1079. throw new Error('Failed to initialize script!', { cause: 'loadCSS' });
  1080. }
  1081.  
  1082. if (navigator.languages.length > 0) {
  1083. for (const nlang of navigator.languages) {
  1084. const lg = nlang.split('-')[0];
  1085. if (alang.indexOf(lg) === -1) {
  1086. alang.push(lg);
  1087. }
  1088. }
  1089. }
  1090. if (!alang.includes(Language.navLang)) {
  1091. alang.push(Language.navLang);
  1092. }
  1093.  
  1094. const table = make('table');
  1095. const tabbody = make('tbody');
  1096. const tabhead = make('thead');
  1097. const mouseTimeout = new Timeout();
  1098. const main = make('mu-js', 'main hidden', {
  1099. onmouseenter(evt) {
  1100. evt.preventDefault();
  1101. evt.stopPropagation();
  1102. evt.target.style.opacity = '1';
  1103. mouseTimeout.clear(...mouseTimeout.ids);
  1104. },
  1105. onmouseleave: async (evt) => {
  1106. evt.preventDefault();
  1107. evt.stopPropagation();
  1108. const target = evt.target;
  1109. await mouseTimeout.set(2500);
  1110. target.style.opacity = '0.15';
  1111. },
  1112. click(evt) {
  1113. try {
  1114. /** @type { Element } */
  1115. const target = evt.target.closest('[data-command]');
  1116. if (!target) {
  1117. return;
  1118. }
  1119. const dataset = target.dataset;
  1120. const cmd = dataset.command;
  1121. if (cmd === 'open-tab' && dataset.webpage) {
  1122. MU.tab.open(dataset.webpage);
  1123. } else if (cmd === 'navigation') {
  1124. if (dom.cl.has(btngreasy, 'hidden')) {
  1125. dom.cl.remove([btngreasy, btnhome, btnissue], 'hidden');
  1126. } else {
  1127. dom.cl.add([btngreasy, btnhome, btnissue], 'hidden');
  1128. }
  1129. } else if (cmd === 'list-description') {
  1130. const arr = [];
  1131. const ignoreTags = new Set(['TD', 'MUJS-A', 'MU-JS']);
  1132. for (const node of target.parentElement.childNodes) {
  1133. if (ignoreTags.has(node.tagName)) {
  1134. continue;
  1135. }
  1136. arr.push(node);
  1137. }
  1138. if (target.nextElementSibling) {
  1139. arr.push(target.nextElementSibling);
  1140. if (target.nextElementSibling.nextElementSibling) {
  1141. arr.push(target.nextElementSibling.nextElementSibling);
  1142. }
  1143. }
  1144. if (dom.cl.has(arr, 'hidden')) {
  1145. dom.cl.remove(arr, 'hidden');
  1146. } else {
  1147. dom.cl.add(arr, 'hidden');
  1148. }
  1149. } else if (cmd === 'close') {
  1150. container.remove();
  1151. } else if (cmd === 'show-search') {
  1152. dom.cl.toggle(ssearch, 'hidden');
  1153. } else if (cmd === 'show-filter') {
  1154. dom.cl.toggle(fsearch, 'hidden');
  1155. } else if (cmd === 'fullscreen') {
  1156. if (dom.cl.has(btnfullscreen, 'expanded')) {
  1157. dom.cl.remove([btnfullscreen, main], 'expanded');
  1158. dom.prop(btnfullscreen, 'innerHTML', iconSVG.fsOpen);
  1159. } else {
  1160. dom.cl.add([btnfullscreen, main], 'expanded');
  1161. dom.prop(btnfullscreen, 'innerHTML', iconSVG.fsClose);
  1162. }
  1163. } else if (cmd === 'hide-list') {
  1164. dom.cl.add(main, 'hidden');
  1165. dom.cl.remove(mainframe, 'hidden');
  1166. timeoutFrame();
  1167. } else if (cmd === 'save') {
  1168. if (sh('.saveerror')) {
  1169. sh('.saveerror').remove();
  1170. }
  1171. if (!isNull(legacyMsg)) {
  1172. legacyMsg = null;
  1173. MUJS.rebuild = true;
  1174. dom.prop(rateContainer, 'innerHTML', '');
  1175. // rateContainer.innerHTML = '';
  1176. }
  1177. if (!dom.prop(target, 'disabled')) {
  1178. MUJS.save();
  1179. sleazyRedirect();
  1180. if (MUJS.rebuild) {
  1181. MUJS.cache.clear();
  1182. buildlist();
  1183. }
  1184. MUJS.unsaved = false;
  1185. MUJS.rebuild = false;
  1186. }
  1187. } else if (cmd === 'reset') {
  1188. cfg = defcfg;
  1189. MUJS.unsaved = true;
  1190. dom.prop(
  1191. qs('.tarea', target.parentElement.parentElement),
  1192. 'value',
  1193. JSON.stringify(cfg.blacklist, null, ' ')
  1194. );
  1195. for (const i of cfg.engines) {
  1196. if (sh(`mu-js.mujs-inlab > [data-name="${i.name}"]`)) {
  1197. sh(`mu-js.mujs-inlab > [data-name="${i.name}"]`).checked = i.enabled;
  1198. }
  1199. // if (sh(`mu-js.mujs-inlab > [id="${i.name}"]`)) {
  1200. // sh(`mu-js.mujs-inlab > [id="${i.name}"]`).checked = i.enabled;
  1201. // }
  1202. }
  1203. for (const i of shA('mu-js.mujs-inlab > input[type="checkbox"]')) {
  1204. if (!i.name.match(/((greasy|sleazy)fork|openuserjs|gi(thub|st))/gi)) {
  1205. i.checked = cfg[i.name];
  1206. }
  1207. }
  1208. } else if (cmd === 'settings') {
  1209. if (MUJS.unsaved && !sh('.saveerror')) {
  1210. const txt = make('mujs-row', 'saveerror', {
  1211. innerHTML: 'Unsaved changes'
  1212. });
  1213. countframe.insertAdjacentHTML('afterend', txt.outerHTML.toString());
  1214. }
  1215. if (dom.cl.has(cfgpage, 'hidden')) {
  1216. dom.cl.remove(cfgpage, 'hidden');
  1217. dom.cl.add(tbody, 'hidden');
  1218. dom.cl.add(main, 'auto-height');
  1219. if (!container.supported) {
  1220. dom.attr(container.frame, 'style', 'height: 100%;');
  1221. }
  1222. } else {
  1223. dom.cl.add(cfgpage, 'hidden');
  1224. dom.cl.remove(tbody, 'hidden');
  1225. dom.cl.remove(main, 'auto-height');
  1226. if (!container.supported) {
  1227. dom.attr(container.frame, 'style', '');
  1228. }
  1229. }
  1230. MUJS.rebuild = false;
  1231. }
  1232. } catch (ex) {
  1233. err(ex);
  1234. }
  1235. }
  1236. });
  1237. const tbody = make('mu-js', 'mujs-body');
  1238. const header = make('mu-js', 'mujs-header-prim');
  1239. const cfgpage = make('mujs-row', 'mujs-cfg hidden');
  1240. const countframe = make('mujs-column');
  1241. const btnframe = make('mujs-column');
  1242. const btnHandles = make('mujs-column', 'btn-handles');
  1243. const gfcounter = make('count-frame', '', {
  1244. title: 'https://greatest.deepsurf.us + https://sleazyfork.org'
  1245. });
  1246. const sfcounter = make('count-frame', '', {
  1247. title: 'https://openuserjs.org'
  1248. });
  1249. const fsearch = make('mujs-btn', 'hidden');
  1250. const ssearch = make('mujs-btn', 'hidden');
  1251. const mainbtn = make('count-frame', 'mainbtn', {
  1252. innerHTML: '0'
  1253. });
  1254. const rateContainer = make('mujs-column', 'rate-container');
  1255. //#endregion
  1256.  
  1257. const template = {
  1258. id: 0,
  1259. bad_ratings: 0,
  1260. good_ratings: 0,
  1261. ok_ratings: 0,
  1262. daily_installs: 0,
  1263. total_installs: 0,
  1264. name: 'NOT FOUND',
  1265. description: 'NOT FOUND',
  1266. version: '0.0.0',
  1267. url: 'about:blank',
  1268. code_url: 'about:blank',
  1269. created_at: Date.now(),
  1270. code_updated_at: Date.now(),
  1271. users: [
  1272. {
  1273. name: '',
  1274. url: ''
  1275. }
  1276. ]
  1277. };
  1278. const ContainerHandler = class {
  1279. constructor() {
  1280. this.showError = this.showError.bind(this);
  1281. this.cleanup = this.cleanup.bind(this);
  1282. this.cache = new Map();
  1283. this.userjsCache = new Map();
  1284. // Unsure if `window.location` would be better
  1285. this.host = location.hostname.split('.').splice(-2).join('.');
  1286. this.site = window.top.document.location.href;
  1287. this.unsaved = false;
  1288. this.isBlacklisted = false;
  1289. this.switchRows = true;
  1290. this.rebuild = false;
  1291. // this.siteujs = [];
  1292. this.forkCount = 0;
  1293. this.customCount = 0;
  1294.  
  1295. ael(window.self, 'beforeunload', this.cleanup);
  1296. }
  1297.  
  1298. checkBlacklist() {
  1299. for (const b of cfg.blacklist.filter((b) => b.enabled)) {
  1300. if (b.regex === true) {
  1301. const reg = new RegExp(b.url, b.flags);
  1302. if (!reg.test(this.site)) continue;
  1303. this.isBlacklisted = true;
  1304. }
  1305. if (Array.isArray(b.url)) {
  1306. for (const c of b.url) {
  1307. if (!this.site.includes(c)) continue;
  1308. this.isBlacklisted = true;
  1309. }
  1310. }
  1311. if (!this.site.includes(b.url)) continue;
  1312. this.isBlacklisted = true;
  1313. }
  1314. if (this.isBlacklisted) {
  1315. this.showError('Blacklisted');
  1316. timeoutFrame();
  1317. }
  1318. return this.isBlacklisted;
  1319. }
  1320.  
  1321. addCustomCnt(cnt) {
  1322. this.customCount += cnt;
  1323. this.updateCounters();
  1324. }
  1325.  
  1326. addForkCnt(cnt) {
  1327. this.forkCount += cnt;
  1328. this.updateCounters();
  1329. }
  1330.  
  1331. updateCounters() {
  1332. dom.prop(sfcounter, 'innerHTML', this.customCount);
  1333. dom.prop(gfcounter, 'innerHTML', this.forkCount);
  1334. dom.prop(mainbtn, 'innerHTML', this.customCount + this.forkCount);
  1335. }
  1336.  
  1337. save() {
  1338. this.unsaved = false;
  1339. MU.storage.setValue('Config', cfg);
  1340. info('Saved:', cfg);
  1341. }
  1342.  
  1343. showError(ex) {
  1344. err(ex);
  1345. const txt = make('mujs-row', 'error', {
  1346. innerHTML: `ERROR: ${typeof ex === 'string' ? ex : `${ex.message} ${ex.stack}`}`
  1347. });
  1348. tbody.prepend(txt);
  1349. }
  1350.  
  1351. refresh() {
  1352. this.forkCount = 0;
  1353. this.customCount = 0;
  1354. this.updateCounters();
  1355. dom.prop([tabbody, rateContainer], 'innerHTML', '');
  1356. if (sh('.error')) {
  1357. sh('.error').remove();
  1358. }
  1359. }
  1360.  
  1361. cleanup() {
  1362. this.cache.clear();
  1363. }
  1364. };
  1365. const MUJS = new ContainerHandler();
  1366. const timeout = new Timeout();
  1367. const timeoutFrame = async () => {
  1368. timeout.clear(...timeout.ids);
  1369. if (dom.cl.has(mainframe, 'hidden')) {
  1370. return;
  1371. }
  1372. if (typeof cfg.time === 'number' && !Number.isNaN(cfg.time)) {
  1373. await timeout.set(MUJS.isBlacklisted ? cfg.time / 2 : cfg.time);
  1374. } else {
  1375. await timeout.set(10000);
  1376. }
  1377. container.remove();
  1378. return timeout.clear(...timeout.ids);
  1379. };
  1380. const sh = (elem) => injCon.querySelector(elem);
  1381. const shA = (elem) => injCon.querySelectorAll(elem);
  1382. const sortRowBy = (cellIndex) => {
  1383. const rows = normalizeTarget(tabbody.rows).sort((tr1, tr2) => {
  1384. const t1cell = tr1.cells[cellIndex];
  1385. const t2cell = tr2.cells[cellIndex];
  1386. const tr1Text = (t1cell.firstElementChild ?? t1cell).textContent;
  1387. const tr2Text = (t2cell.firstElementChild ?? t2cell).textContent;
  1388. const t1pDate = Date.parse(tr1Text);
  1389. const t2pDate = Date.parse(tr2Text);
  1390. if (!isNaN(t1pDate) && !isNaN(t2pDate)) {
  1391. return +new Date(t1pDate) - +new Date(t2pDate);
  1392. }
  1393. if (+tr1Text && +tr2Text) {
  1394. return tr1Text - tr2Text;
  1395. }
  1396. return tr1Text.localeCompare(tr2Text);
  1397. });
  1398. if (MUJS.switchRows) {
  1399. rows.reverse();
  1400. }
  1401. MUJS.switchRows = !MUJS.switchRows;
  1402. tabbody.append(...rows);
  1403. };
  1404. const reqCode = async (obj = {}) => {
  1405. if (obj.code_data) {
  1406. return obj.code_data
  1407. };
  1408. const txt = await Network.req(obj.code_url, 'GET', 'text').catch(MUJS.showError);
  1409. if (typeof txt !== 'string') {
  1410. return;
  1411. }
  1412. if (isNull(txt.match(/\/\/\s@[\w][\s\S]+/g))) {
  1413. return;
  1414. };
  1415. Object.assign(obj, {
  1416. code_data: txt
  1417. });
  1418. return txt;
  1419. };
  1420. const createjs = (ujs, issleazy) => {
  1421. for (const key in template) {
  1422. if (hasOwn(ujs, key)) continue;
  1423. ujs[key] = template[key];
  1424. }
  1425. // Lets not add this UserJS to the list
  1426. if (ujs.id === 421603) {
  1427. return;
  1428. }
  1429. // if (MUJS.userjsCache.has(ujs.id)) {
  1430. // return;
  1431. // }
  1432. // MUJS.userjsCache.set(ujs.id, ujs);
  1433. if (!MUJS.userjsCache.has(ujs.id)) {
  1434. MUJS.userjsCache.set(ujs.id, ujs);
  1435. }
  1436. const eframe = make('td', 'install-btn');
  1437. const uframe = make('td', 'mujs-uframe');
  1438. const fdaily = make('td', 'mujs-list', {
  1439. innerHTML: ujs.daily_installs
  1440. });
  1441. const fupdated = make('td', 'mujs-list', {
  1442. innerHTML: new Intl.DateTimeFormat(navigator.language).format(new Date(ujs.code_updated_at))
  1443. });
  1444. const fname = make('td', 'mujs-name');
  1445. const ftitle = make('mujs-a', 'mujs-homepage', {
  1446. innerHTML: ujs.name,
  1447. title: ujs.url,
  1448. dataset: {
  1449. command: 'open-tab',
  1450. webpage: ujs.url
  1451. }
  1452. });
  1453. const fmore = make('mujs-column', 'mujs-list hidden');
  1454. const fver = make('mu-js', 'mujs-list', {
  1455. innerHTML: `${lang.version}: ${ujs.version}`
  1456. });
  1457. const fcreated = make('mu-js', 'mujs-list', {
  1458. innerHTML: `${lang.created}: ${new Intl.DateTimeFormat(navigator.language).format(
  1459. new Date(ujs.created_at)
  1460. )}`
  1461. });
  1462. const flicense = make('mu-js', 'mujs-list', {
  1463. title: ujs.license ?? 'Not licensed',
  1464. innerHTML: `License: ${ujs.license ?? 'N/A'}`,
  1465. style: 'text-overflow: ellipsis; overflow: hidden; white-space: nowrap; width: fit-content; max-width: 20em;'
  1466. });
  1467. const ftotal = make('mu-js', 'mujs-list', {
  1468. innerHTML: `${lang.total}: ${ujs.total_installs}`
  1469. });
  1470. const fratings = make('mu-js', 'mujs-list', {
  1471. title: lang.rating,
  1472. innerHTML: `${lang.rating}:`
  1473. });
  1474. const fgood = make('mu-js', 'mujs-list mujs-ratings', {
  1475. title: lang.good,
  1476. innerHTML: ujs.good_ratings,
  1477. style:
  1478. 'border-color: rgb(51, 155, 51); background-color: #339b331a; color: rgb(51, 255, 51);'
  1479. });
  1480. const fok = make('mu-js', 'mujs-list mujs-ratings', {
  1481. title: lang.ok,
  1482. innerHTML: ujs.ok_ratings,
  1483. style:
  1484. 'border-color: rgb(155, 155, 0); background-color: #9b9b001a; color: rgb(255, 255, 0);'
  1485. });
  1486. const fbad = make('mu-js', 'mujs-list mujs-ratings', {
  1487. title: lang.bad,
  1488. innerHTML: ujs.bad_ratings,
  1489. style: 'border-color: rgb(155, 0, 0); background-color: #9b33331a; color: rgb(255, 0, 0);'
  1490. });
  1491. const fdesc = make('mu-js', 'mujs-list mujs-pointer', {
  1492. title: ujs.description,
  1493. innerHTML: ujs.description,
  1494. dataset: {
  1495. command: 'list-description'
  1496. }
  1497. });
  1498. const fdwn = make('mu-jsbtn', 'install', {
  1499. innerHTML: `${iconSVG.install} ${lang.install}`,
  1500. title: `${lang.install} "${ujs.name}"`,
  1501. dataset: {
  1502. command: 'open-tab',
  1503. webpage: ujs.code_url
  1504. }
  1505. });
  1506. const fBtns = make('mujs-column', 'mujs-list hidden');
  1507. const dwnCode = make('mu-jsbtn', '', {
  1508. innerHTML: `${iconSVG.install} Save File`,
  1509. async onclick(evt) {
  1510. evt.preventDefault();
  1511. try {
  1512. const txt = await reqCode(ujs);
  1513. if (typeof txt !== 'string') {
  1514. return;
  1515. }
  1516. const makeUserJS = new Blob([txt], { type: 'text/plain' });
  1517. const dlBtn = make('a', 'mujs_Downloader');
  1518. dlBtn.href = URL.createObjectURL(makeUserJS);
  1519. dlBtn.download = 'test.user.js';
  1520. dlBtn.click();
  1521. URL.revokeObjectURL(dlBtn.href);
  1522. dlBtn.remove();
  1523. } catch (ex) {
  1524. err(ex);
  1525. }
  1526. }
  1527. });
  1528. const tr = make('tr', 'frame');
  1529. if (issleazy) {
  1530. dom.cl.add(tr, 'sf');
  1531. if (cfg.recommend.others && goodUserJS.includes(ujs.url)) {
  1532. tr.dataset.good = 'upsell';
  1533. }
  1534. }
  1535. for (const u of ujs.users) {
  1536. const user = make('mujs-a', '', {
  1537. innerHTML: u.name,
  1538. title: u.url,
  1539. dataset: {
  1540. command: 'open-tab',
  1541. webpage: u.url
  1542. }
  1543. });
  1544. if (cfg.recommend.author && u.id === authorID) {
  1545. tr.dataset.author = 'upsell';
  1546. dom.prop(user, 'innerHTML', `${u.name} ${iconSVG.verified}`);
  1547. }
  1548. uframe.append(user);
  1549. }
  1550. if (cfg.recommend.others && goodUserJS.includes(ujs.id)) {
  1551. tr.dataset.good = 'upsell';
  1552. }
  1553. eframe.append(fdwn);
  1554. fmore.append(ftotal, fratings, fgood, fok, fbad, fver, fcreated, flicense);
  1555. fBtns.append(dwnCode);
  1556. fname.append(ftitle, fdesc, fmore, fBtns);
  1557.  
  1558. if (ujs.code_data) {
  1559. const codeArea = make('textarea', 'code-area hidden', {
  1560. dataset: {
  1561. name: 'code'
  1562. },
  1563. rows: '10',
  1564. autocomplete: false,
  1565. spellcheck: false,
  1566. wrap: 'soft',
  1567. value: ujs.code_data
  1568. });
  1569. fname.append(codeArea);
  1570. } else {
  1571. const loadCode = make('mu-jsbtn', '', {
  1572. innerHTML: `${iconSVG.search} Preview`,
  1573. async onclick(evt) {
  1574. evt.preventDefault();
  1575. try {
  1576. if (qs('textarea', fname)) {
  1577. return;
  1578. }
  1579. const txt = await reqCode(ujs);
  1580. if (typeof txt !== 'string') {
  1581. return;
  1582. }
  1583. const codeArea = make('textarea', 'code-area', {
  1584. dataset: {
  1585. name: 'code'
  1586. },
  1587. rows: '10',
  1588. autocomplete: false,
  1589. spellcheck: false,
  1590. wrap: 'soft',
  1591. value: txt
  1592. });
  1593. fname.append(codeArea);
  1594. } catch (ex) {
  1595. err(ex)
  1596. }
  1597. }
  1598. });
  1599. fBtns.append(loadCode);
  1600. }
  1601.  
  1602. for (const e of [fname, uframe, fdaily, fupdated, eframe]) {
  1603. tr.append(e);
  1604. }
  1605. tabbody.append(tr);
  1606. };
  1607. //#region Build List
  1608. const buildlist = async (host = undefined) => {
  1609. try {
  1610. if (isEmpty(host)) {
  1611. host = MUJS.host;
  1612. }
  1613. MUJS.refresh();
  1614. if (MUJS.checkBlacklist()) {
  1615. return;
  1616. }
  1617. const engineTemplate = {};
  1618. for (const engine of cfg.engines) {
  1619. engineTemplate[engine.name] = [];
  1620. }
  1621. if (!MUJS.cache.has(host)) {
  1622. MUJS.cache.set(host, engineTemplate);
  1623. }
  1624. const engines = cfg.engines.filter((e) => e.enabled);
  1625. const cache = MUJS.cache.get(host);
  1626. const customRecords = [];
  1627. const rateFN = (data) => {
  1628. try {
  1629. for (const [key, value] of Object.entries(data.resources.code_search)) {
  1630. const txt = make('mujs-row', 'rate-info', {
  1631. innerHTML: `${key.toUpperCase()}: ${value}`
  1632. });
  1633. rateContainer.append(txt);
  1634. }
  1635. } catch (ex) {
  1636. MUJS.showError(ex);
  1637. }
  1638. };
  1639. info('Building list', { cache, MUJS, engines });
  1640. if (!isNull(legacyMsg)) {
  1641. const txt = make('mujs-row', 'legacy-config', {
  1642. innerHTML: legacyMsg
  1643. });
  1644. rateContainer.append(txt);
  1645. return;
  1646. }
  1647. for (const engine of engines) {
  1648. const forkFN = async (data) => {
  1649. if (!data) {
  1650. return;
  1651. }
  1652. const hideData = [];
  1653. const filterLang = data.filter((d) => {
  1654. if (d.deleted) {
  1655. return false;
  1656. }
  1657. if (cfg.filterlang) {
  1658. const dlocal = d.locale.split('-')[0] ?? d.locale;
  1659. if (alang.includes(dlocal)) {
  1660. return true;
  1661. };
  1662. hideData.push(d);
  1663. return false;
  1664. }
  1665. return true;
  1666. });
  1667. let finalList = filterLang;
  1668.  
  1669. const hds = [];
  1670. for (const h of hideData) {
  1671. const txt = await reqCode(h);
  1672. if (typeof txt !== 'string') {
  1673. continue;
  1674. }
  1675. const headers = txt.match(/\/\/\s@[\w][\s\S]+/g); // txt.match(/\/\/\s?==UserScript==([\s\S]*?)\/\/\s?==\/UserScript==/gm);
  1676. if (isNull(headers)) {
  1677. continue;
  1678. };
  1679. for (const lng of alang) {
  1680. const findName = new RegExp(`//\\s*@name:${lng}\\s*(.*)`, 'gi').exec(headers[0]);
  1681. const findDesc = new RegExp(`//\\s*@description:${lng}\\s*(.*)`, 'gi').exec(headers[0]);
  1682. if (!isNull(findName)) {
  1683. Object.assign(h, {
  1684. name: findName[1],
  1685. translated: true
  1686. });
  1687. }
  1688. if (!isNull(findDesc)) {
  1689. Object.assign(h, {
  1690. description: findDesc[1],
  1691. translated: true
  1692. });
  1693. };
  1694. }
  1695. if (h.translated) {
  1696. hds.push(h);
  1697. };
  1698. }
  1699. finalList = [...new Set([...hds, ...filterLang])];
  1700.  
  1701. for (const ujs of finalList) {
  1702. if (cfg.codePreview && !ujs.code_data) {
  1703. await reqCode(ujs);
  1704. };
  1705. createjs(ujs, false);
  1706. }
  1707. cache[engine.name].push(...finalList);
  1708. MUJS.addForkCnt(finalList.length);
  1709. };
  1710. const customFN = async (htmlDocument) => {
  1711. const selected = htmlDocument.documentElement;
  1712. if (qs('.col-sm-8 .tr-link', selected)) {
  1713. // dbg('.col-sm-8 .tr-link', qsA('.col-sm-8 .tr-link', selected));
  1714. for (const i of qsA('.col-sm-8 .tr-link', selected)) {
  1715. await query('.script-version', i);
  1716. const fixurl = dom
  1717. .prop(qs('.tr-link-a', i), 'href')
  1718. .replace(new RegExp(document.location.origin, 'gi'), 'https://openuserjs.org');
  1719. const layout = {
  1720. name: dom.text(qs('.tr-link-a', i)),
  1721. description: dom.text(qs('p', i)),
  1722. version: dom.text(qs('.script-version', i)),
  1723. url: fixurl,
  1724. code_url: `${fixurl.replace(/\/scripts/gi, '/install')}.user.js`,
  1725. total_installs: dom.text(qs('td:nth-child(2) p', i)),
  1726. created_at: dom.attr(qs('td:nth-child(4) time', i), 'datetime'),
  1727. code_updated_at: dom.attr(qs('td:nth-child(4) time', i), 'datetime'),
  1728. users: [
  1729. {
  1730. name: dom.text(qs('.inline-block a', i)),
  1731. url: dom.prop(qs('.inline-block a', i), 'href')
  1732. }
  1733. ]
  1734. };
  1735. createjs(layout, true);
  1736. customRecords.push(layout);
  1737. }
  1738. }
  1739. if (qs('div.gist-snippet', selected)) {
  1740. dbg('div.gist-snippet', qsA('div.gist-snippet', selected));
  1741. for (const g of qsA('div.gist-snippet', selected)) {
  1742. if (qs('span > a:nth-child(2)', g).textContent.includes('.user.js')) {
  1743. const fixurl = qs('span > a:nth-child(2)', g).href.replace(
  1744. new RegExp(document.location.origin, 'gi'),
  1745. 'https://gist.github.com'
  1746. );
  1747. const layout = {};
  1748. Object.assign(layout, {
  1749. url: fixurl,
  1750. code_url: `${fixurl}/raw/${qs('span > a:nth-child(2)', g).textContent}`,
  1751. created_at: qs('time-ago.no-wrap', g).getAttribute('datetime'),
  1752. users: [
  1753. {
  1754. name: qs('span > a[data-hovercard-type]', g).textContent,
  1755. url: qs('span > a[data-hovercard-type]', g).href.replace(
  1756. new RegExp(document.location.origin, 'gi'),
  1757. 'https://gist.github.com'
  1758. )
  1759. }
  1760. ]
  1761. });
  1762. for (const i of qsA('.file-box table tr .blob-code', g)) {
  1763. const headers = dom.text(i).match(/\/\/\s@[\w][\s\S]+/gi) || [];
  1764. if (headers.length > 0) {
  1765. const crop = headers[0].split(
  1766. /\/\/\s@(name|description|author|version)\s+/gi
  1767. );
  1768. if (headers[0].includes('@name') && !headers[0].includes('@namespace')) {
  1769. Object.assign(layout, {
  1770. name: crop[2].trim()
  1771. });
  1772. }
  1773. if (headers[0].includes('@description')) {
  1774. Object.assign(layout, {
  1775. description: crop[2].trim()
  1776. });
  1777. }
  1778. if (headers[0].includes('@version')) {
  1779. Object.assign(layout, {
  1780. version: crop[2].trim()
  1781. });
  1782. }
  1783. }
  1784. }
  1785. createjs(layout, true);
  1786. customRecords.push(layout);
  1787. }
  1788. }
  1789. }
  1790. cache[engine.name].push(...customRecords);
  1791. MUJS.addCustomCnt(customRecords.length);
  1792. };
  1793. const gitFN = async (data) => {
  1794. try {
  1795. if (isBlank(data.items)) return;
  1796. for (const r of data.items) {
  1797. const layout = {
  1798. name: r.name,
  1799. description: isEmpty(r.repository.description)
  1800. ? 'No Description'
  1801. : r.repository.description,
  1802. url: r.html_url,
  1803. code_url: r.html_url.replace(/\/blob\//g, '/raw/'),
  1804. code_updated_at: r.commit || Date.now(),
  1805. total_installs: r.score,
  1806. users: [
  1807. {
  1808. name: r.repository.owner.login,
  1809. url: r.repository.owner.html_url
  1810. }
  1811. ]
  1812. };
  1813. createjs(layout, true);
  1814. customRecords.push(layout);
  1815. }
  1816. cache[engine.name].push(...customRecords);
  1817. MUJS.addCustomCnt(data.items.length);
  1818. } catch (ex) {
  1819. MUJS.showError(ex);
  1820. }
  1821. };
  1822. const eURL = engine.url;
  1823. const cEngine = cache[`${engine.name}`];
  1824. // engine.name.match(/fork/gi)
  1825. if (engine.name.includes('fork')) {
  1826. if (!isEmpty(cEngine)) {
  1827. for (const ujs of cEngine) {
  1828. createjs(ujs, false);
  1829. }
  1830. MUJS.addForkCnt(cEngine.length);
  1831. continue;
  1832. }
  1833.  
  1834. Network.req(`${eURL}/scripts/by-site/${host}.json`).then(forkFN).catch(MUJS.showError);
  1835. } else if (engine.name.match(/(openuserjs|github)/gi)) {
  1836. if (!isEmpty(cEngine)) {
  1837. for (const ujs of cEngine) {
  1838. createjs(ujs, true);
  1839. }
  1840. MUJS.addCustomCnt(cEngine.length);
  1841. continue;
  1842. }
  1843. if (/github/gi.test(engine.name)) {
  1844. Network.req(
  1845. `${eURL}"// ==UserScript=="+${host}+ "// ==/UserScript=="+in:file+language:js&per_page=30`,
  1846. 'GET',
  1847. 'json',
  1848. {
  1849. headers: {
  1850. Accept: 'application/vnd.github+json',
  1851. Authorization: `Bearer ${engine.token}`,
  1852. 'X-GitHub-Api-Version': '2022-11-28'
  1853. }
  1854. }
  1855. )
  1856. .then(gitFN)
  1857. .then(() => {
  1858. Network.req('https://api.github.com/rate_limit', 'GET', 'json', {
  1859. headers: {
  1860. Accept: 'application/vnd.github+json',
  1861. Authorization: `Bearer ${engine.token}`,
  1862. 'X-GitHub-Api-Version': '2022-11-28'
  1863. }
  1864. })
  1865. .then(rateFN)
  1866. .catch(MUJS.showError);
  1867. })
  1868. .catch(MUJS.showError);
  1869. } else {
  1870. Network.req(`${eURL}${host}`, 'GET', 'document').then(customFN).catch(MUJS.showError);
  1871. }
  1872. }
  1873. }
  1874. dbg('listData', MUJS.userjsCache, tabbody.children);
  1875. // sortRowBy(2);
  1876. } catch (ex) {
  1877. MUJS.showError(ex);
  1878. }
  1879. };
  1880. //#endregion
  1881. //#region Make Config
  1882. const makecfg = () => {
  1883. const makerow = (desc = 'Placeholder', type = null, nm = 'Placeholder', attrs = {}) => {
  1884. const sec = make('mujs-section', 'mujs-cfg-section', {
  1885. style: !Supports.gm && nm === 'cache' ? 'display: none;' : ''
  1886. });
  1887. const lb = make('label');
  1888. const divDesc = make('mu-js', 'mujs-cfg-desc', {
  1889. innerHTML: desc
  1890. });
  1891. lb.append(divDesc);
  1892. sec.append(lb);
  1893. cfgpage.append(sec);
  1894. if (isNull(type)) {
  1895. return lb;
  1896. }
  1897. const inp = make(
  1898. 'input',
  1899. 'mujs-cfg-input',
  1900. {
  1901. type,
  1902. dataset: {
  1903. name: nm
  1904. },
  1905. ...attrs
  1906. }
  1907. );
  1908. if (type === 'checkbox') {
  1909. const inlab = make('mu-js', 'mujs-inlab');
  1910. const la = make('label', '', {
  1911. click() {
  1912. inp.dispatchEvent(new MouseEvent('click'));
  1913. }
  1914. });
  1915. inlab.append(inp, la);
  1916. lb.append(inlab);
  1917. if (nm.includes('-')) {
  1918. return inp;
  1919. }
  1920. if (/(greasy|sleazy)fork|openuserjs|gi(thub|st)/gi.test(nm)) {
  1921. for (const i of cfg.engines) {
  1922. if (i.name !== nm) continue;
  1923. inp.checked = i.enabled;
  1924. ael(inp, 'change', (evt) => {
  1925. MUJS.unsaved = true;
  1926. i.enabled = evt.target.checked;
  1927. });
  1928. }
  1929. } else {
  1930. inp.checked = cfg[nm];
  1931. ael(inp, 'change', (evt) => {
  1932. MUJS.unsaved = true;
  1933. if (/filterlang/i.test(nm)) {
  1934. MUJS.rebuild = true;
  1935. }
  1936. cfg[nm] = evt.target.checked;
  1937. });
  1938. }
  1939. } else {
  1940. lb.append(inp);
  1941. }
  1942. return inp;
  1943. };
  1944. makerow('Sync with GM', 'checkbox', 'cache');
  1945. makerow('Auto Fullscreen', 'checkbox', 'autoexpand', {
  1946. onchange(e) {
  1947. if (e.target.checked) {
  1948. dom.cl.add([btnfullscreen, main], 'expanded');
  1949. dom.prop(btnfullscreen, 'innerHTML', iconSVG.fsClose);
  1950. } else {
  1951. dom.cl.remove([btnfullscreen, main], 'expanded');
  1952. dom.prop(btnfullscreen, 'innerHTML', iconSVG.fsOpen);
  1953. }
  1954. }
  1955. });
  1956. makerow(lang.redirect, 'checkbox', 'sleazyredirect');
  1957. makerow(lang.filter, 'checkbox', 'filterlang');
  1958. makerow('Preview code', 'checkbox', 'codePreview');
  1959. for (const inp of [makerow('Recommend author', 'checkbox', 'recommend-author'), makerow('Recommend scripts', 'checkbox', 'recommend-others')]) {
  1960. const nm = inp.dataset.name === 'recommend-author' ? 'author' : 'others';
  1961. inp.checked = cfg.recommend[nm];
  1962. ael(inp, 'change', (evt) => {
  1963. MUJS.unsaved = true;
  1964. cfg.recommend[nm] = evt.target.checked;
  1965. });
  1966. }
  1967. makerow('Greasy Fork', 'checkbox', 'greasyfork');
  1968. makerow('Sleazy Fork', 'checkbox', 'sleazyfork');
  1969. makerow('Open UserJS', 'checkbox', 'openuserjs');
  1970. makerow('GitHub API', 'checkbox', 'github');
  1971. const ghAPI = cfg.engines.find((c) => c.name === 'github');
  1972. makerow('GitHub API (Token)', 'text', 'github', {
  1973. defaultValue: '',
  1974. value: ghAPI.token ?? '',
  1975. placeholder: 'Paste Access Token',
  1976. onchange(evt) {
  1977. MUJS.unsaved = true;
  1978. MUJS.rebuild = true;
  1979. if (isNull(legacyMsg)) {
  1980. ghAPI.token = evt.target.value;
  1981. }
  1982. }
  1983. });
  1984. makerow(`${lang.dtime} (ms)`, 'number', 'time', {
  1985. defaultValue: 10000,
  1986. value: cfg.time,
  1987. min: 0,
  1988. step: 500,
  1989. onbeforeinput(evt) {
  1990. if (evt.target.validity.badInput) {
  1991. dom.cl.add(evt.target, 'mujs-invalid');
  1992. dom.prop(savebtn, 'disabled', true);
  1993. } else {
  1994. dom.cl.remove(evt.target, 'mujs-invalid');
  1995. dom.prop(savebtn, 'disabled', false);
  1996. }
  1997. },
  1998. oninput(evt) {
  1999. MUJS.unsaved = true;
  2000. const t = evt.target;
  2001. if (t.validity.badInput || (t.validity.rangeUnderflow && t.value !== '-1')) {
  2002. dom.cl.add(t, 'mujs-invalid');
  2003. dom.prop(savebtn, 'disabled', true);
  2004. } else {
  2005. dom.cl.remove(t, 'mujs-invalid');
  2006. dom.prop(savebtn, 'disabled', false);
  2007. cfg.time = isEmpty(t.value) ? cfg.time : parseFloat(t.value);
  2008. }
  2009. }
  2010. });
  2011.  
  2012. const cbtn = make('mu-js', 'mujs-sty-flex');
  2013. const savebtn = make('mujs-btn', 'save', {
  2014. dataset: {
  2015. command: 'save'
  2016. },
  2017. disabled: false,
  2018. innerHTML: lang.save
  2019. });
  2020. const resetbtn = make('mujs-btn', 'reset', {
  2021. innerHTML: lang.reset,
  2022. dataset: {
  2023. command: 'reset'
  2024. }
  2025. });
  2026. const txta = make('textarea', 'tarea', {
  2027. dataset: {
  2028. name: 'blacklist'
  2029. },
  2030. rows: '10',
  2031. autocomplete: false,
  2032. spellcheck: false,
  2033. wrap: 'soft',
  2034. value: JSON.stringify(cfg.blacklist, null, ' '),
  2035. oninput(evt) {
  2036. let isvalid = true;
  2037. try {
  2038. cfg.blacklist = JSON.parse(evt.target.value);
  2039. isvalid = true;
  2040. } catch (ex) {
  2041. err(ex);
  2042. isvalid = false;
  2043. } finally {
  2044. if (isvalid) {
  2045. dom.cl.remove(evt.target, 'mujs-invalid');
  2046. dom.prop(savebtn, 'disabled', false);
  2047. } else {
  2048. dom.cl.add(evt.target, 'mujs-invalid');
  2049. dom.prop(savebtn, 'disabled', true);
  2050. }
  2051. }
  2052. }
  2053. });
  2054. cbtn.append(resetbtn, savebtn);
  2055. cfgpage.append(txta, cbtn);
  2056. };
  2057. //#endregion
  2058. const makeTHead = (rows) => {
  2059. const tr = make('tr');
  2060. for (const r of normalizeTarget(rows)) {
  2061. const tparent = make('th', r.class ?? '', r);
  2062. tr.append(tparent);
  2063. }
  2064. tabhead.append(tr);
  2065. table.append(tabhead, tabbody);
  2066. };
  2067.  
  2068. const btnHide = make('mujs-btn', 'hide-list', {
  2069. title: lang.min,
  2070. innerHTML: iconSVG.hide,
  2071. dataset: {
  2072. command: 'hide-list'
  2073. }
  2074. });
  2075. const btnfullscreen = make('mujs-btn', 'fullscreen', {
  2076. title: lang.max,
  2077. innerHTML: iconSVG.fullscreen,
  2078. dataset: {
  2079. command: 'fullscreen'
  2080. }
  2081. });
  2082. const mainframe = make('mu-js', 'mainframe', {
  2083. style: 'opacity: 0.15;',
  2084. onmouseleave(evt) {
  2085. evt.preventDefault();
  2086. evt.stopPropagation();
  2087. evt.target.style.opacity = '0.15';
  2088. timeoutFrame();
  2089. },
  2090. onmouseenter(evt) {
  2091. evt.preventDefault();
  2092. evt.stopPropagation();
  2093. evt.target.style.opacity = '1';
  2094. timeout.clear(...timeout.ids);
  2095. },
  2096. click(e) {
  2097. e.preventDefault();
  2098. timeout.clear(...timeout.ids);
  2099. dom.cl.remove(main, 'hidden');
  2100. dom.cl.add(mainframe, 'hidden');
  2101. if (cfg.autoexpand) {
  2102. dom.cl.add([btnfullscreen, main], 'expanded');
  2103. dom.prop(btnfullscreen, 'innerHTML', iconSVG.fsClose);
  2104. }
  2105. }
  2106. });
  2107. const filterList = make('input', 'mujs-fltlist', {
  2108. autocomplete: 'off',
  2109. spellcheck: false,
  2110. type: 'text',
  2111. placeholder: lang.searcher,
  2112. oninput(evt) {
  2113. evt.preventDefault();
  2114. if (isEmpty(evt.target.value)) {
  2115. dom.cl.remove(shA('tr.frame'), 'hidden');
  2116. // for (const ujs of shA('tr.frame')) {
  2117. // ujs.classList.remove('hidden');
  2118. // }
  2119. return;
  2120. }
  2121. const reg = new RegExp(evt.target.value, 'gi');
  2122. for (const ujs of shA('tr.frame')) {
  2123. const m = ujs.children[0];
  2124. const n = ujs.children[1];
  2125. const final = m.textContent.match(reg) || n.textContent.match(reg) || [];
  2126. final.length === 0 ? dom.cl.add(ujs, 'hidden') : dom.cl.remove(ujs, 'hidden');
  2127. // if (final.length === 0) {
  2128. // ujs.classList.add('hidden');
  2129. // } else {
  2130. // ujs.classList.remove('hidden');
  2131. // }
  2132. }
  2133. }
  2134. });
  2135. const filterBtn = make('mujs-btn', 'filter', {
  2136. title: lang.filterA,
  2137. innerHTML: iconSVG.filter,
  2138. dataset: {
  2139. command: 'show-filter'
  2140. }
  2141. });
  2142. const siteSearchbtn = make('mujs-btn', 'search', {
  2143. title: lang.search,
  2144. innerHTML: iconSVG.search,
  2145. dataset: {
  2146. command: 'show-search'
  2147. }
  2148. });
  2149. const closebtn = make('mujs-btn', 'close', {
  2150. title: lang.close,
  2151. innerHTML: iconSVG.close,
  2152. dataset: {
  2153. command: 'close'
  2154. }
  2155. });
  2156. const btncfg = make('mujs-btn', 'settings', {
  2157. title: 'Settings',
  2158. innerHTML: iconSVG.cfg,
  2159. dataset: {
  2160. command: 'settings'
  2161. }
  2162. });
  2163. const btnhome = make('mujs-btn', 'github hidden', {
  2164. title: `GitHub (v${
  2165. MU.info.script.version.includes('.') || MU.info.script.version.includes('Book')
  2166. ? MU.info.script.version
  2167. : MU.info.script.version.slice(0, 5)
  2168. })`,
  2169. innerHTML: iconSVG.gh,
  2170. dataset: {
  2171. command: 'open-tab',
  2172. webpage: 'https://github.com/magicoflolis/Userscript-Plus'
  2173. }
  2174. });
  2175. const btnissue = make('mujs-btn', 'issue hidden', {
  2176. innerHTML: iconSVG.issue,
  2177. title: lang.issue,
  2178. dataset: {
  2179. command: 'open-tab',
  2180. webpage: 'https://github.com/magicoflolis/Userscript-Plus/issues/new'
  2181. }
  2182. });
  2183. const btngreasy = make('mujs-btn', 'greasy hidden', {
  2184. title: 'Greasy Fork',
  2185. innerHTML: iconSVG.gf,
  2186. dataset: {
  2187. command: 'open-tab',
  2188. webpage: 'https://greatest.deepsurf.us/scripts/421603'
  2189. }
  2190. });
  2191. const btnnav = make('mujs-btn', 'nav', {
  2192. title: 'Navigation',
  2193. innerHTML: iconSVG.nav,
  2194. dataset: {
  2195. command: 'navigation'
  2196. }
  2197. });
  2198. const siteSearcher = make('input', 'mujs-searcher', {
  2199. autocomplete: 'off',
  2200. spellcheck: false,
  2201. type: 'text',
  2202. placeholder: MUJS.host,
  2203. onchange(evt) {
  2204. evt.preventDefault();
  2205. dbg('mujs-searcher', evt.target.value);
  2206. buildlist(evt.target.value);
  2207. }
  2208. });
  2209. countframe.append(gfcounter, sfcounter);
  2210. fsearch.append(filterList);
  2211. btnHandles.append(btnHide, btnfullscreen, closebtn);
  2212. ssearch.append(siteSearcher);
  2213. btnframe.append(
  2214. fsearch,
  2215. filterBtn,
  2216. ssearch,
  2217. siteSearchbtn,
  2218. btncfg,
  2219. btnissue,
  2220. btnhome,
  2221. btngreasy,
  2222. btnnav,
  2223. btnHandles
  2224. );
  2225. header.append(countframe, rateContainer, btnframe);
  2226. tbody.append(table);
  2227.  
  2228. makeTHead([
  2229. {
  2230. class: 'mujs-header-name',
  2231. textContent: lang.name
  2232. },
  2233. {
  2234. textContent: lang.createdby
  2235. },
  2236. {
  2237. textContent: lang.daily
  2238. },
  2239. {
  2240. textContent: lang.updated
  2241. },
  2242. {
  2243. textContent: lang.install
  2244. }
  2245. ]);
  2246.  
  2247. for (const th of tabhead.rows[0].cells) {
  2248. if (dom.text(th) === lang.install) continue;
  2249. dom.cl.add(th, 'mujs-pointer');
  2250. ael(th, 'click', () => {
  2251. sortRowBy(th.cellIndex);
  2252. });
  2253. }
  2254. main.append(header, tbody, cfgpage);
  2255. mainframe.append(mainbtn);
  2256. mujsRoot.append(mainframe, main);
  2257. injCon.append(mujsRoot);
  2258.  
  2259. makecfg();
  2260. buildlist().then(timeoutFrame);
  2261. } catch (ex) {
  2262. err(ex);
  2263. }
  2264. };
  2265. /**
  2266. * @param { Function } callback
  2267. * @returns { null | true }
  2268. */
  2269. const loadDOM = (callback) => {
  2270. if (!isFN(callback)) {
  2271. return null;
  2272. }
  2273. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  2274. callback.call({}, document);
  2275. }
  2276. document.addEventListener('DOMContentLoaded', (evt) => callback.call({}, evt.target), {
  2277. once: true
  2278. });
  2279. return true;
  2280. };
  2281. const Setup = async () => {
  2282. try {
  2283. cfg = setObj(defcfg, await MU.storage.getValue('Config'));
  2284. lang = Language.cache;
  2285. info('Config:', cfg);
  2286. loadDOM((doc) => {
  2287. try {
  2288. if (window.location === null) {
  2289. err('"window.location" is null, reload the webpage or use a different one');
  2290. return;
  2291. }
  2292. if (doc === null) {
  2293. err('"doc" is null, reload the webpage or use a different one');
  2294. return;
  2295. }
  2296. sleazyRedirect();
  2297. container.inject(primaryFN, doc);
  2298. } catch (ex) {
  2299. err(ex);
  2300. }
  2301. });
  2302. } catch (ex) {
  2303. err(ex);
  2304. }
  2305. };
  2306. if (typeof userjs === 'object' && userjs.UserJS && window && window.self === window.top) {
  2307. Setup();
  2308. }
  2309.  
  2310. })();