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

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

当前为 2023-01-25 提交的版本,查看 最新版本

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