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

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

目前为 2023-12-03 提交的版本,查看 最新版本

  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 6.1.0
  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. // @grant GM_xmlhttpRequest
  34. // @grant GM_openInTab
  35. // @grant GM_getValue
  36. // @grant GM_setValue
  37. // @grant GM_info
  38. // @compatible chrome
  39. // @compatible firefox
  40. // @compatible edge
  41. // @compatible opera
  42. // @compatible safari
  43. // @noframes
  44. // @run-at document-start
  45. // ==/UserScript==
  46.  
  47. /** Injected stylesheet https://github.com/magicoflolis/Userscript-Plus/tree/master/userscript/src/sass */
  48. const main_css = `mujs-root *{scrollbar-color:#fff #2e323d;scrollbar-width:thin;background:#495060;color:#fff}@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:10px;margin-top:3px;margin-bottom:3px;box-shadow:inset 0 0 6px rgba(0,0,0,.3)}mujs-root * ::-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)}mujs-root * ::-webkit-scrollbar-thumb:hover{background-color:#fff}}mu-js{line-height:normal}.mujs-cfg{line-height:1.5}body.webext-page,.main{font-size:14px}mujs-column,mujs-row,.mujs-sty-flex{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}mu-js{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}.mainframe{background:rgba(0,0,0,0);position:fixed;bottom:1rem;right:1rem}.mainframe count-frame{width:2em;height:1em}.mainframe:not(.hidden){z-index:100000000000000000 !important;display:block}count-frame{border-radius:16px;padding:5px;border:2px solid rgba(0,0,0,0);font-size:16px;font-weight:400;display:inline-block;text-align:center;min-width:1em}.mujs-header-prim{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}.mujs-body{overflow-x:hidden;order:1}.mujs-body .mujs-ratings{padding:0 .25em;border:1px solid #fff;border-radius:10px}.mujs-body mu-jsbtn svg{fill:#fff;width:14px;height:14px;background:rgba(0,0,0,0)}.mujs-cfg,.mujs-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){.mujs-cfg{margin:0px auto 1rem auto !important}}.mujs-cfg{height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media screen and (max-height: 812px){.mujs-cfg:not(.webext-page){flex-wrap:wrap;flex-direction:row !important}}.mujs-cfg mujs-section>label{display:flex;justify-content:space-between}.mujs-cfg mujs-section>label input:not([type=checkbox]){position:relative;border-radius:4px;border:1px solid #fff}.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:rgba(255,255,255,.568)}.mujs-cfg .mujs-inlab input[type*=checkbox]:checked+label:before{right:0px}.mujs-cfg .mujs-inlab input[type*=checkbox][id=greasyfork]:checked+label,.mujs-cfg .mujs-inlab input[type*=checkbox][id=sleazyfork]:checked+label{background-color:rgba(0,183,255,.568)}.mujs-cfg .mujs-inlab input[type*=checkbox][id=openuserjs]:checked+label{background-color:rgba(237,63,20,.568)}.mujs-cfg .mujs-inlab input[type*=checkbox][id=github]:checked+label{background-color:rgba(36,41,47,.568)}.mujs-cfg .mujs-inlab label{padding:0;display:block;overflow:hidden;height:16px;border-radius:20px;border:1px solid #fff;background-color:#495060}.mujs-cfg .mujs-inlab label:before{content:"";display:block;width:20px;height:20px;margin:-2px;background:#fff;position:absolute;top:0;right:20px;border-radius:20px}.mujs-cfg [id=blacklist]{overflow-y:auto;background:#000;color:#fff;resize:vertical;outline:none;border-style:none;font-family:monospace}.mujs-cfg [id=blacklist]:focus{outline:none}.mujs-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.mujs-uframe,table td.mujs-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}}mujs-a{display:inline-block}mujs-a.mujs-euser{padding-left:.5rem;padding-right:.5rem}@media screen and (max-width: 800px){.frame:not(.webext-page){display:grid}.frame:not(.webext-page) mu-jsbtn{margin-left:25%;margin-right:25%}}.frame.sf mujs-a{color:#e75531 !important}.frame.sf mu-jsbtn{background-color:#ed3f14 !important;border-color:#ed3f14 !important}.frame:not(.sf) mujs-a{color:#00b7ff}.frame:not(.sf) mu-jsbtn{color:#fff;background-color:#2d8cf0;border-color:#2d8cf0}.mujs-name{display:grid}.mujs-name>*:not(.mujs-homepage){margin-top:3px}.mujs-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}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}input:not([type=checkbox]){border:rgba(0,0,0,0);outline:none !important}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}th,.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}mujs-btn,input,.mujs-homepage{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}.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}
  49. `;
  50.  
  51. (() => {
  52. let userjs = (self.userjs = {})
  53. // Skip text/plain documents.
  54. if (
  55. (document instanceof Document ||
  56. (document instanceof XMLDocument &&
  57. document.createElement('div') instanceof HTMLDivElement)) &&
  58. /^image\/|^text\/plain/.test(document.contentType || '') === false &&
  59. (self.userjs instanceof Object === false || userjs.UserJS !== true)
  60. ) {
  61. userjs = self.userjs = { UserJS: true }
  62. }
  63.  
  64. let cfg = {}
  65. let lang = {}
  66. let legacyMsg = null
  67.  
  68. //#region Console
  69. const err = (...msg) => {
  70. console.error(
  71. '[%cUserJS%c] %cERROR',
  72. 'color: rgb(29, 155, 240);',
  73. '',
  74. 'color: rgb(249, 24, 128);',
  75. ...msg,
  76. )
  77. }
  78. const info = (...msg) => {
  79. console.info(
  80. '[%cUserJS%c] %cINF',
  81. 'color: rgb(29, 155, 240);',
  82. '',
  83. 'color: rgb(0, 186, 124);',
  84. ...msg,
  85. )
  86. }
  87. const log = (...msg) => {
  88. console.log(
  89. '[%cUserJS%c] %cLOG',
  90. 'color: rgb(29, 155, 240);',
  91. '',
  92. 'color: rgb(219, 160, 73);',
  93. ...msg,
  94. )
  95. }
  96. //#endregion
  97. const MU = {}
  98. const hasOwn = Object.hasOwn || Object.prototype.hasOwnProperty.call
  99. const isElem = (obj) => {
  100. /** @type { string } */
  101. const s = Object.prototype.toString.call(obj)
  102. return s.includes('Element')
  103. }
  104. const isStr = (obj) => {
  105. /** @type { string } */
  106. const s = Object.prototype.toString.call(obj)
  107. return s.includes('String')
  108. }
  109. const isObj = (obj) => {
  110. /** @type { string } */
  111. const s = Object.prototype.toString.call(obj)
  112. return s.includes('Object')
  113. }
  114. const isFN = (obj) => {
  115. /** @type { string } */
  116. const s = Object.prototype.toString.call(obj)
  117. return s.includes('Function')
  118. }
  119. /**
  120. * Object is Null
  121. * @param {*} obj - Object
  122. * @returns {boolean} Returns if statement true or false
  123. */
  124. const isNull = (obj) => {
  125. return Object.is(obj, null) || Object.is(obj, undefined)
  126. }
  127. /**
  128. * Object is Blank
  129. * @param {*} obj - Array, Set, Object or String
  130. * @returns {boolean} Returns if statement true or false
  131. */
  132. const isBlank = (obj) => {
  133. return (
  134. (typeof obj === 'string' && Object.is(obj.trim(), '')) ||
  135. ((obj instanceof Set || obj instanceof Map) && Object.is(obj.size, 0)) ||
  136. (Array.isArray(obj) && Object.is(obj.length, 0)) ||
  137. (isObj(obj) && Object.is(Object.keys(obj).length, 0))
  138. )
  139. }
  140. /**
  141. * Object is Empty
  142. * @param {*} obj - Array, object or string
  143. * @returns {boolean} Returns if statement true or false
  144. */
  145. const isEmpty = (obj) => {
  146. return isNull(obj) || isBlank(obj)
  147. }
  148. /**
  149. * @template B
  150. * @param { {} } objA
  151. * @param { B } objB
  152. * @returns { B }
  153. */
  154. const setObj = (objA = {}, objB = {}) => {
  155. objA = objA || {}
  156. objB = objB || {}
  157. for (const [key, value] of Object.entries(objA)) {
  158. if (!hasOwn(objB, key)) {
  159. objB[key] = value
  160. } else if (typeof value === 'object') {
  161. setObj(value, objB[key])
  162. }
  163. }
  164. return objB
  165. }
  166. const normalizeTarget = (target, root = document, toQuery = true) => {
  167. if (isNull(target)) {
  168. return []
  169. }
  170. if (Array.isArray(target)) {
  171. return target
  172. }
  173. if (isStr(target)) {
  174. return toQuery ? Array.from(root.querySelectorAll(target)) : [target]
  175. }
  176. if (isElem(target)) {
  177. return [target]
  178. }
  179. // if (target instanceof Element) {
  180. // return [target]
  181. // }
  182. return Array.from(target)
  183. }
  184. class dom {
  185. static attr(target, attr, value = undefined) {
  186. for (const elem of normalizeTarget(target)) {
  187. if (value === undefined) {
  188. return elem.getAttribute(attr)
  189. }
  190. if (value === null) {
  191. elem.removeAttribute(attr)
  192. } else {
  193. elem.setAttribute(attr, value)
  194. }
  195. }
  196. }
  197.  
  198. /**
  199. * @template { keyof HTMLElementTagNameMap } K
  200. * @param { K } a
  201. * @returns { HTMLElementTagNameMap[K] | undefined }
  202. */
  203. static create(a) {
  204. if (typeof a === 'string') {
  205. return document.createElement(a)
  206. }
  207. }
  208.  
  209. static prop(target, prop, value = undefined) {
  210. for (const elem of normalizeTarget(target)) {
  211. if (value === undefined) {
  212. return elem[prop]
  213. }
  214. elem[prop] = value
  215. }
  216. }
  217.  
  218. static text(target, text) {
  219. const targets = normalizeTarget(target)
  220. if (text === undefined) {
  221. return targets.length !== 0 ? targets[0].textContent : undefined
  222. }
  223. for (const elem of targets) {
  224. elem.textContent = text
  225. }
  226. }
  227. }
  228. dom.cl = class {
  229. static add(target, name) {
  230. if (Array.isArray(name)) {
  231. for (const elem of normalizeTarget(target)) {
  232. elem.classList.add(...name)
  233. }
  234. } else {
  235. for (const elem of normalizeTarget(target)) {
  236. elem.classList.add(name)
  237. }
  238. }
  239. }
  240.  
  241. static remove(target, name) {
  242. if (Array.isArray(name)) {
  243. for (const elem of normalizeTarget(target)) {
  244. elem.classList.remove(...name)
  245. }
  246. } else {
  247. for (const elem of normalizeTarget(target)) {
  248. elem.classList.remove(name)
  249. }
  250. }
  251. }
  252.  
  253. static toggle(target, name, state) {
  254. let r
  255. for (const elem of normalizeTarget(target)) {
  256. r = elem.classList.toggle(name, state)
  257. }
  258. return r
  259. }
  260.  
  261. static has(target, name) {
  262. for (const elem of normalizeTarget(target)) {
  263. if (elem.classList.contains(name)) {
  264. return true
  265. }
  266. }
  267. return false
  268. }
  269. }
  270. class Supports {
  271. static gm = typeof GM !== 'undefined'
  272. }
  273. const isMobile = /Mobile|Tablet/.test(navigator.userAgent)
  274. const navLang = navigator.language.split('-')[0] ?? 'en'
  275. const alang = []
  276. const defcfg = {
  277. injection: 'interactive',
  278. cache: true,
  279. autoexpand: false,
  280. filterlang: false,
  281. sleazyredirect: false,
  282. time: 10000,
  283. blacklist: [
  284. {
  285. enabled: true,
  286. regex: true,
  287. flags: '',
  288. name: 'Blacklist 1',
  289. url: '(gov|cart|checkout|login|join|signin|signup|sign-up|password|reset|password_reset)',
  290. },
  291. {
  292. enabled: true,
  293. regex: true,
  294. flags: '',
  295. name: 'Blacklist 2',
  296. url: '(pay|bank|money|localhost|authorize|checkout|bill|wallet|router)',
  297. },
  298. {
  299. enabled: true,
  300. regex: false,
  301. flags: '',
  302. name: 'Blacklist 3',
  303. url: 'https://home.bluesnap.com',
  304. },
  305. {
  306. enabled: true,
  307. regex: false,
  308. flags: '',
  309. name: 'Blacklist 4',
  310. url: ['zalo.me', 'skrill.com'],
  311. },
  312. ],
  313. engines: [
  314. {
  315. enabled: true,
  316. name: 'greasyfork',
  317. url: 'https://greasyfork.org',
  318. },
  319. {
  320. enabled: true,
  321. name: 'sleazyfork',
  322. url: 'https://sleazyfork.org',
  323. },
  324. {
  325. enabled: false,
  326. name: 'openuserjs',
  327. url: 'https://openuserjs.org/?q=',
  328. },
  329. {
  330. enabled: false,
  331. name: 'github',
  332. url: 'https://api.github.com/search/code?q=',
  333. token: '',
  334. },
  335. ],
  336. }
  337. const langs = {
  338. en: {
  339. legacy: 'PLEASE RESET YOUR CONFIG!',
  340. createdby: 'Created by',
  341. name: 'Name',
  342. daily: 'Daily Installs',
  343. close: 'Close',
  344. filterA: 'Filter',
  345. max: 'Maximize',
  346. min: 'Minimize',
  347. search: 'Search',
  348. searcher: 'Title | Description | Author...',
  349. install: 'Install',
  350. issue: 'New Issue',
  351. version: 'Version',
  352. updated: 'Last Updated',
  353. total: 'Total Installs',
  354. rating: 'Ratings',
  355. good: 'Good',
  356. ok: 'Ok',
  357. bad: 'Bad',
  358. created: 'Created',
  359. redirect: 'Greasy Fork for adults',
  360. filter: 'Filter out other languages',
  361. dtime: 'Display Timeout',
  362. save: 'Save',
  363. },
  364. es: {
  365. legacy: 'PLEASE RESET YOUR CONFIG!',
  366. createdby: 'Created by',
  367. name: 'Name',
  368. daily: 'Instalaciones diarias',
  369. close: 'Ya no se muestra',
  370. filterA: 'Filtro',
  371. max: 'Maximizar',
  372. min: 'Minimizar',
  373. search: 'Busque en',
  374. searcher: 'Título | Descripción | Autor...',
  375. install: 'Instalar',
  376. issue: 'Nueva edición',
  377. version: 'Versión',
  378. updated: 'Última actualización',
  379. total: 'Total de instalaciones',
  380. rating: 'Clasificaciones',
  381. good: 'Bueno',
  382. ok: 'Ok',
  383. bad: 'Malo',
  384. created: 'Creado',
  385. redirect: 'Greasy Fork para adultos',
  386. filter: 'Filtrar otros idiomas',
  387. dtime: 'Mostrar el tiempo de espera',
  388. save: 'Guardar',
  389. },
  390. ru: {
  391. legacy: 'PLEASE RESET YOUR CONFIG!',
  392. createdby: 'Created by',
  393. name: 'Name',
  394. daily: 'Ежедневные установки',
  395. close: 'Больше не показывать',
  396. filterA: 'Фильтр',
  397. max: 'Максимизировать',
  398. min: 'Минимизировать',
  399. search: 'Поиск',
  400. searcher: 'Название | Описание | Автор...',
  401. install: 'Установите',
  402. issue: 'Новый выпуск',
  403. version: 'Версия',
  404. updated: 'Последнее обновление',
  405. total: 'Всего установок',
  406. rating: 'Рейтинги',
  407. good: 'Хорошо',
  408. ok: 'Хорошо',
  409. bad: 'Плохо',
  410. created: 'Создано',
  411. redirect: 'Greasy Fork для взрослых',
  412. filter: 'Отфильтровать другие языки',
  413. dtime: 'Тайм-аут отображения',
  414. save: 'Сохранить',
  415. },
  416. ja: {
  417. legacy: 'PLEASE RESET YOUR CONFIG!',
  418. createdby: 'Created by',
  419. name: 'Name',
  420. daily: 'デイリーインストール',
  421. close: '表示されなくなりました',
  422. filterA: 'フィルター',
  423. max: '最大化',
  424. min: 'ミニマム',
  425. search: '検索',
  426. searcher: 'タイトル|説明|著者...',
  427. install: 'インストール',
  428. issue: '新刊のご案内',
  429. version: 'バージョン',
  430. updated: '最終更新日',
  431. total: '総インストール数',
  432. rating: 'レーティング',
  433. good: 'グッド',
  434. ok: '良い',
  435. bad: '悪い',
  436. created: '作成',
  437. redirect: '大人のGreasyfork',
  438. filter: '他の言語をフィルタリングする',
  439. dtime: '表示タイムアウト',
  440. save: '拯救',
  441. },
  442. fr: {
  443. createdby: 'Created by',
  444. name: 'Name',
  445. daily: 'Installations quotidiennes',
  446. close: 'Ne plus montrer',
  447. filterA: 'Filtre',
  448. max: 'Maximiser',
  449. min: 'Minimiser',
  450. search: 'Recherche',
  451. searcher: 'Titre | Description | Auteur...',
  452. install: 'Installer',
  453. issue: 'Nouveau numéro',
  454. version: 'Version',
  455. updated: 'Dernière mise à jour',
  456. total: 'Total des installations',
  457. rating: 'Notations',
  458. good: 'Bon',
  459. ok: 'Ok',
  460. bad: 'Mauvais',
  461. created: 'Créé',
  462. redirect: 'Greasy Fork pour les adultes',
  463. filter: 'Filtrer les autres langues',
  464. dtime: "Délai d'affichage",
  465. save: 'Sauvez',
  466. },
  467. zh: {
  468. legacy: 'PLEASE RESET YOUR CONFIG!',
  469. createdby: 'Created by',
  470. name: 'Name',
  471. daily: '日常安装',
  472. close: '不再显示',
  473. filterA: '过滤器',
  474. max: '最大化',
  475. min: '最小化',
  476. search: '搜索',
  477. searcher: '标题|描述|作者...',
  478. install: '安装',
  479. issue: '新问题',
  480. version: '版本',
  481. updated: '最后更新',
  482. total: '总安装量',
  483. rating: '评级',
  484. good: '好的',
  485. ok: '好的',
  486. bad: '不好',
  487. created: '创建',
  488. redirect: '大人的Greasyfork',
  489. filter: '过滤掉其他语言',
  490. dtime: '显示超时',
  491. save: '拯救',
  492. },
  493. nl: {
  494. legacy: 'PLEASE RESET YOUR CONFIG!',
  495. createdby: 'Created by',
  496. name: 'Name',
  497. daily: 'Dagelijkse Installaties',
  498. close: 'Sluit',
  499. filterA: 'Filter',
  500. max: 'Maximaliseer',
  501. min: 'Minimaliseer',
  502. search: 'Zoek',
  503. searcher: 'Titel | Beschrijving | Auteur...',
  504. install: 'Installeer',
  505. issue: 'Nieuw Issue',
  506. version: 'Versie',
  507. updated: 'Laatste Update',
  508. total: 'Totale Installaties',
  509. rating: 'Beoordeling',
  510. good: 'Goed',
  511. ok: 'Ok',
  512. bad: 'Slecht',
  513. created: 'Aangemaakt',
  514. redirect: 'Greasy Fork voor volwassenen',
  515. filter: 'Filter andere talen',
  516. dtime: 'Weergave timeout',
  517. save: 'Opslaan',
  518. },
  519. }
  520. /**
  521. * preventDefault + stopPropagation
  522. * @param {Event} e - Selected Element
  523. */
  524. const halt = (e) => {
  525. e.preventDefault()
  526. e.stopPropagation()
  527. }
  528. /**
  529. * Add Event Listener
  530. * @template { keyof HTMLElementEventMap } K
  531. * @template { HTMLElement } R
  532. * @param { R } root - Selected Element
  533. * @param { K } event - root Event Listener
  534. * @param { (this: R, ev: HTMLElementEventMap[K]) => any } callback - Callback function
  535. * @param { boolean | AddEventListenerOptions } [options={}] - (Optional) Options
  536. */
  537. const ael = (root, event, callback, options = {}) => {
  538. let el
  539. try {
  540. el =
  541. root ||
  542. document ||
  543. document.querySelector(':root') ||
  544. document.documentElement ||
  545. document.head ||
  546. document.body
  547. if (isMobile && event === 'click') {
  548. event = 'mouseup'
  549. el.addEventListener('touchstart', callback)
  550. el.addEventListener('touchend', callback)
  551. }
  552. if (event === 'fclick') {
  553. event = 'click'
  554. }
  555. el.addEventListener(event, callback, options)
  556. } catch (ex) {
  557. err(ex)
  558. }
  559. }
  560. /**
  561. * Prefix for `document.querySelectorAll()`
  562. * @template { Element } E
  563. * @param { string } selectors - Elements for query selection
  564. * @param { E } root - Root selector Element
  565. * @returns { NodeListOf<E> }
  566. */
  567. const qsA = (selectors, root) => {
  568. try {
  569. return (root || document).querySelectorAll(selectors)
  570. } catch (ex) {
  571. err(ex)
  572. }
  573. return []
  574. }
  575. /**
  576. * Prefix for `document.querySelector()`
  577. * @template { Element } E
  578. * @param { string } selector - Element for query selection
  579. * @param { E } root - Root selector Element
  580. * @returns { E | null }
  581. */
  582. const qs = (selector, root) => {
  583. try {
  584. return (root || document).querySelector(selector)
  585. } catch (ex) {
  586. err(ex)
  587. }
  588. return null
  589. }
  590. /**
  591. * Prefix for `document.querySelector()` w/ Promise
  592. * @template { Element } E
  593. * @param { string } selector - Element for query selection
  594. * @param { E } root - Root selector Element
  595. * @returns { Promise<E | null> }
  596. */
  597. const query = async (selector, root) => {
  598. let el = null
  599. try {
  600. el = root || document
  601. while (isNull(el.querySelector(selector))) {
  602. await new Promise((resolve) => requestAnimationFrame(resolve))
  603. }
  604. return el.querySelector(selector)
  605. } catch (ex) {
  606. err(ex)
  607. }
  608. return el
  609. }
  610. const formAttrs = (elem, attr = {}) => {
  611. if (isElem(elem)) {
  612. for (const key in attr) {
  613. if (isObj(attr[key])) {
  614. formAttrs(elem[key], attr[key])
  615. } else if (isFN(attr[key])) {
  616. if (key === 'container') {
  617. key()
  618. continue
  619. }
  620. if (/^on/.test(key)) {
  621. elem[key] = attr[key]
  622. continue
  623. }
  624. ael(elem, key, attr[key])
  625. } else if (key === 'class') {
  626. elem.className = attr[key]
  627. } else {
  628. elem[key] = attr[key]
  629. }
  630. }
  631. }
  632. }
  633. /**
  634. * Create/Make Element
  635. * @template { keyof HTMLElementTagNameMap } K
  636. * @param { K } tagName - Element to create
  637. * @param { string } cname - (Optional) Element class name
  638. * @param { keyof HTMLElement } [attrs={}] - (Optional) Element attributes
  639. * @returns { HTMLElementTagNameMap[K] } Returns created Element
  640. */
  641. const make = (tagName, cname, attrs = {}) => {
  642. let el
  643. try {
  644. el = dom.create(tagName)
  645. if (!isEmpty(cname) && isStr(cname)) {
  646. el.className = cname
  647. }
  648. if (!isEmpty(attrs) && isObj(attrs)) {
  649. formAttrs(el, attrs)
  650. }
  651. } catch (ex) {
  652. err(ex)
  653. }
  654. return el
  655. }
  656. const iconSVG = {
  657. 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>',
  658. close:
  659. '<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>',
  660. filter:
  661. '<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>',
  662. fsClose:
  663. '<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>',
  664. fsOpen:
  665. '<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>',
  666. fullscreen:
  667. '<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>',
  668. 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>',
  669. 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>',
  670. 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>',
  671. install:
  672. '<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>',
  673. issue:
  674. '<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>',
  675. 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>',
  676. 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>',
  677. search:
  678. '<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>',
  679. }
  680. const Timeout = class {
  681. constructor() {
  682. this.ids = []
  683. }
  684.  
  685. set(delay, reason) {
  686. return new Promise((resolve, reject) => {
  687. const id = setTimeout(() => {
  688. isNull(reason) ? resolve() : reject(reason)
  689. this.clear(id)
  690. }, delay)
  691. this.ids.push(id)
  692. })
  693. }
  694.  
  695. clear(...ids) {
  696. this.ids = this.ids.filter((id) => {
  697. if (ids.includes(id)) {
  698. clearTimeout(id)
  699. return false
  700. }
  701. return true
  702. })
  703. }
  704. }
  705. const bscStr = (str = '', lowerCase = true) => {
  706. const txt = str[lowerCase ? 'toLowerCase' : 'toUpperCase']()
  707. return txt.replaceAll(/\W/g, '')
  708. }
  709. const Network = {
  710. /**
  711. * Fetch a URL with fetch API as fallback
  712. * @param { RequestInfo | URL } url
  713. * @param { GM.Request["method"] | Request["method"] } method
  714. * @param { GM.Request["responseType"] | Network["responseType"] } responseType
  715. * @param { RequestInit | GM.Request | XMLHttpRequest } data
  716. * @param { boolean } forcefetch
  717. * @returns { Promise<GM.Response<any> | Response> }
  718. * When GM is supported, makes a request like XMLHttpRequest, with some special capabilities, not restricted by same-origin policy
  719. * @link https://violentmonkey.github.io/api/gm/#gm_xmlhttprequest
  720. * @link https://developer.mozilla.org/docs/Web/API/Fetch_API
  721. */
  722. fetchURL(
  723. url,
  724. method = 'GET',
  725. responseType = 'json',
  726. data = {},
  727. forcefetch = false,
  728. ) {
  729. return new Promise((resolve, reject) => {
  730. if (isEmpty(url)) {
  731. reject(new Error('URL field is blank'))
  732. }
  733. method = bscStr(method, false)
  734. responseType = bscStr(responseType)
  735. const params = {
  736. method,
  737. ...data,
  738. }
  739. if (Supports.gm && !forcefetch) {
  740. if (params.credentials) {
  741. Object.assign(params, {
  742. anonymous: false,
  743. })
  744. if (Object.is(params.credentials, 'omit')) {
  745. Object.assign(params, {
  746. anonymous: true,
  747. })
  748. }
  749. delete params.credentials
  750. }
  751. } else if (params.onprogress) {
  752. delete params.onprogress
  753. }
  754. /**
  755. * @param { Response } response
  756. * @returns { Response | Document }
  757. */
  758. const fetchResp = (response) => {
  759. if (!response.ok) reject(response)
  760. const check = (str = 'text') => {
  761. return isFN(response[str]) ? response[str]() : response
  762. }
  763. if (responseType.match(/buffer/i)) {
  764. resolve(check('arrayBuffer'))
  765. } else if (responseType.match(/json/i)) {
  766. resolve(check('json'))
  767. } else if (responseType.match(/text/i)) {
  768. resolve(check('text'))
  769. } else if (responseType.match(/blob/i)) {
  770. resolve(check('blob'))
  771. } else if (responseType.match(/formdata/i)) {
  772. resolve(check('formData'))
  773. } else if (responseType.match(/clone/i)) {
  774. resolve(check('clone'))
  775. } else if (responseType.match(/document/i) && isFN(response.text)) {
  776. const respData = new DOMParser().parseFromString(
  777. response.text(),
  778. 'text/html',
  779. )
  780. resolve(respData)
  781. }
  782. resolve(response)
  783. }
  784. if (responseType.match(/buffer/i)) {
  785. fetch(url, params).then(fetchResp)
  786. } else if (Supports.gm && !forcefetch) {
  787. Network.xmlRequest({
  788. url,
  789. responseType,
  790. ...params,
  791. onerror: reject,
  792. onload: (r) => {
  793. if (r.status !== 200) reject(new Error(`${r.status} ${url}`))
  794. if (responseType.match(/basic/i)) resolve(r)
  795. resolve(r.response)
  796. },
  797. })
  798. } else {
  799. fetch(url, params).then(fetchResp)
  800. }
  801. }).catch(err)
  802. },
  803. format(bytes, decimals = 2) {
  804. if (Number.isNaN(bytes)) return '0 Bytes'
  805. const k = 1024
  806. const dm = decimals < 0 ? 0 : decimals
  807. const i = Math.floor(Math.log(bytes) / Math.log(k))
  808. return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${
  809. Network.sizes[i]
  810. }`
  811. },
  812. prog(evt) {
  813. return Object.is(evt.total, 0)
  814. ? Network.format(evt.loaded)
  815. : `${+((evt.loaded / evt.total) * 100).toFixed(2)}%`
  816. },
  817. sizes: ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
  818. xmlRequest(details) {
  819. try {
  820. if (Supports.gm) {
  821. const req = isFN(GM.xmlHttpRequest)
  822. ? GM.xmlHttpRequest
  823. : GM_xmlhttpRequest
  824. return req(details)
  825. }
  826. return new Promise((resolve, reject) => {
  827. const req = new XMLHttpRequest()
  828. let method = 'GET'
  829. let url = 'about:blank'
  830. let body
  831. for (const [key, value] of Object.entries(details)) {
  832. if (key === 'onload') {
  833. req.addEventListener('load', () => {
  834. if (isFN(value)) {
  835. value(req)
  836. }
  837. resolve(req)
  838. })
  839. } else if (key === 'onerror') {
  840. req.addEventListener('error', (evt) => {
  841. if (isFN(value)) {
  842. value(evt)
  843. }
  844. reject(evt)
  845. })
  846. } else if (key === 'onabort') {
  847. req.addEventListener('abort', (evt) => {
  848. if (isFN(value)) {
  849. value(evt)
  850. }
  851. reject(evt)
  852. })
  853. } else if (key === 'onprogress') {
  854. req.addEventListener('progress', value)
  855. } else if (key === 'responseType') {
  856. if (value.match(/buffer|blob|document|json|text/i)) {
  857. if (value.match(/buffer/i)) {
  858. req.responseType = 'arraybuffer'
  859. } else {
  860. req.responseType = value
  861. }
  862. }
  863. } else if (key === 'method') {
  864. method = value
  865. } else if (key === 'url') {
  866. url = value
  867. } else if (key === 'body') {
  868. body = value
  869. }
  870. }
  871. req.open(method, url)
  872.  
  873. if (isEmpty(req.responseType)) {
  874. req.responseType = 'text'
  875. }
  876.  
  877. if (body) {
  878. req.send(body)
  879. } else {
  880. req.send()
  881. }
  882. })
  883. } catch (ex) {
  884. err(ex)
  885. }
  886. },
  887. }
  888. /**
  889. * Get info of script
  890. * @returns {object} Script info
  891. * @link https://violentmonkey.github.io/api/gm/#gm_info
  892. */
  893. MU.info = Supports.gm
  894. ? isFN(GM.info)
  895. ? GM.info
  896. : GM_info
  897. : {
  898. script: {
  899. icon: '',
  900. name: 'Magic Userscript+',
  901. namespace: 'https://github.com/magicoflolis/Userscript-Plus',
  902. updateURL: 'https://github.com/magicoflolis/Userscript-Plus/releases',
  903. version: 'Bookmarklet',
  904. },
  905. }
  906.  
  907. MU.tab = {
  908. /**
  909. * Open a new window
  910. * @param {string} url - URL of webpage to open
  911. * @param {object} params - GM parameters
  912. * @returns {object} GM_openInTab object with Window object as a fallback
  913. * @link https://violentmonkey.github.io/api/gm/#gm_openintab
  914. * @link https://developer.mozilla.org/docs/Web/API/Window/open
  915. */
  916. open(
  917. url,
  918. params = {
  919. active: true,
  920. insert: true,
  921. },
  922. features,
  923. ) {
  924. if (!Supports.gm && isBlank(params)) {
  925. params = '_blank'
  926. }
  927. if (features) {
  928. return window.open(url, params, features)
  929. }
  930. if (Supports.gm) {
  931. let GMType
  932. if (isFN(GM.openInTab)) {
  933. GMType = GM.openInTab(url, params)
  934. } else {
  935. GMType = GM_openInTab(url, params)
  936. }
  937. return GMType
  938. }
  939. return window.open(url, params)
  940. },
  941. }
  942. MU.storage = {
  943. getItem(key) {
  944. return window.localStorage.getItem(key)
  945. },
  946. has(key) {
  947. return !isNull(this.getItem(key))
  948. },
  949. setItem(key, value) {
  950. window.localStorage.setItem(key, value)
  951. },
  952. remove(key) {
  953. window.localStorage.removeItem(key)
  954. },
  955. /**
  956. * Set value
  957. * @param {string} key - Key to set the value of
  958. * @param {object} v - Value of key
  959. * @returns {Promise} Saves key to either GM managed storage or webpages localstorage
  960. * @link https://violentmonkey.github.io/api/gm/#gm_setvalue
  961. * @link https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
  962. */
  963. setValue(key, v) {
  964. return new Promise((resolve) => {
  965. v = isStr(v) ? v : JSON.stringify(v ?? {})
  966. if (Supports.gm) {
  967. let GMType
  968. if (isFN(GM.setValue)) {
  969. GMType = GM.setValue(key, v)
  970. } else {
  971. GMType = GM_setValue(key, v)
  972. }
  973. resolve(GMType)
  974. } else {
  975. resolve(this.setItem(`MUJS-${key}`, v))
  976. }
  977. })
  978. },
  979. /**
  980. * Get Value
  981. * @link https://violentmonkey.github.io/api/gm/#gm_getvalue
  982. * @link https://developer.mozilla.org/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
  983. */
  984. async getValue(key, def = {}) {
  985. try {
  986. if (Supports.gm) {
  987. let GMType
  988. if (isFN(GM.getValue)) {
  989. GMType = await GM.getValue(key, JSON.stringify(def))
  990. } else {
  991. GMType = GM_getValue(key, JSON.stringify(def))
  992. }
  993. return JSON.parse(GMType)
  994. }
  995. return this.has(`MUJS-${key}`)
  996. ? JSON.parse(this.getItem(`MUJS-${key}`))
  997. : def
  998. } catch (ex) {
  999. err(ex)
  1000. }
  1001. },
  1002. }
  1003. const Container = class {
  1004. constructor() {
  1005. this.remove = this.remove.bind(this)
  1006. this.onFrameLoad = this.onFrameLoad.bind(this)
  1007. this.supported = isFN(document.createElement('main-userjs').attachShadow)
  1008. this.ready = false
  1009. if (this.supported) {
  1010. this.frame = make('main-userjs', '', {
  1011. dataset: {
  1012. insertedBy: 'userscript-plus',
  1013. role: 'primary-container',
  1014. },
  1015. })
  1016. this.root = this.frame.attachShadow({ mode: 'open' })
  1017. this.ready = true
  1018. } else {
  1019. this.frame = make('iframe', 'mujs-iframe', {
  1020. dataset: {
  1021. insertedBy: 'userscript-plus',
  1022. role: 'primary-iframe',
  1023. },
  1024. loading: 'lazy',
  1025. src: 'about:blank',
  1026. style:
  1027. 'position: fixed;bottom: 1rem;right: 1rem;height: 525px;width: 90%;margin: 0px 1rem;z-index: 100000000000000020 !important;',
  1028. onload: this.onFrameLoad,
  1029. })
  1030. }
  1031. ael(window.self, 'beforeunload', this.remove)
  1032. // info('Container:', this)
  1033. }
  1034. /**
  1035. * @param {Function} callback
  1036. */
  1037. async inject(callback) {
  1038. while (this.ready === false) {
  1039. await new Promise((resolve) => requestAnimationFrame(resolve))
  1040. }
  1041.  
  1042. document.documentElement.appendChild(this.frame)
  1043.  
  1044. if (isFN(callback)) {
  1045. callback.call({}, this.root)
  1046. }
  1047. }
  1048.  
  1049. remove() {
  1050. this.frame.remove()
  1051. }
  1052.  
  1053. onFrameLoad(iFrame) {
  1054. this.root = iFrame.target.contentDocument.documentElement
  1055. this.ready = true
  1056.  
  1057. this.root.classList.add('mujs-iframe')
  1058. iFrame.target.contentDocument.body.classList.add('mujs-iframe')
  1059. }
  1060. }
  1061. const container = new Container()
  1062. const sleazyRedirect = () => {
  1063. if (!/greasyfork\.org/.test(location.hostname) && cfg.sleazyredirect) {
  1064. return
  1065. }
  1066. const otherSite = /greasyfork\.org/.test(location.hostname)
  1067. ? 'sleazyfork'
  1068. : 'greasyfork'
  1069. qs('span.sign-in-link')
  1070. ? /scripts\/\d+/.test(location.href)
  1071. ? !qs('#script-info') &&
  1072. (otherSite == 'greasyfork' || qs('div.width-constraint>section>p>a'))
  1073. ? location.assign(
  1074. location.href.replace(
  1075. /\/\/([^.]+\.)?(greasyfork|sleazyfork)\.org/,
  1076. '//$1' + otherSite + '.org',
  1077. ),
  1078. )
  1079. : false
  1080. : false
  1081. : false
  1082. }
  1083. const main = (injCon) => {
  1084. try {
  1085. //#region Static Elements
  1086. const mujsRoot = make('mujs-root')
  1087.  
  1088. const usercss = make('style', '', { innerHTML: main_css })
  1089. usercss.dataset.insertedBy = 'userscript-plus'
  1090. usercss.dataset.role = 'primary-stylesheet'
  1091. mujsRoot.append(usercss)
  1092.  
  1093. const table = make('table')
  1094. const tabbody = make('tbody')
  1095. const tabhead = make('thead')
  1096. const main = make('mu-js', 'main hidden')
  1097. const tbody = make('mu-js', 'mujs-body')
  1098. const header = make('mu-js', 'mujs-header-prim')
  1099. const cfgpage = make('mujs-row', 'mujs-cfg hidden')
  1100. const countframe = make('mujs-column')
  1101. const btnframe = make('mujs-column')
  1102. const btnHandles = make('mujs-column', 'btn-handles')
  1103. const gfcounter = make('count-frame', '', {
  1104. title: 'https://greasyfork.org + https://sleazyfork.org',
  1105. style: 'background: #00b7ff;',
  1106. })
  1107. const sfcounter = make('count-frame', '', {
  1108. title: 'https://openuserjs.org',
  1109. style: 'background: #ed3f14;',
  1110. })
  1111. const fsearch = make('mujs-btn', 'hidden')
  1112. const ssearch = make('mujs-btn', 'hidden')
  1113. const mainbtn = make('count-frame', 'mainbtn', {
  1114. innerHTML: '0',
  1115. })
  1116. const rateContainer = make('mujs-column', 'rate-container')
  1117. //#endregion
  1118.  
  1119. const template = {
  1120. bad_ratings: 0,
  1121. good_ratings: 0,
  1122. ok_ratings: 0,
  1123. daily_installs: 0,
  1124. total_installs: 0,
  1125. name: 'NOT FOUND',
  1126. description: 'NOT FOUND',
  1127. version: '0.0.0',
  1128. url: 'about:blank',
  1129. code_url: 'about:blank',
  1130. created_at: Date.now(),
  1131. code_updated_at: Date.now(),
  1132. users: [
  1133. {
  1134. name: '',
  1135. url: '',
  1136. },
  1137. ],
  1138. }
  1139. const ContainerHandler = class {
  1140. constructor() {
  1141. this.cache = new Map()
  1142. this.host = location.hostname.split('.').splice(-2).join('.')
  1143. this.site = window.top.document.location.href
  1144. this.unsaved = false
  1145. this.isBlacklisted = false
  1146. this.switchRows = true
  1147. this.rebuild = false
  1148. this.siteujs = []
  1149. this.forkCount = 0
  1150. this.customCount = 0
  1151.  
  1152. this.showError = this.showError.bind(this)
  1153. this.cleanup = this.cleanup.bind(this)
  1154. ael(window.self, 'beforeunload', this.cleanup)
  1155. }
  1156.  
  1157. checkBlacklist() {
  1158. const blacklist = cfg.blacklist.filter((b) => b.enabled)
  1159. for (const b of blacklist) {
  1160. if (b.regex) {
  1161. const reg = new RegExp(b.url, b.flags)
  1162. const testurl = reg.test(this.site)
  1163. if (!testurl) continue
  1164. MUJS.isBlacklisted = true
  1165. }
  1166. if (!Array.isArray(b.url)) {
  1167. if (!this.site.includes(b.url)) continue
  1168. MUJS.isBlacklisted = true
  1169. }
  1170. for (const c of b.url) {
  1171. if (!this.site.includes(c)) continue
  1172. this.isBlacklisted = true
  1173. }
  1174. }
  1175. if (this.isBlacklisted) {
  1176. this.showError('Blacklisted')
  1177. timeoutFrame()
  1178. }
  1179. return this.isBlacklisted
  1180. }
  1181.  
  1182. addCustomCnt(cnt) {
  1183. this.customCount += cnt
  1184. this.updateCounters()
  1185. }
  1186.  
  1187. addForkCnt(cnt) {
  1188. this.forkCount += cnt
  1189. this.updateCounters()
  1190. }
  1191.  
  1192. updateCounters() {
  1193. sfcounter.innerHTML = this.customCount
  1194. gfcounter.innerHTML = this.forkCount
  1195. mainbtn.innerHTML = this.customCount + this.forkCount
  1196. }
  1197.  
  1198. save() {
  1199. this.unsaved = false
  1200. MU.storage.setValue('Config', cfg)
  1201. log('Saved:', cfg)
  1202. }
  1203.  
  1204. showError(ex) {
  1205. err(ex)
  1206. const txt = make('mujs-row', 'error', {
  1207. innerHTML: `ERROR: ${typeof ex === 'string' ? ex : ex.message}`,
  1208. })
  1209. tbody.prepend(txt)
  1210. }
  1211.  
  1212. refresh() {
  1213. this.siteujs.length = 0
  1214. this.forkCount = 0
  1215. this.customCount = 0
  1216. this.updateCounters()
  1217. tabbody.innerHTML = ''
  1218. rateContainer.innerHTML = ''
  1219. if (sh('.error')) {
  1220. sh('.error').remove()
  1221. }
  1222. }
  1223.  
  1224. cleanup() {
  1225. this.cache.clear()
  1226. }
  1227. }
  1228. const MUJS = new ContainerHandler()
  1229. const timeout = new Timeout()
  1230. const timeoutFrame = async () => {
  1231. if (typeof cfg.time === 'number' && !isNaN(cfg.time)) {
  1232. timeout.clear(...timeout.ids)
  1233. await timeout.set(MUJS.isBlacklisted ? cfg.time / 2 : cfg.time)
  1234. container.remove()
  1235. return timeout.clear(...timeout.ids)
  1236. }
  1237. }
  1238. const sh = (elem) => injCon.querySelector(elem)
  1239. const shA = (elem) => injCon.querySelectorAll(elem)
  1240. const sortRowBy = (cellIndex) => {
  1241. const rows = normalizeTarget(tabbody.rows).sort((tr1, tr2) => {
  1242. const t1cell = tr1.cells[cellIndex]
  1243. const t2cell = tr2.cells[cellIndex]
  1244. const tr1Text = (t1cell.firstElementChild ?? t1cell).textContent
  1245. const tr2Text = (t2cell.firstElementChild ?? t2cell).textContent
  1246. const t1pDate = Date.parse(tr1Text)
  1247. const t2pDate = Date.parse(tr2Text)
  1248. if (!Number.isNaN(t1pDate) && !Number.isNaN(t2pDate)) {
  1249. return new Date(t1pDate) - new Date(t2pDate)
  1250. }
  1251. if (Number(tr1Text) && Number(tr2Text)) {
  1252. return tr1Text - tr2Text
  1253. }
  1254. return tr1Text.localeCompare(tr2Text)
  1255. })
  1256. if (MUJS.switchRows) {
  1257. rows.reverse()
  1258. }
  1259. MUJS.switchRows = !MUJS.switchRows
  1260. tabbody.append(...rows)
  1261. }
  1262. const createjs = (ujs, issleazy) => {
  1263. for (const key in template) {
  1264. if (!hasOwn(ujs, key)) {
  1265. ujs[key] = template[key]
  1266. }
  1267. }
  1268. const eframe = make('td', 'install-btn')
  1269. const uframe = make('td', 'mujs-uframe')
  1270. const fdaily = make('td', 'mujs-list', {
  1271. innerHTML: ujs.daily_installs,
  1272. })
  1273. const fupdated = make('td', 'mujs-list', {
  1274. innerHTML: new Intl.DateTimeFormat(navigator.language).format(
  1275. new Date(ujs.code_updated_at),
  1276. ),
  1277. })
  1278. const fname = make('td', 'mujs-name')
  1279. const ftitle = make('mujs-a', 'mujs-homepage', {
  1280. title: ujs.name,
  1281. innerHTML: ujs.name,
  1282. onclick(e) {
  1283. halt(e)
  1284. MU.tab.open(ujs.url)
  1285. },
  1286. })
  1287. const fver = make('mu-js', 'mujs-list', {
  1288. innerHTML: `${lang.version}: ${ujs.version}`,
  1289. })
  1290. const fcreated = make('mu-js', 'mujs-list', {
  1291. innerHTML: `${lang.created}: ${new Intl.DateTimeFormat(
  1292. navigator.language,
  1293. ).format(new Date(ujs.created_at))}`,
  1294. })
  1295. const fmore = make('mujs-column', 'mujs-list hidden')
  1296. const ftotal = make('mu-js', 'mujs-list', {
  1297. innerHTML: `${lang.total}: ${ujs.total_installs}`,
  1298. })
  1299. const fratings = make('mu-js', 'mujs-list', {
  1300. title: lang.rating,
  1301. innerHTML: `${lang.rating}:`,
  1302. })
  1303. const fgood = make('mu-js', 'mujs-list mujs-ratings', {
  1304. title: lang.good,
  1305. innerHTML: ujs.good_ratings,
  1306. style:
  1307. 'border-color: rgb(51, 155, 51); background-color: #339b331a; color: rgb(51, 255, 51);',
  1308. })
  1309. const fok = make('mu-js', 'mujs-list mujs-ratings', {
  1310. title: lang.ok,
  1311. innerHTML: ujs.ok_ratings,
  1312. style:
  1313. 'border-color: rgb(155, 155, 0); background-color: #9b9b001a; color: rgb(255, 255, 0);',
  1314. })
  1315. const fbad = make('mu-js', 'mujs-list mujs-ratings', {
  1316. title: lang.bad,
  1317. innerHTML: ujs.bad_ratings,
  1318. style:
  1319. 'border-color: rgb(155, 0, 0); background-color: #9b33331a; color: rgb(255, 0, 0);',
  1320. })
  1321. const fdesc = make('mu-js', 'mujs-list mujs-pointer', {
  1322. title: ujs.description,
  1323. innerHTML: ujs.description,
  1324. onclick(e) {
  1325. halt(e)
  1326. if (fmore.classList.contains('hidden')) {
  1327. fmore.classList.remove('hidden')
  1328. } else {
  1329. fmore.classList.add('hidden')
  1330. }
  1331. },
  1332. })
  1333. const fdwn = make('mu-jsbtn', 'install', {
  1334. title: `${lang.install} { ${ujs.name} }`,
  1335. innerHTML: `${iconSVG.install} ${lang.install}`,
  1336. onclick(e) {
  1337. halt(e)
  1338. MU.tab.open(ujs.code_url)
  1339. },
  1340. })
  1341. for (const u of ujs.users) {
  1342. const user = make('mujs-a', 'mujs-euser', {
  1343. innerHTML: u.name,
  1344. onclick(e) {
  1345. halt(e)
  1346. MU.tab.open(u.url)
  1347. },
  1348. })
  1349. uframe.append(user)
  1350. }
  1351. eframe.append(fdwn)
  1352. fmore.append(ftotal, fratings, fgood, fok, fbad, fver, fcreated)
  1353. fname.append(ftitle, fdesc, fmore)
  1354. const tr = make('tr', `frame${issleazy ? ' sf' : ''}`)
  1355. for (const e of [fname, uframe, fdaily, fupdated, eframe]) {
  1356. tr.append(e)
  1357. }
  1358. tabbody.append(tr)
  1359. }
  1360. if (!isEmpty(navigator.languages)) {
  1361. for (const nlang of navigator.languages) {
  1362. const lg = nlang.split('-')[0]
  1363. if (alang.indexOf(lg) === -1) {
  1364. alang.push(lg)
  1365. }
  1366. }
  1367. }
  1368. const makerow = (desc, type, nm, attrs = {}) => {
  1369. const sec = make('mujs-section', '', {
  1370. style: !Supports.gm && nm === 'cache' ? 'display: none;' : '',
  1371. })
  1372. const lb = make('label')
  1373. const divDesc = make('mu-js', '', {
  1374. innerHTML: desc,
  1375. })
  1376. lb.append(divDesc)
  1377. sec.append(lb)
  1378. cfgpage.append(sec)
  1379. if (isNull(type)) {
  1380. return sec
  1381. }
  1382. const inp = make('input', '', {
  1383. type,
  1384. id: nm,
  1385. name: nm,
  1386. ...attrs,
  1387. })
  1388. if (type === 'checkbox') {
  1389. const inlab = make('mu-js', 'mujs-inlab')
  1390. const la = make('label', '', {
  1391. onclick() {
  1392. inp.dispatchEvent(new MouseEvent('click'))
  1393. },
  1394. })
  1395. inlab.append(inp, la)
  1396. lb.append(inlab)
  1397. if (/(greasy|sleazy)fork|openuserjs|gi(thub|st)/gi.test(nm)) {
  1398. for (const i of cfg.engines) {
  1399. if (i.name === nm) {
  1400. inp.checked = i.enabled
  1401. ael(inp, 'change', (e) => {
  1402. MUJS.unsaved = true
  1403. i.enabled = e.target.checked
  1404. })
  1405. }
  1406. }
  1407. } else {
  1408. inp.checked = cfg[nm]
  1409. ael(inp, 'change', (e) => {
  1410. MUJS.unsaved = true
  1411. if (/filterlang/i.test(nm)) {
  1412. MUJS.rebuild = true
  1413. }
  1414. cfg[nm] = e.target.checked
  1415. })
  1416. }
  1417. } else {
  1418. lb.append(inp)
  1419. }
  1420. return inp
  1421. }
  1422. //#region Build List
  1423. const buildlist = async (host) => {
  1424. try {
  1425. if (isEmpty(host)) {
  1426. host = MUJS.host
  1427. }
  1428. MUJS.refresh()
  1429. if (MUJS.checkBlacklist()) return
  1430. const template = {}
  1431. for (const engine of cfg.engines) {
  1432. template[engine.name] = []
  1433. }
  1434. const engines = cfg.engines.filter((e) => e.enabled)
  1435. if (isEmpty(MUJS.cache.get(host))) {
  1436. MUJS.cache.set(host, template)
  1437. }
  1438. const cache = MUJS.cache.get(host)
  1439. const customRecords = []
  1440. const rateFN = (data) => {
  1441. try {
  1442. for (const [key, value] of Object.entries(
  1443. data.resources.code_search,
  1444. )) {
  1445. const txt = make('mujs-row', 'rate-info', {
  1446. innerHTML: `${key.toLocaleUpperCase()}: ${value}`,
  1447. })
  1448. rateContainer.append(txt)
  1449. }
  1450. } catch (ex) {
  1451. MUJS.showError(ex)
  1452. }
  1453. }
  1454. info('Building list', { cache, MUJS, engines })
  1455. if (!isNull(legacyMsg)) {
  1456. const txt = make('mujs-row', 'legacy-config', {
  1457. innerHTML: legacyMsg,
  1458. })
  1459. rateContainer.append(txt)
  1460. return
  1461. }
  1462. for (const engine of engines) {
  1463. const forkFN = async (data) => {
  1464. if (!data) return
  1465. const hideData = []
  1466. const filterDeleted = data.filter((ujs) => !ujs.deleted)
  1467. const filterLang = filterDeleted.filter((d) => {
  1468. if (!cfg.filterlang) {
  1469. return true
  1470. }
  1471. const dlocal = d.locale.split('-')[0] ?? d.locale
  1472. if (alang.length > 1) {
  1473. for (const a of alang) {
  1474. if (dlocal.includes(a)) {
  1475. return true
  1476. }
  1477. }
  1478. } else if (dlocal.includes(navLang)) {
  1479. return true
  1480. }
  1481. hideData.push(d)
  1482. return false
  1483. })
  1484. let finalList = filterLang
  1485.  
  1486. if (!isBlank(hideData)) {
  1487. const hds = []
  1488. for (const h of hideData) {
  1489. const txt = await Network.fetchURL(
  1490. h.code_url,
  1491. 'GET',
  1492. 'text',
  1493. ).catch(MUJS.showError)
  1494. const headers = txt.match(/\/\/\s@[\w][\s\S]+/g) || []
  1495. if (headers.length > 0) {
  1496. const regName = new RegExp(`// @name:${navLang}\\s+.+`, 'gi')
  1497. const findName = (regName.exec(headers[0]) ?? []).join('')
  1498. if (isEmpty(findName)) {
  1499. continue
  1500. }
  1501. const cReg = new RegExp(`// @name:${navLang}\\s+`, 'gi')
  1502. const cutName = findName.replace(cReg, '')
  1503. Object.assign(h, {
  1504. name: cutName,
  1505. })
  1506. const regDesc = new RegExp(
  1507. `// @description:${navLang}\\s+.+`,
  1508. 'gi',
  1509. )
  1510. const findDesc = (regDesc.exec(headers[0]) ?? []).join('')
  1511. if (isEmpty(findDesc)) {
  1512. continue
  1513. }
  1514. Object.assign(h, {
  1515. description: findDesc.replace(
  1516. new RegExp(`// @description:${navLang}\\s+`, 'gi'),
  1517. '',
  1518. ),
  1519. })
  1520. hds.push(h)
  1521. }
  1522. }
  1523. finalList = [...new Set([...hds, ...filterLang])]
  1524. }
  1525. for (const ujs of finalList) {
  1526. MUJS.siteujs.push(ujs)
  1527. createjs(ujs, false)
  1528. }
  1529. cache[engine.name].push(...finalList)
  1530. MUJS.addForkCnt(finalList.length)
  1531. }
  1532. const customFN = async (data) => {
  1533. const parser = new DOMParser()
  1534. const htmlDocument = parser.parseFromString(data, 'text/html')
  1535. const selected = htmlDocument.documentElement
  1536. if (qs('.col-sm-8 .tr-link', selected)) {
  1537. log('.col-sm-8 .tr-link', qsA('.col-sm-8 .tr-link', selected))
  1538. for (const i of qsA('.col-sm-8 .tr-link', selected)) {
  1539. await query('.script-version', i)
  1540. const fixurl = qs('.tr-link-a', i).href.replace(
  1541. new RegExp(document.location.origin, 'gi'),
  1542. 'https://openuserjs.org',
  1543. )
  1544. const layout = {
  1545. name: qs('.tr-link-a', i).textContent,
  1546. description: qs('p', i).textContent,
  1547. version: qs('.script-version', i).textContent,
  1548. url: fixurl,
  1549. code_url: `${fixurl.replace(
  1550. /\/scripts/gi,
  1551. '/install',
  1552. )}.user.js`,
  1553. total_installs: qs('td:nth-child(2) p', i).textContent,
  1554. created_at: qs('td:nth-child(4) time', i).getAttribute(
  1555. 'datetime',
  1556. ),
  1557. code_updated_at: qs('td:nth-child(4) time', i).getAttribute(
  1558. 'datetime',
  1559. ),
  1560. users: [
  1561. {
  1562. name: qs('.inline-block a', i).textContent,
  1563. url: qs('.inline-block a', i).href,
  1564. },
  1565. ],
  1566. }
  1567. createjs(layout, true)
  1568. // MUJS.addCustomCnt(1)
  1569. customRecords.push(layout)
  1570. }
  1571. }
  1572. if (qs('div.gist-snippet', selected)) {
  1573. log('div.gist-snippet', qsA('div.gist-snippet', selected))
  1574. for (const g of qsA('div.gist-snippet', selected)) {
  1575. if (
  1576. qs('span > a:nth-child(2)', g).textContent.includes(
  1577. '.user.js',
  1578. )
  1579. ) {
  1580. const fixurl = qs('span > a:nth-child(2)', g).href.replace(
  1581. new RegExp(document.location.origin, 'gi'),
  1582. 'https://gist.github.com',
  1583. )
  1584. const layout = {}
  1585. Object.assign(layout, {
  1586. url: fixurl,
  1587. code_url: `${fixurl}/raw/${
  1588. qs('span > a:nth-child(2)', g).textContent
  1589. }`,
  1590. created_at: qs('time-ago.no-wrap', g).getAttribute(
  1591. 'datetime',
  1592. ),
  1593. users: [
  1594. {
  1595. name: qs('span > a[data-hovercard-type]', g)
  1596. .textContent,
  1597. url: qs(
  1598. 'span > a[data-hovercard-type]',
  1599. g,
  1600. ).href.replace(
  1601. new RegExp(document.location.origin, 'gi'),
  1602. 'https://gist.github.com',
  1603. ),
  1604. },
  1605. ],
  1606. })
  1607. for (const i of qsA('.file-box table tr .blob-code', g)) {
  1608. const txt = i.textContent
  1609. const headers = txt.match(/\/\/\s@[\w][\s\S]+/gi) || []
  1610. if (headers.length > 0) {
  1611. const crop = headers[0].split(
  1612. /\/\/\s@(name|description|author|version)\s+/gi,
  1613. )
  1614. if (
  1615. headers[0].includes('@name') &&
  1616. !headers[0].includes('@namespace')
  1617. ) {
  1618. Object.assign(layout, {
  1619. name: crop[2].trim(),
  1620. })
  1621. }
  1622. if (headers[0].includes('@description')) {
  1623. Object.assign(layout, {
  1624. description: crop[2].trim(),
  1625. })
  1626. }
  1627. if (headers[0].includes('@version')) {
  1628. Object.assign(layout, {
  1629. version: crop[2].trim(),
  1630. })
  1631. }
  1632. }
  1633. }
  1634. createjs(layout, true)
  1635. // MUJS.addCustomCnt(1)
  1636. customRecords.push(layout)
  1637. }
  1638. }
  1639. }
  1640. cache[engine.name].push(...customRecords)
  1641. MUJS.addCustomCnt(customRecords.length)
  1642. }
  1643. const gitFN = async (data) => {
  1644. try {
  1645. if (isBlank(data.items)) return
  1646. for (const r of data.items) {
  1647. const layout = {
  1648. name: r.name,
  1649. description: isEmpty(r.repository.description)
  1650. ? 'No Description'
  1651. : r.repository.description,
  1652. url: r.html_url,
  1653. code_url: r.html_url.replace(/\/blob\//g, '/raw/'),
  1654. code_updated_at: Date.now(), // r.commit
  1655. total_installs: r.score,
  1656. users: [
  1657. {
  1658. name: r.repository.owner.login,
  1659. url: r.repository.owner.html_url,
  1660. },
  1661. ],
  1662. }
  1663. createjs(layout, true)
  1664. customRecords.push(layout)
  1665. }
  1666. MUJS.addCustomCnt(data.items.length)
  1667. cache[engine.name].push(...customRecords)
  1668. } catch (ex) {
  1669. MUJS.showError(ex)
  1670. }
  1671. }
  1672. const eURL = engine.url
  1673. const cEngine = cache[`${engine.name}`]
  1674. if (engine.name.match(/fork/gi)) {
  1675. if (!isEmpty(cEngine)) {
  1676. for (const ujs of cEngine) {
  1677. createjs(ujs, false)
  1678. }
  1679. MUJS.addForkCnt(cEngine.length)
  1680. continue
  1681. }
  1682.  
  1683. if (cfg.filterlang) {
  1684. if (alang.length > 1) {
  1685. for (const a of alang) {
  1686. Network.fetchURL(
  1687. `${eURL}/${a}/scripts/by-site/${host}.json?page=1`,
  1688. )
  1689. .then(forkFN)
  1690. .catch(MUJS.showError)
  1691. }
  1692. continue
  1693. }
  1694. Network.fetchURL(
  1695. `${eURL}/${navLang}/scripts/by-site/${host}.json?page=1`,
  1696. )
  1697. .then(forkFN)
  1698. .catch(MUJS.showError)
  1699. continue
  1700. }
  1701. Network.fetchURL(`${eURL}/scripts/by-site/${host}.json`)
  1702. .then(forkFN)
  1703. .catch(MUJS.showError)
  1704. } else if (engine.name.match(/(openuserjs|github)/gi)) {
  1705. if (!isEmpty(cEngine)) {
  1706. for (const ujs of cEngine) {
  1707. createjs(ujs, true)
  1708. }
  1709. MUJS.addCustomCnt(cEngine.length)
  1710. continue
  1711. }
  1712. if (/github/gi.test(engine.name)) {
  1713. Network.fetchURL(
  1714. `${eURL}"// ==UserScript=="+${host}+ "// ==/UserScript=="+in:file+language:js&per_page=30`,
  1715. 'GET',
  1716. 'json',
  1717. {
  1718. headers: {
  1719. Accept: 'application/vnd.github+json',
  1720. Authorization: `Bearer ${engine.token}`,
  1721. 'X-GitHub-Api-Version': '2022-11-28',
  1722. },
  1723. },
  1724. )
  1725. .then(gitFN)
  1726. .then(() => {
  1727. Network.fetchURL(
  1728. 'https://api.github.com/rate_limit',
  1729. 'GET',
  1730. 'json',
  1731. {
  1732. headers: {
  1733. Accept: 'application/vnd.github+json',
  1734. Authorization: `Bearer ${engine.token}`,
  1735. 'X-GitHub-Api-Version': '2022-11-28',
  1736. },
  1737. },
  1738. )
  1739. .then(rateFN)
  1740. .catch(MUJS.showError)
  1741. })
  1742. .catch(MUJS.showError)
  1743. } else {
  1744. Network.fetchURL(`${eURL}${host}`, 'GET', 'text')
  1745. .then(customFN)
  1746. .catch(MUJS.showError)
  1747. }
  1748. }
  1749. }
  1750. sortRowBy(2)
  1751. } catch (ex) {
  1752. MUJS.showError(ex)
  1753. }
  1754. }
  1755. //#endregion
  1756. //#region Make Config
  1757. const makecfg = () => {
  1758. makerow('Sync with GM', 'checkbox', 'cache')
  1759. makerow('Auto Fullscreen', 'checkbox', 'autoexpand', {
  1760. onchange(e) {
  1761. if (e.target.checked) {
  1762. btnfullscreen.classList.add('expanded')
  1763. main.classList.add('expanded')
  1764. btnfullscreen.innerHTML = iconSVG.fsClose
  1765. } else {
  1766. btnfullscreen.classList.remove('expanded')
  1767. main.classList.remove('expanded')
  1768. btnfullscreen.innerHTML = iconSVG.fsOpen
  1769. }
  1770. },
  1771. })
  1772. makerow(lang.redirect, 'checkbox', 'sleazyredirect')
  1773. makerow(lang.filter, 'checkbox', 'filterlang')
  1774. makerow('Greasy Fork', 'checkbox', 'greasyfork')
  1775. makerow('Sleazy Fork', 'checkbox', 'sleazyfork')
  1776. makerow('Open UserJS', 'checkbox', 'openuserjs')
  1777. makerow('GitHub API', 'checkbox', 'github')
  1778. const cfgAPI = cfg.engines.filter((c) => c.name === 'github')[0]
  1779. makerow('GitHub API (Token)', 'password', 'github', {
  1780. defaultValue: '',
  1781. value: cfgAPI.token ?? '',
  1782. placeholder: 'Paste Access Token',
  1783. onchange(e) {
  1784. MUJS.unsaved = true
  1785. MUJS.rebuild = true
  1786. if (isNull(legacyMsg)) {
  1787. cfgAPI.token = e.target.value
  1788. }
  1789. },
  1790. })
  1791. makerow(`${lang.dtime} (ms)`, 'number', 'time', {
  1792. defaultValue: 10000,
  1793. value: cfg.time,
  1794. min: 0,
  1795. step: 500,
  1796. onbeforeinput(e) {
  1797. if (e.target.validity.badInput) {
  1798. dom.cl.add(e.target, 'mujs-invalid')
  1799. dom.prop(savebtn, 'disabled', true)
  1800. } else {
  1801. dom.cl.remove(e.target, 'mujs-invalid')
  1802. dom.prop(savebtn, 'disabled', false)
  1803. }
  1804. },
  1805. oninput(e) {
  1806. MUJS.unsaved = true
  1807. const t = e.target
  1808. if (
  1809. t.validity.badInput ||
  1810. (t.validity.rangeUnderflow && t.value !== '-1')
  1811. ) {
  1812. dom.cl.add(t, 'mujs-invalid')
  1813. dom.prop(savebtn, 'disabled', true)
  1814. } else {
  1815. dom.cl.remove(t, 'mujs-invalid')
  1816. dom.prop(savebtn, 'disabled', false)
  1817. cfg.time = isEmpty(t.value) ? cfg.time : parseFloat(t.value)
  1818. }
  1819. },
  1820. })
  1821. const cbtn = make('mu-js', 'mujs-sty-flex')
  1822. const savebtn = make('mujs-btn', 'save', {
  1823. disabled: false,
  1824. innerHTML: lang.save,
  1825. onclick(e) {
  1826. halt(e)
  1827. if (sh('.saveerror')) {
  1828. sh('.saveerror').remove()
  1829. }
  1830. if (!isNull(legacyMsg)) {
  1831. legacyMsg = null
  1832. MUJS.rebuild = true
  1833. rateContainer.innerHTML = ''
  1834. }
  1835. if (!dom.prop(e.target, 'disabled')) {
  1836. MUJS.save()
  1837. sleazyRedirect()
  1838. if (MUJS.rebuild) {
  1839. MUJS.cache.clear()
  1840. buildlist()
  1841. }
  1842. MUJS.unsaved = false
  1843. MUJS.rebuild = false
  1844. }
  1845. },
  1846. })
  1847. const txta = make('textarea', 'tarea', {
  1848. name: 'blacklist',
  1849. id: 'blacklist',
  1850. rows: '10',
  1851. autocomplete: false,
  1852. spellcheck: false,
  1853. wrap: 'soft',
  1854. value: JSON.stringify(cfg.blacklist, null, ' '),
  1855. oninput(e) {
  1856. let isvalid = true
  1857. try {
  1858. cfg.blacklist = JSON.parse(e.target.value)
  1859. isvalid = true
  1860. } catch (ex) {
  1861. err(ex)
  1862. isvalid = false
  1863. } finally {
  1864. if (isvalid) {
  1865. dom.cl.remove(e.target, 'mujs-invalid')
  1866. dom.prop(savebtn, 'disabled', false)
  1867. } else {
  1868. dom.cl.add(e.target, 'mujs-invalid')
  1869. dom.prop(savebtn, 'disabled', true)
  1870. }
  1871. }
  1872. },
  1873. })
  1874. const resetbtn = make('mujs-btn', 'reset', {
  1875. innerHTML: 'Reset',
  1876. onclick(e) {
  1877. halt(e)
  1878. cfg = defcfg
  1879. MUJS.unsaved = true
  1880. txta.value = JSON.stringify(cfg.blacklist, null, ' ')
  1881. for (const i of cfg.engines) {
  1882. if (sh(`mu-js.mujs-inlab > [id="${i.name}"]`)) {
  1883. sh(`mu-js.mujs-inlab > [id="${i.name}"]`).checked = i.enabled
  1884. }
  1885. }
  1886. for (const i of shA('mu-js.mujs-inlab > input[type="checkbox"]')) {
  1887. if (
  1888. !i.name.match(/((greasy|sleazy)fork|openuserjs|gi(thub|st))/gi)
  1889. ) {
  1890. i.checked = cfg[i.name]
  1891. }
  1892. }
  1893. },
  1894. })
  1895. cbtn.append(savebtn, resetbtn)
  1896. cfgpage.append(txta, cbtn)
  1897. }
  1898. //#endregion
  1899. const makeTHead = (rows) => {
  1900. const tr = make('tr')
  1901. for (const r of normalizeTarget(rows)) {
  1902. const tparent = make('th', r.class ?? '', r)
  1903. tr.append(tparent)
  1904. }
  1905. tabhead.append(tr)
  1906. table.append(tabhead, tabbody)
  1907. }
  1908. const btnHide = make('mujs-btn', 'hide-list', {
  1909. title: lang.min,
  1910. innerHTML: iconSVG.hide,
  1911. onclick(e) {
  1912. halt(e)
  1913. main.classList.add('hidden')
  1914. mainframe.classList.remove('hidden')
  1915. timeoutFrame()
  1916. },
  1917. })
  1918. const btnfullscreen = make('mujs-btn', 'fullscreen', {
  1919. title: lang.max,
  1920. innerHTML: iconSVG.fullscreen,
  1921. onclick(e) {
  1922. halt(e)
  1923. if (btnfullscreen.classList.contains('expanded')) {
  1924. btnfullscreen.classList.remove('expanded')
  1925. main.classList.remove('expanded')
  1926. btnfullscreen.innerHTML = iconSVG.fsOpen
  1927. return
  1928. }
  1929. btnfullscreen.classList.add('expanded')
  1930. main.classList.add('expanded')
  1931. btnfullscreen.innerHTML = iconSVG.fsClose
  1932. },
  1933. })
  1934. const mainframe = make('mu-js', 'mainframe', {
  1935. onclick(e) {
  1936. e.preventDefault()
  1937. timeout.clear(...timeout.ids)
  1938. main.classList.remove('hidden')
  1939. mainframe.classList.add('hidden')
  1940. if (cfg.autoexpand) {
  1941. btnfullscreen.classList.add('expanded')
  1942. main.classList.add('expanded')
  1943. btnfullscreen.innerHTML = iconSVG.fsClose
  1944. }
  1945. },
  1946. })
  1947. const filterList = make('input', 'mujs-fltlist', {
  1948. autocomplete: 'off',
  1949. spellcheck: false,
  1950. type: 'text',
  1951. placeholder: lang.searcher,
  1952. oninput(e) {
  1953. e.preventDefault()
  1954. if (!isEmpty(e.target.value)) {
  1955. const reg = new RegExp(e.target.value, 'gi')
  1956. for (const ujs of shA('.frame')) {
  1957. const m = ujs.children[0]
  1958. const n = ujs.children[1]
  1959. const final =
  1960. m.textContent.match(reg) || n.textContent.match(reg) || []
  1961. if (final.length === 0) {
  1962. ujs.classList.add('hidden')
  1963. } else {
  1964. ujs.classList.remove('hidden')
  1965. }
  1966. }
  1967. } else {
  1968. for (const ujs of shA('.frame')) {
  1969. ujs.classList.remove('hidden')
  1970. }
  1971. }
  1972. },
  1973. })
  1974. const filterBtn = make('mujs-btn', 'filter', {
  1975. title: lang.filterA,
  1976. innerHTML: iconSVG.filter,
  1977. onclick(e) {
  1978. e.preventDefault()
  1979. fsearch.classList.toggle('hidden')
  1980. },
  1981. })
  1982. const siteSearcher = make('input', 'mujs-searcher', {
  1983. autocomplete: 'off',
  1984. spellcheck: false,
  1985. type: 'text',
  1986. placeholder: MUJS.host,
  1987. onchange(e) {
  1988. e.preventDefault()
  1989. buildlist(e.target.value)
  1990. },
  1991. })
  1992. const siteSearchbtn = make('mujs-btn', 'search', {
  1993. title: lang.search,
  1994. innerHTML: iconSVG.search,
  1995. onclick(e) {
  1996. e.preventDefault()
  1997. ssearch.classList.toggle('hidden')
  1998. },
  1999. })
  2000. const closebtn = make('mujs-btn', 'close', {
  2001. title: lang.close,
  2002. innerHTML: iconSVG.close,
  2003. onclick: async (e) => {
  2004. halt(e)
  2005. container.remove()
  2006. },
  2007. })
  2008. const btncfg = make('mujs-btn', 'settings', {
  2009. title: 'Settings',
  2010. innerHTML: iconSVG.cfg,
  2011. onclick(e) {
  2012. e.preventDefault()
  2013. if (MUJS.unsaved && !sh('.saveerror')) {
  2014. const txt = make('mujs-row', 'saveerror', {
  2015. innerHTML: 'Unsaved changes',
  2016. })
  2017. countframe.insertAdjacentHTML('afterend', txt.outerHTML.toString())
  2018. }
  2019. if (dom.cl.has(cfgpage, 'hidden')) {
  2020. dom.cl.remove(cfgpage, 'hidden')
  2021. dom.cl.add(tbody, 'hidden')
  2022. dom.cl.add(main, 'auto-height')
  2023. if (!container.supported) {
  2024. dom.attr(container.frame, 'style', 'height: 100%;')
  2025. }
  2026. } else {
  2027. dom.cl.add(cfgpage, 'hidden')
  2028. dom.cl.remove(tbody, 'hidden')
  2029. dom.cl.remove(main, 'auto-height')
  2030. main.classList.remove('auto-height')
  2031. if (!container.supported) {
  2032. dom.attr(container.frame, 'style', '')
  2033. }
  2034. }
  2035. MUJS.rebuild = false
  2036. },
  2037. })
  2038. const btnhome = make('mujs-btn', 'github hidden', {
  2039. title: `GitHub (v${
  2040. MU.info.script.version.includes('.') ||
  2041. MU.info.script.version.includes('Book')
  2042. ? MU.info.script.version
  2043. : MU.info.script.version.slice(0, 5)
  2044. })`,
  2045. innerHTML: iconSVG.gh,
  2046. onclick(e) {
  2047. halt(e)
  2048. MU.tab.open('https://github.com/magicoflolis/Userscript-Plus')
  2049. },
  2050. })
  2051. const btnissue = make('mujs-btn', 'issue hidden', {
  2052. title: lang.issue,
  2053. innerHTML: iconSVG.issue,
  2054. onclick(e) {
  2055. e.preventDefault()
  2056. MU.tab.open(
  2057. 'https://github.com/magicoflolis/Userscript-Plus/issues/new',
  2058. )
  2059. },
  2060. })
  2061. const btngreasy = make('mujs-btn', 'greasy hidden', {
  2062. title: 'Greasy Fork',
  2063. innerHTML: iconSVG.gf,
  2064. onclick(e) {
  2065. e.preventDefault()
  2066. MU.tab.open('https://greasyfork.org/scripts/421603')
  2067. },
  2068. })
  2069. const btnnav = make('mujs-btn', 'nav', {
  2070. title: 'Navigation',
  2071. innerHTML: iconSVG.nav,
  2072. onclick(e) {
  2073. halt(e)
  2074. if (btngreasy.classList.contains('hidden')) {
  2075. btnissue.classList.remove('hidden')
  2076. btnhome.classList.remove('hidden')
  2077. btngreasy.classList.remove('hidden')
  2078. } else {
  2079. btnissue.classList.add('hidden')
  2080. btnhome.classList.add('hidden')
  2081. btngreasy.classList.add('hidden')
  2082. }
  2083. },
  2084. })
  2085. countframe.append(gfcounter, sfcounter)
  2086. fsearch.append(filterList)
  2087. ssearch.append(siteSearcher)
  2088. btnHandles.append(btnHide, btnfullscreen, closebtn)
  2089. btnframe.append(
  2090. fsearch,
  2091. filterBtn,
  2092. ssearch,
  2093. siteSearchbtn,
  2094. btncfg,
  2095. btnissue,
  2096. btnhome,
  2097. btngreasy,
  2098. btnnav,
  2099. btnHandles,
  2100. )
  2101. header.append(countframe, rateContainer, btnframe)
  2102. tbody.append(table)
  2103.  
  2104. makeTHead([
  2105. {
  2106. class: 'mujs-header-name',
  2107. textContent: lang.name,
  2108. },
  2109. {
  2110. textContent: lang.createdby,
  2111. },
  2112. {
  2113. textContent: lang.daily,
  2114. },
  2115. {
  2116. textContent: lang.updated,
  2117. },
  2118. {
  2119. textContent: lang.install,
  2120. },
  2121. ])
  2122.  
  2123. for (const th of tabhead.rows[0].cells) {
  2124. if (dom.text(th) === lang.install) continue
  2125. dom.cl.add(th, 'mujs-pointer')
  2126. ael(th, 'click', () => {
  2127. sortRowBy(th.cellIndex)
  2128. })
  2129. }
  2130. main.append(header, tbody, cfgpage)
  2131. mainframe.append(mainbtn)
  2132. mujsRoot.append(mainframe, main)
  2133. injCon.append(mujsRoot)
  2134. makecfg()
  2135. buildlist()
  2136. timeoutFrame()
  2137. } catch (ex) {
  2138. err(ex)
  2139. }
  2140. }
  2141. /**
  2142. * @param {Function} callback
  2143. * @returns {null|boolean}
  2144. */
  2145. const loadDOM = (callback) => {
  2146. if (!isFN(callback)) {
  2147. return null
  2148. }
  2149. if (
  2150. document.readyState === 'interactive' ||
  2151. document.readyState === 'complete'
  2152. ) {
  2153. callback.call({}, document)
  2154. }
  2155. document.addEventListener(
  2156. 'DOMContentLoaded',
  2157. (evt) => callback.call({}, evt.target),
  2158. {
  2159. once: true,
  2160. },
  2161. )
  2162. return true
  2163. }
  2164. const Setup = async () => {
  2165. try {
  2166. cfg = setObj(defcfg, await MU.storage.getValue('Config'))
  2167. lang = langs[cfg.language] || langs[navLang] || langs.en
  2168. info('Config:', cfg)
  2169. loadDOM((doc) => {
  2170. if (window.location === null) {
  2171. return
  2172. }
  2173. if (doc === null) {
  2174. return
  2175. }
  2176. sleazyRedirect()
  2177. container.inject(main)
  2178. })
  2179. } catch (ex) {
  2180. err(ex)
  2181. }
  2182. }
  2183. if (
  2184. typeof userjs === 'object' &&
  2185. userjs.UserJS &&
  2186. window &&
  2187. window.self === window.top
  2188. ) {
  2189. Setup()
  2190. }
  2191.  
  2192. })();