Magic Userscript+ : 顯示當前網站所有可用的UserJS腳本 Jaeger

顯示當前網站的所有可用UserJS(Tampermonkey)腳本,交流QQ群:104267383

目前為 2023-03-24 提交的版本,檢視 最新版本

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