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

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

当前为 2023-08-06 提交的版本,查看 最新版本

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