Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger

显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383

当前为 2023-02-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Magic Userscript+ : Show Site All UserJS
  3. // @name:zh Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger
  4. // @name:zh-CN Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger
  5. // @name:zh-TW Magic Userscript+ : 顯示當前網站所有可用的UserJS腳本 Jaeger
  6. // @name:ja Magic Userscript+ : 現在のサイトの利用可能なすべてのUserJSスクリプトを表示するJaeger
  7. // @name:ru-RU Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
  8. // @name:ru Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
  9. // @description Show current site all UserJS, the easier way to install UserJs for Tampermonkey.
  10. // @description:zh 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
  11. // @description:zh-CN 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
  12. // @description:zh-TW 顯示當前網站的所有可用UserJS(Tampermonkey)腳本,交流QQ群:104267383
  13. // @description:ja 現在のサイトで利用可能なすべてのUserJS(Tampermonkey)スクリプトを表示します。
  14. // @description:ru-RU Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
  15. // @description:ru Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
  16. // @author Magic <magicoflolis@tuta.io>
  17. // @version 5.11.19
  18. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gYRBAceMUIR3QAAEg9JREFUeNrtXWlwVNW2/k4n3RkbM5FRMEHUBOIAekGMJV4lYVDBAeQ+IYTJ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vFOgfjJpIkAK8mJSX9OyMjw6BUKrlx40ZqNBrqdDoeOHCAd9xxh4VyZs2axR9//JFXr151GHkgiauTMKQIhWvXrlGj0fCjjz5iSEgIy8rKpMiOdqVS+a0YOpKEm1QEceQ8DsD2sLAw3YIFC1hSUkKtVsuamhrZPWxvsZ515AHcPAlDilAwGo1sa2tjY2Mjd+3axbS0NAYGBraK4YLjxLoJuIUkAcByQRCOp6WlXVm4cKFh6tSpnDhxIquqqlhVVcXp06czOjqawcHBNpEHcHFyxalTp+Rls/v27eOKFSsYExOjFwThN1wPEV8OJ4Gyt5IocX3BQk5QUNB/x8bGfpeenv6rWq226TOSkpJ44cIFedOPzs5OajQai4OXBw0axGXLlnHChAkE0J6cnHw+Ojr6W1xfFpQjlqXyF0pwKUajMUAQBMV1n5Zg4ehSKBRd4u8q0enVZcchppKudXXdli1bAvfs2aP+448/wvV6fbhOp7uzq6srzWg03knyDpIxJCMBRHR1dYWpVCoA0Hd1dV0FcBWABsDF8PDwOpVKVaXVan8ZOXJkZ1xcXNvhw4ebxZGsRZlSfUwmk0oQBLS3t3eLwVTuOPvsvo+z9zSX/wfl+jWwZp8+ogAAAABJRU5ErkJggg==
  19. // @supportURL https://github.com/magicoflolis/Userscript-Plus/issues/new
  20. // @namespace https://github.com/magicoflolis/Userscript-Plus
  21. // @homepageURL https://github.com/magicoflolis/Userscript-Plus
  22. // @license MIT
  23. // @connect greasyfork.org
  24. // @connect sleazyfork.org
  25. // @connect github.com
  26. // @connect openuserjs.org
  27. // @match https://*/*
  28. // @grant GM_xmlhttpRequest
  29. // @grant GM_openInTab
  30. // @grant GM_getValue
  31. // @grant GM_setValue
  32. // @grant GM_info
  33. // @compatible chrome
  34. // @compatible firefox
  35. // @compatible edge
  36. // @compatible opera
  37. // @compatible safari
  38. // @noframes
  39. // @run-at document-start
  40. // ==/UserScript==
  41.  
  42. /**
  43. * Injected stylesheet
  44. * https://github.com/magicoflolis/Userscript-Plus/tree/master/src/sass
  45. */
  46. const main_css = `*{scrollbar-color:#fff #2e323d;scrollbar-width:thin}@supports not (scrollbar-width: thin){* ::-webkit-scrollbar{width:1.4vw;height:3.3vh}* ::-webkit-scrollbar-track{background-color:#2e323d;border-radius:10px;margin-top:3px;margin-bottom:3px;box-shadow:inset 0 0 6px rgba(0,0,0,.3)}* ::-webkit-scrollbar-thumb{border-radius:10px;background-color:#fff;background-image:-webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent)}* ::-webkit-scrollbar-thumb:hover{background-color:#fff}}*:not(.mujs-iframe){background:#495060;color:#fff}magic-userjs{line-height:normal}.magicuserjs-cfg{line-height:1.5}body.webext-page,.main{font-size:14px}mujs-column,mujs-row{display:flex}mujs-column,mujs-row{gap:10px}@media screen and (max-width: 800px){mujs-column{flex-flow:row wrap}}mujs-row{flex-direction:column}magic-userjs{cursor:default}.hidden{display:none !important;z-index:-1 !important}.main{width:100%;width:-moz-available;width:-webkit-fill-available;background:#495060 !important;border:1px solid rgba(0,0,0,0);border-radius:10px;font-family:Arial,Helvetica,sans-serif}@media screen and (max-height: 450px){.main:not(.webext-page){height:100% !important;bottom:0rem !important;margin-left:0rem !important;margin-right:0rem !important;right: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}.count{background:rgba(0,0,0,0)}.mainframe{background:rgba(0,0,0,0);position:fixed;bottom:1rem;right:1rem}.mainframe:not(.hidden){z-index:100000000000000000 !important;display:block}.mainframe count-frame{width:2em;height:1em}count-frame{border-radius:16px;padding:0 .25em;border:2px solid rgba(0,0,0,0);font-size:16px;font-weight:400;display:inline-block;text-align:center;min-width:1em}.magicuserjs-header{order:0;display:flex;gap:10px;border-bottom:1px solid #fff;border-top-left-radius:10px;border-top-right-radius:10px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;padding:10px;font-size:1em;place-content:space-between}.magicuserjs-body{overflow-x:hidden;order:1}.magicuserjs-body .magicuserjs-ratings{padding:0 .25em;border:1px solid #fff;border-radius:10px}.magicuserjs-body magicuserjs-btn svg{fill:#fff;width:14px;height:14px;background:rgba(0,0,0,0)}.magicuserjs-cfg,.magicuserjs-body{border:1px solid rgba(0,0,0,0);border-bottom-left-radius:10px;border-bottom-right-radius:10px}@media screen and (max-width: 1150px){.magicuserjs-cfg{margin:0px auto 1rem auto !important}}.magicuserjs-cfg{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media screen and (max-height: 812px){.magicuserjs-cfg:not(.webext-page){flex-wrap:wrap;flex-direction:row !important}}.magicuserjs-cfg mujs-section>label{display:flex;justify-content:space-between}.magicuserjs-cfg mujs-section>label input[type*=number]{position:relative;border-radius:4px;border:1px solid #fff}.magicuserjs-cfg .magicuserjs-inlab{position:relative;width:38px}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]{display:none}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]:checked+label{margin-left:0;background-color:rgba(255,255,255,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]:checked+label:before{right:0px}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#greasyfork:checked+label,.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#sleazyfork:checked+label{background-color:rgba(0,183,255,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#openuserjs:checked+label{background-color:rgba(237,63,20,.568)}.magicuserjs-cfg .magicuserjs-inlab input[type*=checkbox]#github:checked+label{background-color:rgba(36,41,47,.568)}.magicuserjs-cfg .magicuserjs-inlab label{padding:0;display:block;overflow:hidden;height:16px;border-radius:20px;border:1px solid #fff;background-color:#495060}.magicuserjs-cfg .magicuserjs-inlab label:before{content:"";display:block;width:20px;height:20px;margin:-2px;background:#fff;position:absolute;top:0;right:20px;border-radius:20px}.magicuserjs-cfg #blacklist{overflow-y:auto;background:#000;color:#fff;resize:vertical;outline:none;border-style:none;font-family:monospace}.magicuserjs-cfg #blacklist:focus{outline:none}.magicuserjs-cfg:not(.webext-page){order:2;margin:0px 25rem 1rem 25rem}table{width:100%;width:-moz-available;width:-webkit-fill-available}@media screen and (max-width: 800px){table thead>tr{display:grid;grid-auto-flow:column}}@media screen and (max-width: 500px){table thead>tr{display:none !important}}table th,table td{border-bottom:1px solid #fff}table td.magicuserjs-uframe,table td.magicuserjs-list,table td.install-btn{text-align:center}table th{position:-webkit-sticky;position:sticky;top:0}table th.mujs-header-name{width:50%}@media screen and (max-width: 800px){table th.mujs-header-name{width:auto !important}}magicuserjs-a{display:inline-block}magicuserjs-a.magicuserjs-euser{padding-left:.5rem;padding-right:.5rem}@media screen and (max-width: 800px){.frame:not(.webext-page){display:grid}.frame:not(.webext-page) magicuserjs-btn{margin-left:25%;margin-right:25%}}.frame.sf magicuserjs-a{color:#e75531 !important}.frame.sf magicuserjs-btn{background-color:#ed3f14 !important;border-color:#ed3f14 !important}.frame:not(.sf) magicuserjs-a{color:#00b7ff !important}.frame:not(.sf) magicuserjs-btn{color:#fff;background-color:#2d8cf0;border-color:#2d8cf0}.magicuserjs-name{display:grid}.magicuserjs-name span{font-size:.8em !important}mujs-btn{font-style:normal;font-weight:400;font-variant:normal;text-transform:none;text-rendering:auto;border:1px solid #fff;font-size:16px;border-radius:4px;line-height:1;padding:6px 15px}mujs-btn svg{fill:#fff;width:14px;height:14px}magicuserjs-btn{font-size:14px;border-radius:4px;font-style:normal;padding:7px 15%;font-weight:400;font-variant:normal;line-height:normal;display:block}input[type*=number],input[type*=text]{border:rgba(0,0,0,0);outline:none !important}magicuserjs-a,magicuserjs-btn,.mujs-pointer,.magicuserjs-cfg mujs-section *:not(input[type*=text],input[type*=number]),.mainbtn,.mainframe,mujs-btn{cursor:pointer !important}th,.magicuserjs-cfg *:not(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}mujs-btn,input,.magicuserjs-homepage{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}`;
  47.  
  48. (() => {
  49. const win = window,
  50. /**
  51. * Object is Null
  52. * @param {Object} obj - Object
  53. * @returns {boolean} Returns if statement true or false
  54. */
  55. isNull = obj => (Object.is(obj,null) || Object.is(obj,undefined)),
  56. /**
  57. * Object is Blank
  58. * @param {(Object|Object[]|string)} obj - Array, object or string
  59. * @returns {boolean} Returns if statement true or false
  60. */
  61. isBlank = obj => typeof obj === 'string' && Object.is(obj.trim(),'') || typeof obj === 'object' && Object.is(Object.keys(obj).length,0),
  62. /**
  63. * Object is Empty
  64. * @param {(Object|Object[]|string)} obj - Array, object or string
  65. * @returns {boolean} Returns if statement true or false
  66. */
  67. isEmpty = obj => isNull(obj) || isBlank(obj);
  68. class Timeout {
  69. constructor() {
  70. this.ids = [];
  71. }
  72. set = (delay, reason) => {
  73. return new Promise((resolve, reject) => {
  74. const id = setTimeout(() => {
  75. isNull(reason) ? resolve() : reject(reason);
  76. this.clear(id);
  77. }, delay);
  78. this.ids.push(id);
  79. });
  80. };
  81. clear = (...ids) => {
  82. this.ids = this.ids.filter(id => {
  83. if (ids.includes(id)) {
  84. clearTimeout(id);
  85. return false;
  86. };
  87. return true;
  88. });
  89. };
  90. };
  91. class MUError extends Error {
  92. /**
  93. * @param {string} fnName - (Optional) Function name
  94. * @param {...string} params - Extra error parameters
  95. */
  96. constructor(fnName = 'AFError',...params) {
  97. super(...params);
  98. if (Error.captureStackTrace) {
  99. Error.captureStackTrace(this, MUError)
  100. } else {
  101. this.stack = (new Error).stack
  102. };
  103. this.fn = `[${fnName}]`;
  104. const dt = new Date(Date.now());
  105. this.date = `[${dt.getHours()}:${('0' + dt.getMinutes()).slice(-2)}]`;
  106. this.name = this.constructor.name;
  107. };
  108. };
  109.  
  110. let langs = {
  111. en: {
  112. daily: 'Daily Installs',
  113. close: 'Close',
  114. filterA: 'Filter',
  115. max: 'Maximize',
  116. min: 'Minimize',
  117. search: 'Search',
  118. searcher: 'Title | Description | Author...',
  119. install: 'Install',
  120. issue: 'New Issue',
  121. version: 'Version',
  122. updated: 'Last Updated',
  123. legacy: 'Legacy',
  124. total: 'Total Installs',
  125. rating: 'Ratings',
  126. good: 'Good',
  127. ok: 'Ok',
  128. bad: 'Bad',
  129. created: 'Created',
  130. redirect: 'Greasy Fork for adults',
  131. filter: 'Filter out other languages',
  132. dtime: 'Display Timeout',
  133. save: 'Save',
  134. },
  135. es: {
  136. daily: 'Instalaciones diarias',
  137. close: 'Ya no se muestra',
  138. filterA: 'Filtro',
  139. max: 'Maximizar',
  140. min: 'Minimizar',
  141. search: 'Busque en',
  142. searcher: 'Título | Descripción | Autor...',
  143. install: 'Instalar',
  144. issue: 'Nueva edición',
  145. version: 'Versión',
  146. updated: 'Última actualización',
  147. legacy: 'Legado',
  148. total: 'Total de instalaciones',
  149. rating: 'Clasificaciones',
  150. good: 'Bueno',
  151. ok: 'Ok',
  152. bad: 'Malo',
  153. created: 'Creado',
  154. redirect: 'Greasy Fork para adultos',
  155. filter: 'Filtrar otros idiomas',
  156. dtime: 'Mostrar el tiempo de espera',
  157. save: 'Guardar',
  158. },
  159. ru: {
  160. daily: 'Ежедневные установки',
  161. close: 'Больше не показывать',
  162. filterA: 'Фильтр',
  163. max: 'Максимизировать',
  164. min: 'Минимизировать',
  165. search: 'Поиск',
  166. searcher: 'Название | Описание | Автор...',
  167. install: 'Установите',
  168. issue: 'Новый выпуск',
  169. version: 'Версия',
  170. updated: 'Последнее обновление',
  171. legacy: 'Наследие',
  172. total: 'Всего установок',
  173. rating: 'Рейтинги',
  174. good: 'Хорошо',
  175. ok: 'Хорошо',
  176. bad: 'Плохо',
  177. created: 'Создано',
  178. redirect: 'Greasy Fork для взрослых',
  179. filter: 'Отфильтровать другие языки',
  180. dtime: 'Тайм-аут отображения',
  181. save: 'Сохранить',
  182. },
  183. ja: {
  184. daily: 'デイリーインストール',
  185. close: '表示されなくなりました',
  186. filterA: 'フィルター',
  187. max: '最大化',
  188. min: 'ミニマム',
  189. search: '検索',
  190. searcher: 'タイトル|説明|著者...',
  191. install: 'インストール',
  192. issue: '新刊のご案内',
  193. version: 'バージョン',
  194. updated: '最終更新日',
  195. legacy: 'レガシー',
  196. total: '総インストール数',
  197. rating: 'レーティング',
  198. good: 'グッド',
  199. ok: '良い',
  200. bad: '悪い',
  201. created: '作成',
  202. redirect: '大人のGreasyfork',
  203. filter: '他の言語をフィルタリングする',
  204. dtime: '表示タイムアウト',
  205. save: '拯救',
  206. },
  207. fr: {
  208. daily: 'Installations quotidiennes',
  209. close: 'Ne plus montrer',
  210. filterA: 'Filtre',
  211. max: 'Maximiser',
  212. min: 'Minimiser',
  213. search: 'Recherche',
  214. searcher: 'Titre | Description | Auteur...',
  215. install: 'Installer',
  216. issue: 'Nouveau numéro',
  217. version: 'Version',
  218. updated: 'Dernière mise à jour',
  219. legacy: 'Héritage',
  220. total: 'Total des installations',
  221. rating: 'Notations',
  222. good: 'Bon',
  223. ok: 'Ok',
  224. bad: 'Mauvais',
  225. created: 'Créé',
  226. redirect: 'Greasy Fork pour les adultes',
  227. filter: 'Filtrer les autres langues',
  228. // eslint-disable-next-line quotes
  229. dtime: `Délai d'affichage`,
  230. save: 'Sauvez',
  231. },
  232. zh: {
  233. daily: '日常安装',
  234. close: '不再显示',
  235. filterA: '过滤器',
  236. max: '最大化',
  237. min: '最小化',
  238. search: '搜索',
  239. searcher: '标题|描述|作者...',
  240. install: '安装',
  241. issue: '新问题',
  242. version: '版本',
  243. updated: '最后更新',
  244. legacy: '遗产',
  245. total: '总安装量',
  246. rating: '评级',
  247. good: '好的',
  248. ok: '好的',
  249. bad: '不好',
  250. created: '创建',
  251. redirect: '大人的Greasyfork',
  252. filter: '过滤掉其他语言',
  253. dtime: '显示超时',
  254. save: '拯救',
  255. },
  256. },
  257. alang = [],
  258. clang = navigator.language.split('-')[0] ?? 'en',
  259. lang = langs[clang],
  260. isGM = typeof GM !== 'undefined',
  261. defcfg = {
  262. cache: true,
  263. autoexpand: false,
  264. filterlang: false,
  265. sleazyredirect: false,
  266. time: 10000,
  267. blacklist: [
  268. {
  269. enabled: true,
  270. regex: true,
  271. flags: '',
  272. name: 'Blacklist 1',
  273. url: '(gov|cart|checkout|login|join|signin|signup|sign-up|password|reset|password_reset)',
  274. },
  275. {
  276. enabled: true,
  277. regex: true,
  278. flags: '',
  279. name: 'Blacklist 2',
  280. url: '(pay|bank|money|localhost|authorize|checkout|bill|wallet|router)',
  281. },
  282. {
  283. enabled: true,
  284. regex: false,
  285. flags: '',
  286. name: 'Blacklist 3',
  287. url: 'https://home.bluesnap.com',
  288. },
  289. {
  290. enabled: true,
  291. regex: false,
  292. flags: '',
  293. name: 'Blacklist 4',
  294. url: [
  295. 'zalo.me',
  296. 'skrill.com'
  297. ],
  298. },
  299. ],
  300. engines: [
  301. {
  302. enabled: true,
  303. name: 'greasyfork',
  304. url: 'https://greasyfork.org',
  305. },
  306. {
  307. enabled: true,
  308. name: 'sleazyfork',
  309. url: 'https://sleazyfork.org',
  310. },
  311. {
  312. enabled: false,
  313. name: 'openuserjs',
  314. url: 'https://openuserjs.org/?q=',
  315. },
  316. {
  317. enabled: false,
  318. name: 'github',
  319. url: 'https://github.com/search?l=JavaScript&o=desc&q="==UserScript=="+',
  320. },
  321. {
  322. enabled: false,
  323. name: 'gist',
  324. url: 'https://gist.github.com/search?l=JavaScript&o=desc&q="==UserScript=="+',
  325. },
  326. ]
  327. },
  328. cfg = {},
  329. urls = [],
  330. sitegfcount = 0,
  331. sitesfcount = 0,
  332. MU = {
  333. /**
  334. * Get Value
  335. * @param {string} key - Key to get the value of
  336. * @param {Object} def - Fallback default value of key
  337. * @returns {Object} Value or default value of key
  338. * @link https://violentmonkey.github.io/api/gm/#gm_getvalue
  339. * @link https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
  340. */
  341. async getValue(key,def = {}) {
  342. try {
  343. return await new Promise((resolve) => {
  344. const params = JSON.stringify(def ?? {});
  345. if (isGM) {
  346. resolve(JSON.parse(GM_getValue(key, params)));
  347. } else {
  348. resolve(localStorage.getItem(`MUJS${key}`) ? JSON.parse(localStorage.getItem(`MUJS${key}`)) : def);
  349. };
  350. });
  351. } catch (ex) {
  352. err(ex);
  353. return def;
  354. }
  355. },
  356. /**
  357. * Get info of script
  358. * @returns {Object} Script info
  359. * @link https://violentmonkey.github.io/api/gm/#gm_info
  360. */
  361. info() {
  362. return isGM ? GM_info : {
  363. script: {
  364. updateURL: '',
  365. version: 'Bookmarklet'
  366. }
  367. }
  368. },
  369. /**
  370. * Open a new window
  371. * @param {string} url - URL of webpage to open
  372. * @param {object} params - GM parameters
  373. * @returns {object} GM_openInTab object with Window object as a fallback
  374. * @link https://violentmonkey.github.io/api/gm/#gm_openintab
  375. * @link https://developer.mozilla.org/docs/Web/API/Window/open
  376. */
  377. openInTab(url, params = {
  378. active: true,
  379. insert: true,
  380. }, features) {
  381. if(!isGM && isBlank(params)) {
  382. params = '_blank';
  383. };
  384. if(features) {
  385. return win.open(url, params, features);
  386. };
  387. return isGM ? GM_openInTab(url, params) : win.open(url, params);
  388. },
  389. /**
  390. * Set value
  391. * @param {string} key - Key to set the value of
  392. * @param {Object} v - Value of key
  393. * @returns {Promise} Saves key to either GM managed storage or webpages localstorage
  394. * @link https://violentmonkey.github.io/api/gm/#gm_setvalue
  395. * @link https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
  396. */
  397. setValue(key,v) {
  398. return new Promise((resolve) => {
  399. v = typeof v !== 'string' ? JSON.stringify(v ?? {}) : v;
  400. if(isGM && cfg.cache) {
  401. resolve( GM_setValue(key,v) );
  402. } else {
  403. resolve( win.localStorage.setItem(`MUJS${key}`,v) );
  404. };
  405. });
  406. },
  407. /**
  408. * Fetch a URL with fetch API as fallback
  409. *
  410. * When GM is supported, makes a request like XMLHttpRequest, with some special capabilities, not restricted by same-origin policy
  411. * @param {string} url - The URL to fetch
  412. * @param {string} method - Fetch method
  413. * @param {string} responseType - Response type
  414. * @param {Object} extras - Fetch parameters
  415. * @param {boolean} forcefetch - Force use fetch API
  416. * @returns {*} Fetch results
  417. * @link https://violentmonkey.github.io/api/gm/#gm_xmlhttprequest
  418. * @link https://developer.mozilla.org/docs/Web/API/Fetch_API
  419. */
  420. fetchURL(url,method = 'GET',responseType = 'json',extras = {},forcefetch) {
  421. return new Promise((resolve, reject) => {
  422. if(isGM && !forcefetch) {
  423. GM_xmlhttpRequest({
  424. method: method,
  425. url,
  426. responseType,
  427. ...extras,
  428. onerror: e => reject(e),
  429. onload: (r) => {
  430. if(r.status !== 200) reject(`${r.status} ${url}`);
  431. if(responseType.match(/basic/gi)) resolve(r);
  432. resolve(r.response);
  433. },
  434. });
  435. } else {
  436. fetch(url, {
  437. method: method,
  438. ...extras,
  439. }).then((response) => {
  440. if(!response.ok) reject(response);
  441. if(responseType.match(/json/gi)) {
  442. resolve(response.json());
  443. } else if(responseType.match(/text/gi)) {
  444. resolve(response.text());
  445. } else if(responseType.match(/blob/gi)) {
  446. resolve(response.blob());
  447. };
  448. resolve(response);
  449. }).catch(handleError);
  450. };
  451. });
  452. },
  453. };
  454.  
  455. const doc = document,
  456. /**
  457. * preventDefault + stopPropagation
  458. * @param {Object} e - Selected Element
  459. */
  460. halt = (e) => {
  461. e.preventDefault();
  462. e.stopPropagation();
  463. },
  464. /**
  465. * setTimeout w/ Promise
  466. * @param {number} ms - Timeout in milliseconds (ms)
  467. * @returns {Promise} Promise object
  468. */
  469. delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
  470. /**
  471. * Add Event Listener
  472. * @param {Object} root - Selected Element
  473. * @param {string} event - root Event Listener
  474. * @param {Function} callback - Callback function
  475. * @param {Object} [options={}] - (Optional) Options
  476. * @returns {Object} Returns selected Element
  477. */
  478. ael = (root, event, callback, options = {}) => {
  479. try {
  480. let isMobile = () => {
  481. let a = navigator.userAgent || win.opera;
  482. return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0,4));
  483. };
  484. root = (root || doc || doc.documentElement);
  485. if(isMobile()) {
  486. if(event === 'click') {
  487. event = 'mouseup';
  488. root.addEventListener('touchstart', callback);
  489. root.addEventListener('touchend', callback);
  490. };
  491. };
  492. if(event === 'fclick') {event = 'click'};
  493. return root.addEventListener(event, callback, {...options});
  494. } catch(ex) {
  495. handleError(ex);
  496. };
  497. },
  498. /**
  499. * Prefix for document.querySelectorAll()
  500. * @param {Object} element - Elements for query selection
  501. * @param {Object} [root=document] - Root selector Element
  502. * @returns {Object} Returns root.querySelectorAll(element)
  503. */
  504. qsA = (element, root) => {
  505. root = root ?? doc ?? doc.body;
  506. return root.querySelectorAll(element);
  507. },
  508. /**
  509. * Prefix for document.querySelector()
  510. * @param {Object} element - Element for query selection
  511. * @param {Object} [root=document] - Root selector Element
  512. * @returns {Object} Returns root.querySelector(element)
  513. */
  514. qs = (element, root) => {
  515. root = root ?? doc ?? doc.body;
  516. return root.querySelector(element);
  517. },
  518. /**
  519. * Prefix for document.querySelector() w/ Promise
  520. * @param {Object} element - Element for query selection
  521. * @param {Object} [root=document] - Root selector Element
  522. * @returns {Object} Returns root.querySelector(element)
  523. */
  524. query = async (element, root) => {
  525. root = root ?? doc ?? doc.body;
  526. while(isNull(root.querySelector(element))) {
  527. await new Promise(resolve=>requestAnimationFrame(resolve))
  528. };
  529. return root.querySelector(element);
  530. },
  531. /**
  532. * Create/Make Element
  533. * @param {Object} element - Element to create
  534. * @param {string} cname - (Optional) Element class name
  535. * @param {Object} [attrs={}] - (Optional) Element attributes
  536. * @returns {Object} Returns created Element
  537. */
  538. make = (element, cname, attrs = {}) => {
  539. let el;
  540. try {
  541. el = doc.createElement(element);
  542. if(!isEmpty(cname)) {
  543. el.className = cname;
  544. };
  545. if(!isEmpty(attrs)) {
  546. for (const key in attrs) {
  547. el[key] = attrs[key];
  548. };
  549. };
  550. return el;
  551. } catch(ex) {handleError(ex)}
  552. },
  553. iconSVG = {
  554. 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>',
  555. close: '<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>',
  556. filter: '<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>',
  557. fsClose: '<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>',
  558. fsOpen: '<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>',
  559. fullscreen: '<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>',
  560. 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>',
  561. 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>',
  562. 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>',
  563. install: '<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>',
  564. issue: '<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>',
  565. 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>',
  566. plus: '<svg viewBox="0 0 24 24"><g stroke-width="0"/><g stroke-linecap="round" stroke-linejoin="round"/><g><path d="M13.5 3C13.5 2.44772 13.0523 2 12.5 2H11.5C10.9477 2 10.5 2.44772 10.5 3V10.5H3C2.44772 10.5 2 10.9477 2 11.5V12.5C2 13.0523 2.44772 13.5 3 13.5H10.5V21C10.5 21.5523 10.9477 22 11.5 22H12.5C13.0523 22 13.5 21.5523 13.5 21V13.5H21C21.5523 13.5 22 13.0523 22 12.5V11.5C22 10.9477 21.5523 10.5 21 10.5H13.5V3Z" fill="#ffffff"/> </g></svg>',
  567. search: '<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="#ffffff"/> </g></svg>',
  568. },
  569. container = make('main-userjs','mujs-primary'),
  570. ifram = make('iframe','mujs-iframe', {
  571. src: 'about:blank',
  572. style: 'position: fixed; bottom: 1rem; right: 1rem; height: 525px; width: 90%; margin-left: 1rem; margin-right: 1rem; z-index: 100000000000000020 !important;'
  573. });
  574.  
  575. function main() {
  576. const injCon = container.attachShadow instanceof Function ? container.shadowRoot : ifram.contentDocument.body;
  577. let unsaved = false,
  578. isBlacklisted = false,
  579. seen = new Set(),
  580. switchRows = true,
  581. thisHost = location.hostname.split('.').splice(-2).join('.');
  582. const save = () => {
  583. try {
  584. MU.setValue('Config', cfg);
  585. unsaved = false;
  586. log('Saved:',cfg);
  587. } catch(e) {err(e)};
  588. },
  589. timeout = new Timeout(),
  590. timeoutFrame = async () => {
  591. if(typeof cfg.time === 'number' && !isNaN(cfg.time)) {
  592. timeout.clear(...timeout.ids);
  593. await timeout.set(isBlacklisted ? cfg.time/2 : cfg.time);
  594. container.remove();
  595. ifram.remove();
  596. return timeout.clear(...timeout.ids);
  597. }
  598. },
  599. sh = elem => injCon.querySelector(elem),
  600. shA = elem => injCon.querySelectorAll(elem),
  601. table = make('table'),
  602. tabbody = make('tbody'),
  603. tabhead = make('thead'),
  604. makeTHead = (rows = []) => {
  605. let tr = make('tr');
  606. for(let r of rows) {
  607. let tparent = make('th', r.class ?? '', r);
  608. tr.append(tparent);
  609. };
  610. tabhead.append(tr);
  611. table.append(tabhead, tabbody);
  612. },
  613. showError = (msg) => {
  614. err(msg);
  615. let txt = make('mujs-row','error', {
  616. innerHTML: msg
  617. });
  618. for(let u of urls) {
  619. let dwnbtn = make('a','magicuserjs-urls', {
  620. href: u,
  621. target: '_blank',
  622. rel: 'noopener',
  623. innerHTML: u
  624. });
  625. txt.append(dwnbtn);
  626. };
  627. if(sh('.magicuserjs-body')) {
  628. sh('.magicuserjs-body').prepend(txt);
  629. };
  630. },
  631. sortRowBy = (cellIndex) => {
  632. const rows = Array.from(tabbody.rows);
  633. rows.sort((tr1, tr2) => {
  634. const t1cell = tr1.cells[cellIndex],
  635. t2cell = tr2.cells[cellIndex],
  636. tr1Text = (t1cell.firstElementChild ?? t1cell).textContent,
  637. tr2Text = (t2cell.firstElementChild ?? t2cell).textContent,
  638. t1pDate = Date.parse(tr1Text),
  639. t2pDate = Date.parse(tr2Text);
  640. if(!Number.isNaN(t1pDate) && !Number.isNaN(t2pDate)) {
  641. return new Date(t1pDate) - new Date(t2pDate);
  642. };
  643. if(Number(tr1Text) && Number(tr2Text)) {
  644. return tr1Text - tr2Text;
  645. };
  646. return tr1Text.localeCompare(tr2Text);
  647. });
  648. if(switchRows) {
  649. rows.reverse()
  650. };
  651. switchRows = !switchRows;
  652. tabbody.append(...rows);
  653. },
  654. createjs = (ujs, issleazy) => {
  655. let eframe = make('td', 'install-btn'),
  656. uframe = make('td','magicuserjs-uframe'),
  657. fdaily = make('td','magicuserjs-list', {
  658. innerHTML: ujs.daily_installs,
  659. }),
  660. fupdated = make('td','magicuserjs-list', {
  661. innerHTML: new Intl.DateTimeFormat(navigator.language).format(new Date(ujs.code_updated_at)),
  662. }),
  663. fname = make('td','magicuserjs-name'),
  664. ftitle = make('magicuserjs-a','magicuserjs-homepage', {
  665. title: ujs.name,
  666. innerHTML: ujs.name,
  667. onclick: (e) => {
  668. halt(e);
  669. MU.openInTab(ujs.url);
  670. }
  671. }),
  672. fver = make('magic-userjs','magicuserjs-list', {
  673. innerHTML: `${lang.version}: ${ujs.version}`,
  674. }),
  675. fcreated = make('magic-userjs','magicuserjs-list', {
  676. innerHTML: `${lang.created}: ${new Intl.DateTimeFormat(navigator.language).format(new Date(ujs.created_at))}`,
  677. }),
  678. fmore = make('mujs-column','magicuserjs-list hidden', {
  679. style: 'margin-top: 3px;',
  680. }),
  681. ftotal = make('magic-userjs','magicuserjs-list', {
  682. innerHTML: `${lang.total}: ${ujs.total_installs}`,
  683. }),
  684. fratings = make('magic-userjs','magicuserjs-list', {
  685. title: lang.rating,
  686. innerHTML: `${lang.rating}:`,
  687. }),
  688. fgood = make('magic-userjs','magicuserjs-list magicuserjs-ratings', {
  689. title: lang.good,
  690. innerHTML: ujs.good_ratings,
  691. style: 'border-color: rgb(51, 155, 51); background-color: #339b331a; color: #339b33;',
  692. }),
  693. fok = make('magic-userjs','magicuserjs-list magicuserjs-ratings', {
  694. title: lang.ok,
  695. innerHTML: ujs.ok_ratings,
  696. style: 'border-color: rgb(155, 155, 0); background-color: #9b9b001a; color: #9b9b00;',
  697. }),
  698. fbad = make('magic-userjs','magicuserjs-list magicuserjs-ratings', {
  699. title: lang.bad,
  700. innerHTML: ujs.bad_ratings,
  701. style: 'border-color: red; background-color: #9b33331a; color: red;',
  702. }),
  703. fdesc = make('magic-userjs','magicuserjs-list', {
  704. style: 'cursor: pointer; margin-top: 3px;',
  705. title: ujs.description,
  706. innerHTML: ujs.description,
  707. onclick: (e) => {
  708. halt(e);
  709. if(fmore.classList.contains('hidden')) {
  710. fmore.classList.remove('hidden');
  711. } else {
  712. fmore.classList.add('hidden');
  713. }
  714. },
  715. }),
  716. fdwn = make('magicuserjs-btn','install', {
  717. title: `${lang.install} { ${ujs.name} }`,
  718. innerHTML: `${iconSVG.install} ${lang.install}`,
  719. onclick: (e) => {
  720. halt(e);
  721. MU.openInTab(ujs.code_url);
  722. },
  723. });
  724. for(let u of ujs.users) {
  725. let user = make('magicuserjs-a','magicuserjs-euser', {
  726. innerHTML: u.name,
  727. onclick: (e) => {
  728. halt(e);
  729. MU.openInTab(u.url);
  730. },
  731. });
  732. uframe.append(user);
  733. };
  734. eframe.append(fdwn);
  735. fmore.append(ftotal,fratings,fgood,fok,fbad,fver,fcreated);
  736. fname.append(ftitle,fdesc,fmore);
  737. let tr = make('tr', `frame ${issleazy ? 'sf' : ''}`);
  738. for(let e of [fname,uframe,fdaily,fupdated,eframe]) {
  739. tr.append(e);
  740. };
  741. tabbody.append(tr);
  742.  
  743. };
  744. if(!isEmpty(navigator.languages)) {
  745. for(let nlang of navigator.languages) {
  746. let lg = nlang.split('-')[0];
  747. if(alang.indexOf(lg) === -1) {
  748. alang.push(lg);
  749. };
  750. };
  751. };
  752. try {
  753. if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirect) {
  754. let otherSite = /greasyfork\.org/.test(document.location.hostname) ? 'sleazyfork' : 'greasyfork';
  755. qs('span.sign-in-link') ? /scripts\/\d+/.test(document.location.href) ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a')) ? location.href = location.href.replace(/\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/, '//$1' + otherSite + '.org') : false : false : false;
  756. };
  757. let rebuild = false,
  758. siteujs = [],
  759. main = make('magic-userjs','main hidden'),
  760. usercss = make('style', 'primary-stylesheet', {innerHTML: main_css,}),
  761. tbody = make('magic-userjs','magicuserjs-body'),
  762. header = make('magic-userjs','magicuserjs-header'),
  763. cfgpage = make('mujs-row','magicuserjs-cfg hidden'),
  764. makerow = (desc,type,nm,attrs = {}) => {
  765. let sec = make('mujs-section','', {
  766. style: !isGM && nm === 'cache' ? 'display: none;' : ''
  767. }),
  768. lb = make('label'),
  769. divDesc = make('magic-userjs','', {
  770. innerHTML: desc,
  771. }),
  772. inp = make('input','', {
  773. type: type,
  774. id: nm,
  775. name: nm,
  776. ...attrs
  777. });
  778. if(type === 'checkbox') {
  779. let inlab = make('magic-userjs','magicuserjs-inlab'),
  780. la = make('label','', {
  781. onclick: () => inp.click()
  782. });
  783. inlab.append(inp,la);
  784. lb.append(divDesc,inlab);
  785. if(nm.match(/((greasy|sleazy)fork|openuserjs|gi(thub|st))/gi)) {
  786. for(let i of cfg.engines) {
  787. if(i.name === nm) {
  788. inp.checked = i.enabled;
  789. ael(inp,'change', (e) => {
  790. unsaved = true;
  791. i.enabled = e.target.checked;
  792. rebuild = true;
  793. });
  794. };
  795. };
  796. } else {
  797. inp.checked = cfg[nm];
  798. if(nm.match(/(autoexpand|sleazyredirect)/gi)) {
  799. ael(inp,'change', (e) => {
  800. unsaved = true;
  801. cfg[nm] = e.target.checked;
  802. });
  803. } else {
  804. ael(inp,'change', (e) => {
  805. unsaved = true;
  806. cfg[nm] = e.target.checked;
  807. rebuild = true;
  808. });
  809. };
  810. };
  811. } else {
  812. lb.append(divDesc,inp);
  813. };
  814. sec.append(lb);
  815. cfgpage.append(sec);
  816. return inp;
  817. },
  818. countframe = make('mujs-column'),
  819. gfcountframe = make('magic-userjs', 'counterframe'),
  820. sfcountframe = make('magic-userjs', 'counterframe'),
  821. gfcounter = make('count-frame','count', {
  822. title: 'https://greasyfork.org + https://sleazyfork.org',
  823. style: 'background: #00b7ff;'
  824. }),
  825. sfcounter = make('count-frame','count', {
  826. title: 'https://openuserjs.org',
  827. style: 'background: #ed3f14;'
  828. }),
  829. buildlist = async (host) => {
  830. try {
  831. if(isEmpty(host)) {
  832. host = thisHost;
  833. };
  834. const template = {
  835. bad_ratings: 0,
  836. good_ratings: 0,
  837. ok_ratings: 0,
  838. daily_installs: 0,
  839. total_installs: 0,
  840. name: 'Not found',
  841. description: 'Not found',
  842. version: '0.0.0',
  843. url: 'about:blank',
  844. code_url: 'about:blank',
  845. created_at: Date.now(),
  846. code_updated_at: Date.now(),
  847. users: [
  848. {
  849. name: '',
  850. url: '',
  851. }
  852. ]
  853. };
  854. let sites = [],
  855. custom = [],
  856. engines = cfg.engines.filter(e => e.enabled);
  857. for(let i of engines) {
  858. if(i.url.match(/fork.org/gi)) {
  859. if(cfg.filterlang) {
  860. if(alang.length > 1) {
  861. for(let a of alang) {
  862. urls.push(`${i.url}/${a}/scripts/by-site/${host}.json`);
  863. sites.push(MU.fetchURL(`${i.url}/${a}/scripts/by-site/${host}.json?page=1`),);
  864. };
  865. continue;
  866. };
  867. urls.push(`${i.url}/${clang}/scripts/by-site/${host}.json`);
  868. sites.push(MU.fetchURL(`${i.url}/${clang}/scripts/by-site/${host}.json?page=1`),);
  869. continue;
  870. };
  871. urls.push(`${i.url}/scripts/by-site/${host}.json`);
  872. sites.push(MU.fetchURL(`${i.url}/scripts/by-site/${host}.json`),);
  873. } else if(i.url.match(/(openuserjs.org|github.com)/gi)) {
  874. urls.push(`${i.url}${host}`);
  875. custom.push(MU.fetchURL(`${i.url}${host}`,'GET','text'),);
  876. };
  877. };
  878. info('Fetching data',host);
  879.  
  880. if(!isBlank(sites)) {
  881. let hideData = [];
  882. let data = await Promise.all(sites).catch((e) => {throw new MUError('Data',e)}),
  883. joinData = [...new Set([...data[0], ...data[1]])],
  884. filterDeleted = joinData.filter(ujs => !ujs.deleted),
  885. filterLang = cfg.filterlang ? filterDeleted.filter((d) => {
  886. let dlocal = d.locale.split('-')[0] ?? d.locale;
  887. if(alang.length > 1) {
  888. for(let a of alang) {
  889. if(dlocal.includes(a)) {
  890. return true;
  891. };
  892. };
  893. } else if(dlocal.includes(clang)) {
  894. return true;
  895. };
  896. hideData.push(d);
  897. return false;
  898. }) : filterDeleted,
  899. finalList = filterLang;
  900.  
  901. if(!isBlank(hideData)) {
  902. let hds = [];
  903. for(let h of hideData) {
  904. let txt = await MU.fetchURL(h.code_url,'GET','text');
  905. let headers = txt.match(/\/\/\s@[\w][\s\S]+/gi) || [];
  906. if(headers.length > 0) {
  907. let regName = new RegExp(`// @name:${clang}\\s+.+`,'gi'),
  908. findName = headers[0].match(regName) || [];
  909.  
  910. if(isEmpty(findName)) {
  911. continue;
  912. };
  913. let cReg = new RegExp(`// @name:${clang}\\s+`,'gi'),
  914. cutName = findName[0].replace(cReg, '');
  915. Object.assign(h, {
  916. name: cutName
  917. });
  918.  
  919. let regDesc = new RegExp(`// @description:${clang}\\s+.+`,'gi'),
  920. findDesc = headers[0].match(regDesc) || [];
  921. if(isEmpty(findDesc)) {
  922. continue;
  923. };
  924. let dReg = new RegExp(`// @description:${clang}\\s+`,'gi'),
  925. cutDesc = findDesc[0].replace(dReg, '');
  926. Object.assign(h, {
  927. description: cutDesc
  928. });
  929. hds.push(h);
  930. };
  931. };
  932. finalList = [...new Set([...hds, ...filterLang])];
  933. };
  934.  
  935. for(let ujs of finalList) {
  936. siteujs.push(
  937. {
  938. url: ujs,
  939. sleazy: false,
  940. },
  941. );
  942. sitegfcount++;
  943. };
  944. for(let ujs of siteujs) {
  945. createjs(ujs.url,ujs.sleazy);
  946. };
  947. } else {
  948. showError('Error occured while loading UserJS for this webpage')
  949. };
  950. gfcounter.innerHTML = sitegfcount;
  951. mainbtn.innerHTML = sitesfcount + sitegfcount;
  952. if(!isBlank(custom)) {
  953. let customRecords = [];
  954. let c = await Promise.all(custom).catch((e) => {throw new MUError('Custom',e)}),
  955. parser = new DOMParser(),
  956. htmlDocument = parser.parseFromString(c,'text/html'),
  957. selected = htmlDocument.documentElement;
  958. if(qs('.col-sm-8 .tr-link',selected)) {
  959. for(let i of qsA('.col-sm-8 .tr-link',selected)) {
  960. await query('.script-version',i);
  961. let fixurl = qs('.tr-link-a',i).href.replace(new RegExp(doc.location.origin, 'gi'),'https://openuserjs.org'),
  962. layout = {
  963. name: qs('.tr-link-a',i).textContent,
  964. description: qs('p',i).textContent,
  965. version: qs('.script-version',i).textContent,
  966. url: fixurl,
  967. code_url: `${fixurl.replace(new RegExp('/scripts', 'gi'),'/install')}.user.js`,
  968. total_installs: qs('td:nth-child(2) p',i).textContent,
  969. created_at: qs('td:nth-child(4) time',i).getAttribute('datetime'),
  970. code_updated_at: qs('td:nth-child(4) time',i).getAttribute('datetime'),
  971. users: [
  972. {
  973. name: qs('.inline-block a',i).textContent,
  974. url: qs('.inline-block a',i).href,
  975. }
  976. ]
  977. };
  978. for(const key in template) {
  979. if(!Object.hasOwn(layout, key)) {
  980. layout[key] = template[key];
  981. };
  982. };
  983. createjs(layout, true);
  984. customRecords.push(layout);
  985. sitesfcount++;
  986. sfcounter.innerHTML = sitesfcount;
  987. };
  988. };
  989. if(qs('.repo-list-item',selected)) {
  990. for(let r of qsA('.repo-list-item',selected)) {
  991. let layout = {},
  992. fixurl = qs('a',r).href.replace(new RegExp(doc.location.origin, 'gi'),'https://github.com');
  993. layout = Object.assign(layout, {
  994. name: qs('a',r).textContent,
  995. description: qs('p.mb-1',r).textContent.trim(),
  996. url: fixurl,
  997. code_url: fixurl,
  998. code_updated_at: qs('relative-time.no-wrap',r).getAttribute('datetime'),
  999. total_installs: qs('a.Link--muted:nth-child(1)',r) ? qs('a.Link--muted:nth-child(1)',r).textContent : 0,
  1000. users: [{
  1001. name: qs('a',r).href.match(/\/[\w\d-]+\//gi)[0].replaceAll('/',''),
  1002. url: `https://github.com${qs('a',r).href.match(/\/[\w\d-]+\//gi)}`,
  1003. }]
  1004. });
  1005. for (const key in template) {
  1006. if(!Object.hasOwn(layout, key)) {
  1007. layout[key] = template[key];
  1008. };
  1009. };
  1010. createjs(layout, true);
  1011. customRecords.push(layout);
  1012. sitesfcount++;
  1013. sfcounter.innerHTML = sitesfcount;
  1014. };
  1015. };
  1016. if(qs('div.gist-snippet',selected)) {
  1017. for(let g of qsA('div.gist-snippet',selected)) {
  1018. if(qs('span > a:nth-child(2)',g).textContent.includes('.user.js')) {
  1019. let layout = {},
  1020. fixurl = qs('span > a:nth-child(2)',g).href.replace(new RegExp(doc.location.origin, 'gi'),'https://gist.github.com');
  1021. layout = Object.assign(layout, {
  1022. url: fixurl,
  1023. code_url: `${fixurl}/raw/${qs('span > a:nth-child(2)',g).textContent}`,
  1024. created_at: qs('time-ago.no-wrap',g).getAttribute('datetime'),
  1025. users: [{
  1026. name: qs('span > a[data-hovercard-type]',g).textContent,
  1027. url: qs('span > a[data-hovercard-type]',g).href.replace(new RegExp(doc.location.origin, 'gi'),'https://gist.github.com'),
  1028. }]
  1029. });
  1030. for(let i of qsA('.file-box table tr .blob-code',g)) {
  1031. let txt = i.textContent,
  1032. headers = txt.match(/\/\/\s@[\w][\s\S]+/gi) || [];
  1033. if(headers.length > 0) {
  1034. let crop = headers[0].split(/\/\/\s@(name|description|author|version)\s+/gi);
  1035. if(headers[0].includes('@name') && !headers[0].includes('@namespace')) {
  1036. layout = Object.assign(layout, {
  1037. name: crop[2].trim(),
  1038. });
  1039. };
  1040. if(headers[0].includes('@description')) {
  1041. layout = Object.assign(layout, {
  1042. description: crop[2].trim(),
  1043. });
  1044. };
  1045. if(headers[0].includes('@version')) {
  1046. layout = Object.assign(layout, {
  1047. version: crop[2].trim(),
  1048. });
  1049. };
  1050. }
  1051. };
  1052. for (const key in template) {
  1053. if(!Object.hasOwn(layout, key)) {
  1054. layout[key] = template[key];
  1055. };
  1056. };
  1057. createjs(layout, true);
  1058. customRecords.push(layout);
  1059. sitesfcount++;
  1060. sfcounter.innerHTML = sitesfcount;
  1061. };
  1062. };
  1063. };
  1064. seen.add({
  1065. host: host,
  1066. data: siteujs,
  1067. custom: customRecords,
  1068. gfcount: sitegfcount,
  1069. sfcount: sitesfcount,
  1070. });
  1071. sfcounter.innerHTML = sitesfcount;
  1072. mainbtn.innerHTML = sitesfcount + sitegfcount;
  1073. } else {
  1074. seen.add({
  1075. host: host,
  1076. data: siteujs,
  1077. gfcount: sitegfcount,
  1078. sfcount: sitesfcount,
  1079. });
  1080. };
  1081. if(isBlank(sites) && isBlank(custom)) showError('No available UserJS for this webpage');
  1082.  
  1083. staticRows = Array.from(tabbody.rows);
  1084.  
  1085. sortRowBy(2);
  1086.  
  1087. } catch(ex) {
  1088. showError(ex);
  1089. };
  1090. },
  1091. preBuild = (site) => {
  1092. let bhref = site ?? win.top.document.location.href,
  1093. blacklist = cfg.blacklist.filter(b => b.enabled);
  1094. siteujs = [];
  1095. urls = [];
  1096. sitegfcount = 0;
  1097. sitesfcount = 0;
  1098. tabbody.innerHTML = '';
  1099. if(sh('.error')) {
  1100. sh('.error').remove();
  1101. };
  1102. gfcounter.innerHTML = sitegfcount;
  1103. sfcounter.innerHTML = sitesfcount;
  1104. mainbtn.innerHTML = sitegfcount;
  1105. for(let b of blacklist) {
  1106. if(b.regex) {
  1107. let reg = new RegExp(b.url,b.flags),
  1108. testurl = reg.test(bhref);
  1109. if(!testurl) continue;
  1110. isBlacklisted = true;
  1111. };
  1112. if(!Array.isArray(b.url)) {
  1113. if(!bhref.includes(b.url)) continue;
  1114. isBlacklisted = true;
  1115. };
  1116. for(let c of b.url) {
  1117. if(!bhref.includes(c)) continue;
  1118. isBlacklisted = true;
  1119. };
  1120. };
  1121. if(isBlacklisted) {
  1122. urls.push(bhref);
  1123. showError('Blacklisted');
  1124. return timeoutFrame();
  1125. };
  1126. if(isEmpty(site)) {
  1127. site = thisHost;
  1128. };
  1129. if(seen.size > 0) {
  1130. for(let s of seen) {
  1131. if(Object.is(s.host,site)) {
  1132. if(s.data) {
  1133. for(let ujs of s.data) {
  1134. createjs(ujs.url, ujs.sleazy);
  1135. };
  1136. };
  1137. if(s.custom) {
  1138. for(let ujs of s.custom) {
  1139. createjs(ujs, true);
  1140. };
  1141. };
  1142. gfcounter.innerHTML = s.gfcount;
  1143. sfcounter.innerHTML = s.sfcount;
  1144. mainbtn.innerHTML = s.sfcount + s.gfcount;
  1145. return;
  1146. }
  1147. };
  1148. };
  1149.  
  1150. return buildlist(site);
  1151. },
  1152. //#region Make Config
  1153. makecfg = () => {
  1154. makerow('Sync with GM','checkbox','cache');
  1155. makerow('Auto Fullscreen','checkbox','autoexpand', {
  1156. onchange: (e) => {
  1157. if(e.target.checked) {
  1158. btnfullscreen.classList.add('expanded');
  1159. main.classList.add('expanded');
  1160. btnfullscreen.innerHTML = fcclose;
  1161. } else {
  1162. btnfullscreen.classList.remove('expanded');
  1163. main.classList.remove('expanded');
  1164. btnfullscreen.innerHTML = fcopen;
  1165. };
  1166. },
  1167. });
  1168. makerow(lang.redirect,'checkbox','sleazyredirect');
  1169. makerow(lang.filter,'checkbox','filterlang');
  1170. makerow('Greasy Fork','checkbox','greasyfork');
  1171. makerow('Sleazy Fork','checkbox','sleazyfork');
  1172. makerow('Open UserJS','checkbox','openuserjs');
  1173. makerow('GitHub','checkbox','github');
  1174. makerow('Gist (GitHub)','checkbox','gist');
  1175. let rtime = makerow(`${lang.dtime} (ms)`,'number','time', {
  1176. defaultValue: 10000,
  1177. value: cfg.time,
  1178. min: 0,
  1179. step: 500,
  1180. onbeforeinput: (e) => {
  1181. if(e.target.validity.badInput) {
  1182. e.target.setAttribute('style','border-radius: 8px; border-width: 2px !important; border-style: solid; border-color: red !important;');
  1183. } else {
  1184. e.target.setAttribute('style','');
  1185. }
  1186. },
  1187. oninput: (e) => {
  1188. unsaved = true;
  1189. let t = e.target;
  1190. if(t.validity.badInput || t.validity.rangeUnderflow && t.value !== '-1') {
  1191. t.setAttribute('style','border-radius: 8px; border-width: 2px !important; border-style: solid; border-color: red !important;');
  1192. } else {
  1193. t.setAttribute('style','');
  1194. cfg.time = isEmpty(t.value) ? cfg.time : parseFloat(t.value);
  1195. }
  1196. }
  1197. });
  1198. let isvalid = true,
  1199. txta = make('textarea','tarea', {
  1200. name: 'blacklist',
  1201. id: 'blacklist',
  1202. rows: '10',
  1203. autocomplete: false,
  1204. spellcheck: false,
  1205. wrap: 'soft',
  1206. value: JSON.stringify(cfg.blacklist, null, ' '),
  1207. oninput: (e) => {
  1208. try {
  1209. cfg.blacklist = JSON.parse(e.target.value);
  1210. if(!isvalid) {
  1211. isvalid = true;
  1212. e.target.setAttribute('style','');
  1213. };
  1214. } catch(ex) {
  1215. isvalid = false;
  1216. err(ex);
  1217. };
  1218. },
  1219. }),
  1220. cbtn = make('magic-userjs', 'b', {
  1221. style: 'display: flex'
  1222. }),
  1223. savebtn = make('mujs-btn', 'save', {
  1224. style: 'margin: auto;',
  1225. innerHTML: lang.save,
  1226. onclick: (e) => {
  1227. halt(e);
  1228. if(rtime.validity.badInput || rtime.validity.rangeUnderflow && rtime.value !== '-1') {
  1229. return rtime.setAttribute('style','border-radius: 8px; border-width: 2px !important; border-style: solid; border-color: red !important;');
  1230. };
  1231. if(!isvalid) {
  1232. return txta.setAttribute('style','border-radius: 8px; border-width: 2px !important; border-style: solid; border-color: red !important;');
  1233. };
  1234. save();
  1235. if(rebuild) {
  1236. seen.clear();
  1237. rebuild = false;
  1238. preBuild();
  1239. };
  1240. if(/greasyfork\.org/.test(doc.location.hostname) && cfg.sleazyredirect) {
  1241. let otherSite = /greasyfork\.org/.test(document.location.hostname) ? 'sleazyfork' : 'greasyfork';
  1242. qs('span.sign-in-link') ? /scripts\/\d+/.test(document.location.href) ? !qs('#script-info') && (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a')) ? location.href = location.href.replace(/\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/, '//$1' + otherSite + '.org') : false : false : false;
  1243. };
  1244. },
  1245. }),
  1246. resetbtn = make('mujs-btn', 'reset', {
  1247. style: 'margin: auto;',
  1248. innerHTML: 'Reset',
  1249. onclick: (e) => {
  1250. halt(e);
  1251. MU.setValue('Config');
  1252. unsaved = true;
  1253. cfg = defcfg;
  1254. txta.value = JSON.stringify(cfg.blacklist, null, ' ');
  1255. for(let i of cfg.engines) {
  1256. if(sh(`#${i.name}`)) {
  1257. sh(`#${i.name}`).checked = i.enabled;
  1258. };
  1259. };
  1260. for(let i of shA('.magicuserjs-inlab input[type="checkbox"]')) {
  1261. if(!i.name.match(/((greasy|sleazy)fork|openuserjs|gi(thub|st))/gi)) {
  1262. i.checked = cfg[i.name];
  1263. };
  1264. };
  1265. },
  1266. });
  1267. cbtn.append(savebtn,resetbtn);
  1268. cfgpage.append(txta,cbtn);
  1269. },
  1270. //#endregion
  1271. fcopen = iconSVG.fsOpen,
  1272. fcclose = iconSVG.fsClose,
  1273. btnHide = make('mujs-btn','hide-list', {
  1274. title: lang.min,
  1275. innerHTML: iconSVG.hide,
  1276. onclick: (e) => {
  1277. halt(e);
  1278. main.classList.add('hidden');
  1279. mainframe.classList.remove('hidden');
  1280. timeoutFrame();
  1281. }
  1282. }),
  1283. btnfullscreen = make('mujs-btn','fullscreen', {
  1284. title: lang.max,
  1285. innerHTML: iconSVG.fullscreen,
  1286. onclick: (e) => {
  1287. halt(e);
  1288. if(btnfullscreen.classList.contains('expanded')) {
  1289. btnfullscreen.classList.remove('expanded');
  1290. main.classList.remove('expanded');
  1291. btnfullscreen.innerHTML = fcopen;
  1292. return;
  1293. };
  1294. btnfullscreen.classList.add('expanded');
  1295. main.classList.add('expanded');
  1296. btnfullscreen.innerHTML = fcclose;
  1297. }
  1298. }),
  1299. mainframe = make('magic-userjs','mainframe', {
  1300. onclick: (e) => {
  1301. e.preventDefault();
  1302. timeout.clear(...timeout.ids);
  1303. main.classList.remove('hidden');
  1304. mainframe.classList.add('hidden');
  1305. if(cfg.autoexpand) {
  1306. btnfullscreen.classList.add('expanded');
  1307. main.classList.add('expanded');
  1308. btnfullscreen.innerHTML = fcclose;
  1309. };
  1310. }
  1311. }),
  1312. mainbtn = make('count-frame','mainbtn', {
  1313. innerHTML: '0',
  1314. }),
  1315. fsearch = make('mujs-btn','hidden'),
  1316. ssearch = make('mujs-btn','hidden'),
  1317. filterList = make('input','searcher', {
  1318. style: 'width: 170px;',
  1319. autocomplete: 'off',
  1320. spellcheck: false,
  1321. type: 'text',
  1322. placeholder: lang.searcher,
  1323. oninput: (e) => {
  1324. e.preventDefault();
  1325. let v = e.target.value;
  1326. if(!isEmpty(v)) {
  1327. let reg = new RegExp(v,'gi');
  1328. for(let ujs of shA('.frame')) {
  1329. let m = ujs.children[0],
  1330. n = ujs.children[1],
  1331. final = m.textContent.match(reg) || n.textContent.match(reg) || [];
  1332. if(final.length === 0) {
  1333. ujs.classList.add('hidden');
  1334. } else {
  1335. ujs.classList.remove('hidden');
  1336. };
  1337. };
  1338. } else {
  1339. for(let ujs of shA('.frame')) {
  1340. ujs.classList.remove('hidden')
  1341. };
  1342. };
  1343. },
  1344. }),
  1345. filterBtn = make('mujs-btn','filter', {
  1346. title: lang.filterA,
  1347. innerHTML: iconSVG.filter,
  1348. onclick: (e) => {
  1349. e.preventDefault();
  1350. fsearch.classList.toggle('hidden');
  1351. }
  1352. }),
  1353. siteSearcher = make('input','searcher', {
  1354. style: 'width: 100px;',
  1355. autocomplete: 'off',
  1356. spellcheck: false,
  1357. type: 'text',
  1358. placeholder: thisHost,
  1359. onchange: (e) => {
  1360. e.preventDefault();
  1361. preBuild(e.target.value);
  1362. },
  1363. }),
  1364. siteSearchbtn = make('mujs-btn','search', {
  1365. title: lang.search,
  1366. innerHTML: iconSVG.search,
  1367. onclick: (e) => {
  1368. e.preventDefault();
  1369. ssearch.classList.toggle('hidden');
  1370. }
  1371. }),
  1372. closebtn = make('mujs-btn','close', {
  1373. title: lang.close,
  1374. innerHTML: iconSVG.close,
  1375. onclick: async (e) => {
  1376. halt(e);
  1377. container.remove();
  1378. ifram.remove();
  1379. }
  1380. }),
  1381. btnframe = make('mujs-column'),
  1382. btnHandles = make('mujs-column', 'btn-handles'),
  1383. btncfg = make('mujs-btn','settings', {
  1384. title: 'Settings',
  1385. innerHTML: iconSVG.cfg,
  1386. onclick: (e) => {
  1387. e.preventDefault();
  1388. if(sh('.saveerror')) {
  1389. sh('.saveerror').remove();
  1390. };
  1391. if(unsaved) {
  1392. let txt = make('mujs-row','saveerror', {
  1393. innerHTML: 'Unsaved changes'
  1394. });
  1395. tbody.prepend(txt);
  1396. delay(10000).then(() => txt.remove());
  1397. };
  1398. if(cfgpage.classList.contains('hidden')) {
  1399. cfgpage.classList.remove('hidden');
  1400. tbody.classList.add('hidden');
  1401. main.classList.add('auto-height');
  1402. if(ifram) {
  1403. ifram.setAttribute('style','height: 100%;');
  1404. };
  1405. } else {
  1406. cfgpage.classList.add('hidden');
  1407. tbody.classList.remove('hidden');
  1408. main.classList.remove('auto-height');
  1409. if(ifram) {
  1410. ifram.setAttribute('style','');
  1411. };
  1412. };
  1413. rebuild = false;
  1414. },
  1415. }),
  1416. btnhome = make('mujs-btn','github hidden', {
  1417. title: `GitHub (v${MU.info().script.version.includes('.') || MU.info().script.version.includes('Book') ? MU.info().script.version : MU.info().script.version.slice(0,5)})`,
  1418. innerHTML: iconSVG.gh,
  1419. onclick: (e) => {
  1420. halt(e);
  1421. MU.openInTab('https://github.com/magicoflolis/Userscript-Plus');
  1422. }
  1423. }),
  1424. btnissue = make('mujs-btn','issue hidden', {
  1425. title: lang.issue,
  1426. innerHTML: iconSVG.issue,
  1427. onclick: (e) => {
  1428. e.preventDefault();
  1429. MU.openInTab('https://github.com/magicoflolis/Userscript-Plus/issues/new');
  1430. }
  1431. }),
  1432. btngreasy = make('mujs-btn','greasy hidden', {
  1433. title: 'Greasy Fork',
  1434. innerHTML: iconSVG.gf,
  1435. onclick: (e) => {
  1436. e.preventDefault();
  1437. MU.openInTab('https://greasyfork.org/scripts/421603');
  1438. }
  1439. }),
  1440. btnnav = make('mujs-btn','nav', {
  1441. title: 'Navigation',
  1442. innerHTML: iconSVG.nav,
  1443. onclick: (e) => {
  1444. halt(e);
  1445. if(btngreasy.classList.contains('hidden')) {
  1446. btnissue.classList.remove('hidden');
  1447. btnhome.classList.remove('hidden');
  1448. btngreasy.classList.remove('hidden');
  1449. } else {
  1450. btnissue.classList.add('hidden');
  1451. btnhome.classList.add('hidden');
  1452. btngreasy.classList.add('hidden');
  1453. };
  1454. }
  1455. });
  1456. gfcountframe.append(gfcounter);
  1457. sfcountframe.append(sfcounter);
  1458. countframe.append(gfcountframe,sfcountframe);
  1459. fsearch.append(filterList);
  1460. ssearch.append(siteSearcher);
  1461. btnHandles.append(btnHide,btnfullscreen,closebtn);
  1462. btnframe.append(fsearch,filterBtn,ssearch,siteSearchbtn,btncfg,btnissue,btnhome,btngreasy,btnnav,btnHandles);
  1463. header.append(countframe,btnframe);
  1464. tbody.append(table);
  1465. makeTHead([
  1466. {
  1467. class: 'mujs-header-name',
  1468. textContent: 'Name'
  1469. },
  1470. {
  1471. textContent: 'Created by',
  1472. },
  1473. {
  1474. textContent: lang.daily,
  1475. },
  1476. {
  1477. textContent: lang.updated,
  1478. },
  1479. {
  1480. textContent: lang.install,
  1481. },
  1482. ]);
  1483. for (const th of tabhead.rows[0].cells) {
  1484. if(th.textContent === lang.install) continue;
  1485. th.classList.add('mujs-pointer');
  1486. ael(th, 'click', () => {
  1487. sortRowBy(th.cellIndex);
  1488. });
  1489. };
  1490. main.append(header,tbody,cfgpage);
  1491. mainframe.append(mainbtn);
  1492. injCon.append(usercss,mainframe,main);
  1493. makecfg();
  1494. preBuild();
  1495. timeoutFrame();
  1496. ael(win,'beforeunload', () => {
  1497. container.remove();
  1498. ifram.remove();
  1499. });
  1500. } catch(ex) {handleError(ex)}
  1501. };
  1502.  
  1503. function containerInject() {
  1504. try {
  1505. info('Injecting Container...');
  1506. if(container.attachShadow instanceof Function) {
  1507. doc.body.append(container);
  1508. container.attachShadow({mode: 'open'});
  1509. return main();
  1510. };
  1511. ael(ifram, 'load', () => {
  1512. ifram.contentDocument.documentElement.classList.add('mujs-iframe');
  1513. ifram.contentDocument.body.classList.add('mujs-iframe');
  1514. main();
  1515. });
  1516. doc.body.append(ifram);
  1517. } catch(ex) {handleError(ex)}
  1518. };
  1519.  
  1520. async function stateChange(event) {
  1521. const evt = event.target ?? doc;
  1522. if(Object.is(evt.readyState,'complete')) {
  1523. containerInject();
  1524. };
  1525. };
  1526.  
  1527. async function setupConfig() {
  1528. try {
  1529. cfg = await MU.getValue('Config',defcfg);
  1530. for (const key in defcfg) {
  1531. if(!Object.hasOwn(cfg, key)) {
  1532. cfg[key] = defcfg[key];
  1533. } else if (key === 'lang') {
  1534. for (const keyl in defcfg[key]) {
  1535. if(!Object.hasOwn(cfg[key], keyl)) {
  1536. cfg[key][keyl] = defcfg[key][keyl];
  1537. };
  1538. };
  1539. } else if (key === 'engines') {
  1540. for (const key2 in defcfg[key]) {
  1541. if(!Object.hasOwn(cfg[key], key2)) {
  1542. cfg[key][key2] = defcfg[key][key2];
  1543. };
  1544. };
  1545. } else if (key === 'blacklist') {
  1546. for (const key3 in defcfg[key]) {
  1547. if(!Object.hasOwn(cfg[key], key3)) {
  1548. cfg[key][key3] = defcfg[key][key3];
  1549. };
  1550. };
  1551. }
  1552. };
  1553. dbg('Config:',cfg);
  1554. if(Object.is(doc.readyState,'complete')) {
  1555. containerInject();
  1556. } else {
  1557. ael(doc,'readystatechange',stateChange);
  1558. };
  1559. } catch(ex) {
  1560. handleError(ex)
  1561. };
  1562. };
  1563. //#region Console
  1564. function dbg(...msg) {
  1565. const dt = new Date(Date.now());
  1566. return console.log('[%cAF%c] %cDBG', 'color: rgb(29, 155, 240);', '', 'color: rgb(255, 212, 0);', `[${dt.getHours()}:${('0' + dt.getMinutes()).slice(-2)}]`, ...msg);
  1567. };
  1568. function err(...msg) {
  1569. return console.error('[%cUserJS%c] %cERROR', 'color: rgb(29, 155, 240);', '', 'color: rgb(249, 24, 128);', ...msg);
  1570. };
  1571. /**
  1572. * Displays error messages in webpage
  1573. * @param {Object|string} error - Error Object or message
  1574. */
  1575. // TODO expand upon function
  1576. function handleError(error) {
  1577. const emsg = error.fn ? `${error.fn} ERROR: ${error.message}` : error;
  1578. return err(emsg);
  1579. };
  1580. function info(...msg) {
  1581. return console.info('[%cUserJS%c] %cINF', 'color: rgb(29, 155, 240);', '', 'color: rgb(0, 186, 124);', ...msg);
  1582. };
  1583. function log(...msg) {
  1584. return console.log('[%cUserJS%c] %cLOG', 'color: rgb(29, 155, 240);', '', 'color: rgb(219, 160, 73);', ...msg);
  1585. };
  1586. //#endregion
  1587.  
  1588. if(!win.frameElement) {
  1589. setupConfig();
  1590. };
  1591.  
  1592. })();