Greasy Fork++

添加各种功能并改善 Greasy Fork 体验

当前为 2023-09-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Greasy Fork++
  3. // @namespace https://github.com/iFelix18
  4. // @version 3.2.20
  5. // @author CY Fung <https://greasyfork.org/users/371179> & Davide <iFelix18@protonmail.com>
  6. // @icon https://www.google.com/s2/favicons?domain=https://greasyfork.org
  7. // @description Adds various features and improves the Greasy Fork experience
  8. // @description:de Fügt verschiedene Funktionen hinzu und verbessert das Greasy Fork-Erlebnis
  9. // @description:es Agrega varias funciones y mejora la experiencia de Greasy Fork
  10. // @description:fr Ajoute diverses fonctionnalités et améliore l'expérience Greasy Fork
  11. // @description:it Aggiunge varie funzionalità e migliora l'esperienza di Greasy Fork
  12. // @description:ru Добавляет различные функции и улучшает работу с Greasy Fork
  13. // @description:zh-CN 添加各种功能并改善 Greasy Fork 体验
  14. // @description:zh-TW 加入多種功能並改善Greasy Fork的體驗
  15. // @description:ja Greasy Forkの体験を向上させる様々な機能を追加
  16. // @description:ko Greasy Fork 경험을 향상시키고 다양한 기능을 추가
  17. // @copyright 2023, CY Fung (https://greasyfork.org/users/371179); 2021, Davide (https://github.com/iFelix18)
  18. // @license MIT
  19. // @require https://fastly.jsdelivr.net/gh/sizzlemctwizzle/GM_config@06f2015c04db3aaab9717298394ca4f025802873/gm_config.min.js
  20. // @require https://fastly.jsdelivr.net/npm/@violentmonkey/shortcut@1.4.0/dist/index.min.js
  21. // @require https://fastly.jsdelivr.net/gh/cyfung1031/userscript-supports@3fa07109efca28a21094488431363862ccd52d7c/library/WinComm.min.js
  22. // @match *://greasyfork.org/*
  23. // @match *://sleazyfork.org/*
  24. // @connect greasyfork.org
  25. // @compatible chrome
  26. // @compatible edge
  27. // @compatible firefox
  28. // @compatible safari
  29. // @compatible brave
  30. // @grant GM.deleteValue
  31. // @grant GM.getValue
  32. // @grant GM.notification
  33. // @grant GM.registerMenuCommand
  34. // @grant GM.setValue
  35. // @grant unsafeWindow
  36. // @run-at document-start
  37. // @inject-into content
  38. // ==/UserScript==
  39.  
  40. /* global GM_config, VM, GM, WinComm */
  41.  
  42. /**
  43. * @typedef { typeof import("./library/WinComm.js") } WinComm
  44. */
  45.  
  46. // console.log(GM)
  47.  
  48. /** @type {WinComm} */
  49. const WinComm = this.WinComm;
  50.  
  51. // -------- UU Fucntion - original code: https://fastly.jsdelivr.net/npm/@ifelix18/utils@6.5.0/lib/index.min.js --------
  52. // optimized by CY Fung to remove $ dependency and observe creation
  53. const UU = (function () {
  54. const scriptName = GM.info.script.name; // not name_i18n
  55. const scriptVersion = GM.info.script.version;
  56. const authorMatch = /^(.*?)\s<\S[^\s@]*@\S[^\s.]*\.\S+>$/.exec(GM.info.script.author);
  57. const author = authorMatch ? authorMatch[1] : GM.info.script.author;
  58. let scriptId = scriptName.toLowerCase().replace(/\s/g, "-");
  59. let loggingEnabled = false;
  60.  
  61. const log = (message) => {
  62. if (loggingEnabled) {
  63. console.log(`${scriptName}:`, message);
  64. }
  65. };
  66.  
  67. const error = (message) => {
  68. console.error(`${scriptName}:`, message);
  69. };
  70.  
  71. const warn = (message) => {
  72. console.warn(`${scriptName}:`, message);
  73. };
  74.  
  75. const alert = (message) => {
  76. window.alert(`${scriptName}: ${message}`);
  77. };
  78.  
  79. /** @param {string} text */
  80. const short = (text, length) => {
  81. const s = text.split(" ");
  82. const l = Number(length);
  83. return s.length > l
  84. ? `${s.slice(0, l).join(" ")} [...]`
  85. : text;
  86. };
  87.  
  88. const addStyle = (css) => {
  89. const head = document.head || document.querySelector("head");
  90. const style = document.createElement("style");
  91. style.textContent = css;
  92. head.appendChild(style);
  93. };
  94.  
  95. const init = async (options = {}) => {
  96. scriptId = options.id || scriptId;
  97. loggingEnabled = typeof options.logging === "boolean" ? options.logging : false;
  98. console.info(
  99. `%c${scriptName}\n%cv${scriptVersion}${author ? ` by ${author}` : ""} is running!`,
  100. "color:red;font-weight:700;font-size:18px;text-transform:uppercase",
  101. ""
  102. );
  103. };
  104.  
  105. return {
  106. init,
  107. log,
  108. error,
  109. warn,
  110. alert,
  111. short,
  112. addStyle
  113. };
  114. })();
  115.  
  116. // -------- UU Fucntion - original code: https://fastly.jsdelivr.net/npm/@ifelix18/utils@6.5.0/lib/index.min.js --------
  117.  
  118.  
  119. const mWindow = (() => {
  120.  
  121.  
  122. const fields = {
  123. hideBlacklistedScripts: {
  124. label: 'Hide blacklisted scripts:<br><span>Choose which lists to activate in the section below, press <b>Ctrl + Alt + B</b> to show Blacklisted scripts</span>',
  125. section: ['Features'],
  126. labelPos: 'right',
  127. type: 'checkbox',
  128. default: true
  129. },
  130. hideHiddenScript: {
  131. label: 'Hide scripts:<br><span>Add a button to hide the script<br>See and edit the list of hidden scripts below, press <b>Ctrl + Alt + H</b> to show Hidden script',
  132. labelPos: 'right',
  133. type: 'checkbox',
  134. default: true
  135. },
  136. showInstallButton: {
  137. label: 'Install button:<br><span>Add to the scripts list a button to install the script directly</span>',
  138. labelPos: 'right',
  139. type: 'checkbox',
  140. default: true
  141. },
  142. showTotalInstalls: {
  143. label: 'Installations:<br><span>Shows the number of daily and total installations on the user profile</span>',
  144. labelPos: 'right',
  145. type: 'checkbox',
  146. default: true
  147. },
  148. milestoneNotification: {
  149. label: 'Milestone notifications:<br><span>Get notified whenever your total installs got over any of these milestone<br>Separate milestones with a comma, leave blank to turn off notifications</span>',
  150. labelPos: 'left',
  151. type: 'text',
  152. title: 'Separate milestones with a comma!',
  153. size: 150,
  154. default: '10, 100, 500, 1000, 2500, 5000, 10000, 100000, 1000000'
  155. },
  156. nonLatins: {
  157. label: 'Non-Latin:<br><span>This list blocks all scripts with non-Latin characters in the title/description</span>',
  158. section: ['Lists'],
  159. labelPos: 'right',
  160. type: 'checkbox',
  161. default: false // not true
  162. },
  163. blacklist: {
  164. label: 'Blacklist:<br><span>A "non-opinionable" list that blocks all scripts with emoji in the title/description, references to "bots", "cheats" and some online game sites, and other "bullshit"</span>',
  165. labelPos: 'right',
  166. type: 'checkbox',
  167. default: true
  168. },
  169. customBlacklist: {
  170. label: 'Custom Blacklist:<br><span>Personal blacklist defined by a set of unwanted words<br>Separate unwanted words with a comma (example: YouTube, Facebook, pizza), leave blank to disable this list</span>',
  171. labelPos: 'left',
  172. type: 'text',
  173. title: 'Separate unwanted words with a comma!',
  174. size: 150,
  175. default: ''
  176. },
  177. hiddenList: {
  178. label: 'Hidden Scripts:<br><span>Block individual undesired scripts by their unique IDs<br>Separate IDs with a comma</span>',
  179. labelPos: 'left',
  180. type: 'textarea',
  181. title: 'Separate IDs with a comma!',
  182. default: '',
  183. save: false
  184. },
  185. logging: {
  186. label: 'Logging',
  187. section: ['Developer options'],
  188. labelPos: 'right',
  189. type: 'checkbox',
  190. default: false
  191. },
  192. debugging: {
  193. label: 'Debugging',
  194. labelPos: 'right',
  195. type: 'checkbox',
  196. default: false
  197. }
  198. }
  199.  
  200. const logo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAASFBMVEVHcEwBAQEDAwMAAAACAgIBAQEAAAAREREDAwMBAQH///8WFhYuLi7U1NSdnZ1bW1vExMTq6uqtra309PRERETf399ycnKGhoaVOQEOAAAACnRSTlMAg87/rjLgE1rzhWrqxgAABexJREFUaN61WouSpCAMVPEJKCqi//+nF4IKKig6e1SduzfupEkT8oIkiRlVVdRpnmdlQ0hTZnme1kVV4Zvk96Fla8nH0ZSI8rP0Ks2uwi1Ilv4EURW5K5xS0slhMb/BkD0hrMk/q1HVeSP6QVILMFIY8wagn6ojTV5Xn8RnbFZaoAPQc9bR3gXQ/yaWvYYA8VfKKeXACZVnAE1V9o4on/izWPsb/q9Ji3j5OcrjhiCXohsAQso6lh6QL9qOEd6GAAbKYAInAFAiiqYC5LMeLIaFKeppR3h/BiAkj6CpLuEPmbbHngUBhFZsdAGiaUL5xLBzRrAAZBlk5wpnVJEohHTbuZoAD0uhMUu+uY/bLZHaryBCH4vQCuugbnSoYf5sk+llKWaEETT/Qu2TecmSHaF1KPT6gmkM4hNLLkIR2l/guAZK1fQrS3kVXmChEX5mKb0xICH/gKXrQtf2pbhlyfqFoL/1LUOVEbFwcsuSs5GfAcjJ8dVkknbafpYUfUXSQYWqRP81THcs8fbVMmTVaQU6ENNOdyxNgGRYmFsp2/mQaFiKzGeC1IcVmAjrDjq4LAF9RgdF13CAo3cTDRcAP2OOCjX6UAwCPpbWyGZsCWTMAM0YTGF2Eg0XAD8bramue9jocGVpi5y7LbUUVRO0dRINF2D9bN/PBSqgAizt8gHByJAUddEyTqa7rYF57oZkkgiYj48lYeVTuuh4Hw1A8pWhxr68snQYioOxHSm6A2gq1wuZz68suUMKELst8oCLfAew+rzMecmOLO251wYwa4CDmd4B8GyPM1YDlyXeUp8Gx412A9Chy6vP9cXO0kW+5e6N104vH68sXeW/jwzptss8OihFf1UAY2dVkgDCdQz8dfiv1m3sZek62rcIsJlr/5uADv1bhNqzxrcIb3VIkzz06m9YykMAM39kidIoAG+5R7icHlm6BViUVDqSZknpfd8NZh2MO1Xz+JKlcYsfZeK3UqjBTDRexn680PVoSxMFBiCST6RJJmXzg2FTegaPzyRWRWu9cERAHW4o6jANmPU0Ewwqe36wa8j1wyQLADHyk1FphM760H1sBY/+PtS5ECQTvucHynoapYPiZJKFDoSNnFxZYl0QYG2gQExtcJFN8LNl1voHOA++5yQelh5yVPhRopma8M3OALMO8p0GhgDT+lgKDatBhhvN5gcuRWaZJeQ8CzVBLmBLd2tgdrLND9xFxh9CW8JABYRSNQVYugJYK8rB2bn5gWOmaM4dzmXQVjvuidMzS3YfpEm9uPnBtp5yNFRJLRUTb9OaiN1x+06uk0q4+cG+U+SqCeoKLmMwrYkp1pYWRbUvgoDjDZng7EScG3/wSxAyK7+/Xvrgl974JZ1gp69r1Bc7LvUlXhEIsSxh4lWU5Ecdwixh6lhlhPwvlkyZlpIvCFEspW4B8h9YWguQYOZynzZEsJTvRWBPxwDABnKuXWJY2ovAKu8H9h7gkSXblqqFIB8AHlhyekbGUk2PYUbXtvgAXGnYjfWwNA+QcDHN3+x2Q2rngENgiSeeAUZfjDMVHkSn1m2GGBVwCh0d8NlfhJ4owiyE+VjiPV0WKQ7tHCxD1h6DeQ7PAMKWvUcERtt2PDakkio9f/1pkdcsxMOSLq7ldD5LAJf3BeCaCfQmDl57s/Xak4sHEJiPjOcdN4f61+n8CDDQaX/iIk8KcrOTDqCC4Km3tdw9AeBM1+dq1IqRE0stI8LbWk6K7AmAjYPeX/jEdF/qJtgpX+pDzfH9eCVunFyt1UEQUt8dUHwE2BE6b2f8A8I1WMxqGLQfyqu7I8zmOwBh08TJrfy36+ANw1XcQdrHEXOeWeTf5edRJ7JV+t/o+UKTc+hRxx8oF+lLaxKCvTmw1vcRshcAbGFZ8eFUv4kF4NnHewn5pM91sauv7z9gumDPPNgoobBq54/XHraLGyAZXPLqaFrnzIMpKoeR/3BxY7t6woWY2hYqZZ0u2DOPeZzZr1dP7OUZbk4MVE+wecrmqcn+5vLMevsneP3ncfwDNtu0vRpuz80AAAAASUVORK5CYII='
  201.  
  202. const locales = { /* cSpell: disable */
  203. de: {
  204. downgrade: 'Auf zurückstufen',
  205. hide: '❌ Dieses skript ausblenden',
  206. install: 'Installieren',
  207. notHide: '✔️ Dieses skript nicht ausblenden',
  208. milestone: 'Herzlichen Glückwunsch, Ihre Skripte haben den Meilenstein von insgesamt $1 Installationen überschritten!',
  209. reinstall: 'Erneut installieren',
  210. update: 'Auf aktualisieren'
  211. },
  212. en: {
  213. downgrade: 'Downgrade to',
  214. hide: '❌ Hide this script',
  215. install: 'Install',
  216. notHide: '✔️ Not hide this script',
  217. milestone: 'Congrats, your scripts got over the milestone of $1 total installs!',
  218. reinstall: 'Reinstall',
  219. update: 'Update to'
  220. },
  221. es: {
  222. downgrade: 'Degradar a',
  223. hide: '❌ Ocultar este script',
  224. install: 'Instalar',
  225. notHide: '✔️ No ocultar este script',
  226. milestone: '¡Felicidades, sus scripts superaron el hito de $1 instalaciones totales!',
  227. reinstall: 'Reinstalar',
  228. update: 'Actualizar a'
  229. },
  230. fr: {
  231. downgrade: 'Revenir à',
  232. hide: '❌ Cacher ce script',
  233. install: 'Installer',
  234. notHide: '✔️ Ne pas cacher ce script',
  235. milestone: 'Félicitations, vos scripts ont franchi le cap des $1 installations au total!',
  236. reinstall: 'Réinstaller',
  237. update: 'Mettre à'
  238. },
  239. it: {
  240. downgrade: 'Riporta a',
  241. hide: '❌ Nascondi questo script',
  242. install: 'Installa',
  243. notHide: '✔️ Non nascondere questo script',
  244. milestone: 'Congratulazioni, i tuoi script hanno superato il traguardo di $1 installazioni totali!',
  245. reinstall: 'Reinstalla',
  246. update: 'Aggiorna a'
  247. },
  248. ru: {
  249. downgrade: 'Откатить до',
  250. hide: '❌ Скрыть этот скрипт',
  251. install: 'Установить',
  252. notHide: '✔️ Не скрывать этот сценарий',
  253. milestone: 'Поздравляем, ваши скрипты преодолели рубеж в $1 установок!',
  254. reinstall: 'Переустановить',
  255. update: 'Обновить до'
  256. },
  257. 'zh-CN': {
  258. downgrade: '降级到',
  259. hide: '❌ 隐藏此脚本',
  260. install: '安装',
  261. notHide: '✔️ 不隐藏此脚本',
  262. milestone: '恭喜,您的脚本超过了 $1 次总安装的里程碑!',
  263. reinstall: '重新安装',
  264. update: '更新到'
  265. },
  266. 'zh-TW': {
  267. downgrade: '降級至',
  268. hide: '❌ 隱藏此腳本',
  269. install: '安裝',
  270. notHide: '✔️ 不隱藏此腳本',
  271. milestone: '恭喜,您的腳本安裝總數已超過 $1!',
  272. reinstall: '重新安裝',
  273. update: '更新至'
  274. },
  275. 'ja': {
  276. downgrade: 'ダウングレードする',
  277. hide: '❌ このスクリプトを隠す',
  278. install: 'インストール',
  279. notHide: '✔️ このスクリプトを隠さない',
  280. milestone: 'おめでとうございます、あなたのスクリプトの合計インストール回数が $1 を超えました!',
  281. reinstall: '再インストール',
  282. update: '更新する'
  283. },
  284. 'ko': {
  285. downgrade: '다운그레이드하기',
  286. hide: '❌ 이 스크립트 숨기기',
  287. install: '설치',
  288. notHide: '✔️ 이 스크립트 숨기지 않기',
  289. milestone: '축하합니다, 스크립트의 총 설치 횟수가 $1을 넘었습니다!',
  290. reinstall: '재설치',
  291. update: '업데이트하기'
  292. }
  293.  
  294. };
  295.  
  296. const blacklist = [ /* cSpell: disable-next-line */
  297. '\\bagar((\\.)?io)?\\b', '\\bagma((\\.)?io)?\\b', '\\baimbot\\b', '\\barras((\\.)?io)?\\b', '\\bbot(s)?\\b', '\\bbubble((\\.)?am)?\\b', '\\bcheat(s)?\\b', '\\bdiep((\\.)?io)?\\b', '\\bfreebitco((\\.)?in)?\\b', '\\bgota((\\.)?io)?\\b', '\\bhack(s)?\\b', '\\bkrunker((\\.)?io)?\\b', '\\blostworld((\\.)?io)?\\b', '\\bmoomoo((\\.)?io)?\\b', '\\broblox(\\.com)?\\b', '\\bshell\\sshockers\\b', '\\bshellshock((\\.)?io)?\\b', '\\bshellshockers\\b', '\\bskribbl((\\.)?io)?\\b', '\\bslither((\\.)?io)?\\b', '\\bsurviv((\\.)?io)?\\b', '\\btaming((\\.)?io)?\\b', '\\bvenge((\\.)?io)?\\b', '\\bvertix((\\.)?io)?\\b', '\\bzombs((\\.)?io)?\\b', '\\p{Extended_Pictographic}'
  298. ];
  299.  
  300.  
  301. const settingsCSS = `
  302.  
  303. /*
  304. #greasyfork-plus label::before {
  305. content:'';
  306. display:block;
  307. position:absolute;
  308. left:0;
  309. right:0;
  310. top:0;
  311. bottom:0;
  312. z-index:1;
  313. }
  314. #greasyfork-plus label {
  315. position:relative;
  316. z-index:0;
  317. }
  318. */
  319.  
  320. html {
  321. color: #222;
  322. background: #f9f9f9;
  323. }
  324.  
  325. #greasyfork-plus{
  326. --config-var-display: flex;
  327. }
  328. #greasyfork-plus * {
  329. font-family:Open Sans,sans-serif,Segoe UI Emoji !important;
  330. font-size:12px
  331. }
  332. #greasyfork-plus .section_header[class] {
  333. background-color:#670000;
  334. background-image:linear-gradient(#670000,#900);
  335. border:1px solid transparent;
  336. color:#fff
  337. }
  338. #greasyfork-plus .field_label[class]{
  339. margin-bottom:4px
  340. }
  341. #greasyfork-plus .field_label[class] span{
  342. font-size:95%;
  343. font-style:italic;
  344. opacity:.8;
  345. }
  346. #greasyfork-plus .field_label[class] b{
  347. color:#670000
  348. }
  349. #greasyfork-plus_logging_var[class],
  350. #greasyfork-plus_debugging_var[class] {
  351. --config-var-display: inline-flex;
  352. }
  353. #greasyfork-plus #greasyfork-plus_logging_var label.field_label[class],
  354. #greasyfork-plus #greasyfork-plus_debugging_var label.field_label[class] {
  355. margin-bottom:0;
  356. align-self: center;
  357. }
  358. #greasyfork-plus .config_var[class]{
  359. display:var(--config-var-display);
  360. position: relative;
  361. }
  362. #greasyfork-plus_customBlacklist_var[class],
  363. #greasyfork-plus_hiddenList_var[class],
  364. #greasyfork-plus_milestoneNotification_var[class]{
  365. flex-direction:column;
  366. margin-left:21px;
  367. }
  368.  
  369. #greasyfork-plus_customBlacklist_var[class]::before,
  370. #greasyfork-plus_hiddenList_var[class]::before,
  371. #greasyfork-plus_milestoneNotification_var[class]::before{
  372. /* content: "◉"; */
  373. content: "◎";
  374. position: absolute;
  375. left: auto;
  376. top: auto;
  377. margin-left: -16px;
  378. }
  379. #greasyfork-plus_field_customBlacklist[class],
  380. #greasyfork-plus_field_milestoneNotification[class]{
  381. flex:1;
  382. }
  383. #greasyfork-plus_field_hiddenList[class]{
  384. box-sizing:border-box;
  385. overflow:hidden;
  386. resize:none;
  387. width:100%
  388. }
  389.  
  390. body > #greasyfork-plus_wrapper:only-child {
  391. box-sizing: border-box;
  392. overflow: auto;
  393. max-height: calc(100vh - 72px);
  394. padding: 12px;
  395. /* overflow: auto; */
  396. scrollbar-gutter: both-edges;
  397. background: rgba(127,127,127,0.05);
  398. border: 1px solid rgba(127,127,127,0.5);
  399. }
  400.  
  401. #greasyfork-plus_wrapper > #greasyfork-plus_buttons_holder:last-child {
  402. position: fixed;
  403. bottom: 0;
  404. right: 0;
  405. margin: 0 12px 6px 0;
  406. }
  407.  
  408. #greasyfork-plus .saveclose_buttons[class] {
  409. padding: 4px 14px;
  410. margin: 6px;
  411. }
  412. #greasyfork-plus .section_header_holder#greasyfork-plus_section_2[class] {
  413. position: fixed;
  414. left: 0;
  415. bottom: 0;
  416. margin: 8px;
  417. }
  418. #greasyfork-plus .section_header#greasyfork-plus_section_header_2[class] {
  419. background: #000;
  420. color: #eee;
  421. }
  422.  
  423. #greasyfork-plus_header[class]{
  424. font-size: 16pt;
  425. font-weight: bold;
  426. }
  427.  
  428. `;
  429.  
  430. const pageCSS = `
  431.  
  432. .script-list li.blacklisted{
  433. display:none;
  434. background:#321919;
  435. color:#e8e6e3
  436. }
  437. .script-list li.hidden{
  438. display:none;
  439. background:#321932;
  440. color:#e8e6e3
  441. }
  442. .script-list li.blacklisted a:not(.install-link),.script-list li.hidden a:not(.install-link){
  443. color:#ff8484
  444. }
  445. #script-info.hidden,#script-info.hidden .user-content{
  446. background:#321932;
  447. color:#e8e6e3
  448. }
  449. #script-info.hidden a:not(.install-link):not(.install-help-link){
  450. color:#ff8484
  451. }
  452. #script-info.hidden code{
  453. background-color:transparent
  454. }
  455. html {
  456. --block-btn-color:#111;
  457. --block-btn-bgcolor:#eee;
  458. }
  459. #script-info.hidden, #script-info.hidden .user-content {
  460. --block-btn-color:#eee;
  461. --block-btn-bgcolor:#111;
  462. }
  463.  
  464. [style-54998]{
  465. float:right;
  466. font-size: 70%;
  467. text-decoration:none;
  468. }
  469.  
  470. [style-16377]{
  471. cursor:pointer;
  472. font-size:70%;
  473. white-space:nowrap;
  474. border: 1px solid #888;
  475. background: var(--block-btn-bgcolor, #eee);
  476. color: var(--block-btn-color);
  477. border-radius: 4px;
  478. padding: 0px 6px;
  479. margin: 0 8px;
  480. }
  481. [style-77329] {
  482. cursor: pointer;
  483. margin-left: 1ex;
  484. white-space: nowrap;
  485. float: right;
  486. border: 1px solid #888;
  487. background: var(--block-btn-bgcolor, #eee);
  488. color: var(--block-btn-color);
  489. border-radius: 4px;
  490. padding: 0px 6px;
  491. }
  492.  
  493. a#hyperlink-35389,
  494. a#hyperlink-40361,
  495. a#hyperlink-35389:visited,
  496. a#hyperlink-40361:visited,
  497. a#hyperlink-35389:hover,
  498. a#hyperlink-40361:hover,
  499. a#hyperlink-35389:focus,
  500. a#hyperlink-40361:focus,
  501. a#hyperlink-35389:active,
  502. a#hyperlink-40361:active {
  503.  
  504. border: none !important;
  505. outline: none !important;
  506. box-shadow: none !important;
  507. appearance: none !important;
  508. background: none !important;
  509. color:inherit !important;
  510. }
  511.  
  512. a#hyperlink-35389{
  513. opacity: var(--hyperlink-blacklisted-option-opacity);
  514.  
  515. }
  516. a#hyperlink-40361{
  517. opacity: var(--hyperlink-hidden-option-opacity);
  518. }
  519.  
  520.  
  521. html {
  522.  
  523. --hyperlink-blacklisted-option-opacity: 0.5;
  524. --hyperlink-hidden-option-opacity: 0.5;
  525. }
  526.  
  527.  
  528. .list-option.list-current[class] > a[href] {
  529.  
  530. text-decoration:none;
  531. }
  532.  
  533. html {
  534. --blacklisted-display: none;
  535. --hidden-display: none;
  536. }
  537.  
  538. [blacklisted-shown] {
  539. --blacklisted-display: list-item;
  540. --hyperlink-blacklisted-option-opacity: 1;
  541. }
  542. [hidden-shown] {
  543. --hidden-display: list-item;
  544. --hyperlink-hidden-option-opacity: 1;
  545. }
  546.  
  547. .script-list li.blacklisted{
  548. display: var(--blacklisted-display);
  549.  
  550. }
  551.  
  552. .script-list li.hidden{
  553. display: var(--hidden-display);
  554.  
  555. }
  556.  
  557. .install-link.install-status-checking,
  558. .install-link.install-status-checking:visited,
  559. .install-link.install-status-checking:active,
  560. .install-link.install-status-checking:hover,
  561. .install-help-link.install-status-checking {
  562. background-color: #405458;
  563. }
  564.  
  565. `
  566.  
  567. const window = {};
  568.  
  569. /** @param {typeof WinComm.createInstance} createInstance */
  570. function contentScriptText(shObject, createInstance) {
  571.  
  572. /*
  573. *
  574.  
  575. return new Promise((resolve, reject) => {
  576. const external = unsafeWindow.external;
  577. console.log(334, external)
  578. const scriptHandler = GM.info.scriptHandler;
  579. if (external && external.Violentmonkey && (scriptHandler || 'Violentmonkey') === 'Violentmonkey' ) {
  580. external.Violentmonkey.isInstalled(name, namespace).then((data) => resolve(data));
  581. return;
  582. }
  583.  
  584. if (external && external.Tampermonkey && (scriptHandler || 'Tampermonkey') === 'Tampermonkey') {
  585. external.Tampermonkey.isInstalled(name, namespace, (data) => {
  586. (data.installed) ? resolve(data.version) : resolve();
  587. });
  588. return;
  589. }
  590.  
  591. resolve();
  592. });
  593.  
  594. */
  595.  
  596.  
  597. const { scriptHandler, scriptName, scriptVersion, scriptNamespace, communicationId } = shObject;
  598.  
  599. const wincomm = createInstance(communicationId);
  600.  
  601. const external = window.external;
  602.  
  603. if (external[scriptHandler]) 1;
  604. else if (external && external.Violentmonkey && (scriptHandler || 'Violentmonkey') === 'Violentmonkey') scriptHandler = 'Violentmonkey';
  605. else if (external && external.Tampermonkey && (scriptHandler || 'Tampermonkey') === 'Tampermonkey') scriptHandler = 'Tampermonkey';
  606.  
  607. const manager = external[scriptHandler];
  608.  
  609. if (!manager) {
  610.  
  611. wincomm.send('userScriptManagerNotDetected', {
  612. code: 1
  613. });
  614. return;
  615.  
  616. }
  617.  
  618.  
  619. const pnIsInstalled2 = (type, scriptName, scriptNamespace) => new Promise((resolve, reject) => {
  620. const result = manager.isInstalled(scriptName, scriptNamespace);
  621. if (result instanceof Promise) {
  622. result.then((result) => resolve({
  623. type,
  624. result: typeof result === 'string' ? { version: result } : result
  625. })).catch(reject);
  626. } else {
  627. resolve({
  628. type,
  629. result: typeof result === 'string' ? { version: result } : result
  630. })
  631. }
  632.  
  633. }).catch(console.warn);
  634.  
  635.  
  636. const pnIsInstalled3 = (type, scriptName, scriptNamespace) => new Promise((resolve, reject) => {
  637. try {
  638. manager.isInstalled(scriptName, scriptNamespace, (result) => {
  639. resolve({
  640. type,
  641. result: typeof result === 'string' ? { version: result } : result
  642. })
  643.  
  644. });
  645. } catch (e) {
  646. reject(e);
  647. }
  648. }).catch(console.warn);
  649.  
  650.  
  651.  
  652. const enableScriptInstallChecker = (r) => {
  653.  
  654. const { type, result } = r;
  655. let version = result.version;
  656. // console.log(type, result, version)
  657. if (version !== scriptVersion) return;
  658.  
  659. const pnIsInstalled = type < 25 ? pnIsInstalled2 : pnIsInstalled3;
  660.  
  661. wincomm.hook('_$GreasyFork$Msg$OnScriptInstallCheck', {
  662.  
  663. 'installedVersion.req': (d, evt) => {
  664. pnIsInstalled(type, d.data.name, d.data.namespace).then((r) => {
  665. if (r && 'result' in r) {
  666. wincomm.response(evt, 'installedVersion.res', {
  667. version: r.result ? (r.result.version || '') : ''
  668. });
  669. }
  670. })
  671. }
  672.  
  673. });
  674.  
  675. wincomm.send('ready', { type });
  676.  
  677. // console.log('enableScriptInstallChecker', r)
  678.  
  679.  
  680. }
  681.  
  682. const kl = manager.isInstalled.length;
  683.  
  684. if (!(kl === 2 || kl === 3)) return;
  685. const puds = kl === 2 ? [
  686. pnIsInstalled2(21, scriptName, scriptNamespace), // scriptName is GM.info.script.name not GM.info.script.name_i18n
  687. pnIsInstalled2(20, scriptName, '')
  688. ] : [
  689. pnIsInstalled3(31, scriptName, scriptNamespace),
  690. pnIsInstalled3(30, scriptName, '')
  691. ];
  692.  
  693. Promise.all(puds).then((rs) => {
  694. const [r1, r0] = rs;
  695. if (r0 && r0.result && r0.result.version) enableScriptInstallChecker(r0); // '3.1.4'
  696. else if (r1 && r1.result && r1.result.version) enableScriptInstallChecker(r1);
  697. });
  698.  
  699.  
  700.  
  701. // console.log(327, shObject, scriptHandler);
  702.  
  703. }
  704.  
  705.  
  706.  
  707. return { fields, logo, locales, blacklist, settingsCSS, pageCSS, contentScriptText }
  708.  
  709.  
  710.  
  711. })();
  712.  
  713. (async () => {
  714.  
  715. function fixValue(key, def, test) {
  716. return GM.getValue(key, def).then((v) => test(v) || GM.deleteValue(key))
  717. }
  718.  
  719. function numberArr(arrVal) {
  720. if (!arrVal || typeof arrVal.length !== 'number') return [];
  721. return arrVal.filter(e => typeof e === 'number' && !isNaN(e))
  722. }
  723.  
  724. const isScriptFirstUse = await GM.getValue('firstUse', true);
  725. await Promise.all([
  726. fixValue('hiddenList', [], v => v && typeof v === 'object' && typeof v.length === 'number' && (v.length === 0 || typeof v[0] === 'number')),
  727. fixValue('lastMilestone', 0, v => v && typeof v === 'number' && v >= 0)
  728. ])
  729.  
  730. function createRE(t, ...opt) {
  731. try {
  732. return new RegExp(t, ...opt);
  733. } catch (e) { }
  734. return null;
  735. }
  736.  
  737. const useHashedScriptName = true;
  738.  
  739. const id = 'greasyfork-plus';
  740. const title = `${GM.info.script.name} v${GM.info.script.version} Settings`;
  741. const fields = mWindow.fields;
  742. const logo = mWindow.logo;
  743. const nonLatins = /[^\p{Script=Latin}\p{Script=Common}\p{Script=Inherited}]/gu;
  744. const blacklist = createRE((mWindow.blacklist || []).join('|'), 'giu');
  745. const hiddenList = numberArr(await GM.getValue('hiddenList', []));
  746. const lang = document.documentElement.lang;
  747. const locales = mWindow.locales;
  748.  
  749. function hiddenListStrToArr(str) {
  750. if (!str || typeof str !== 'string') str = '';
  751. return [...new Set(str ? numberArr(str.split(',').map(e => parseInt(e))) : [])];
  752. }
  753.  
  754. const gmc = new GM_config({
  755. id,
  756. title,
  757. fields,
  758. css: mWindow.settingsCSS,
  759. events: {
  760. init: () => {
  761. gmc.initializedResolve && gmc.initializedResolve();
  762. gmc.initializedResolve = null;
  763.  
  764. },
  765. /** @param {Document} document */
  766. open: async (document) => {
  767. const textarea = document.querySelector(`#${id}_field_hiddenList`);
  768.  
  769. const hiddenSet = new Set(numberArr(await GM.getValue('hiddenList', [])));
  770. if (hiddenSet.size !== 0) {
  771. const unsavedHiddenList = hiddenListStrToArr(gmc.get('hiddenList'));
  772. const unsavedHiddenSet = new Set(unsavedHiddenList);
  773.  
  774. const hasDifferentItems = [...hiddenSet].some(item => !unsavedHiddenSet.has(item)) || [...unsavedHiddenSet].some(item => !hiddenSet.has(item));
  775.  
  776. if (hasDifferentItems) {
  777.  
  778. gmc.fields.hiddenList.value = [...hiddenSet].sort((a, b) => a - b).join(', ');
  779.  
  780. gmc.close();
  781. gmc.open();
  782.  
  783. }
  784.  
  785.  
  786. }
  787.  
  788. const resize = (target) => {
  789. target.style.height = '';
  790. target.style.height = `${target.scrollHeight}px`;
  791. };
  792.  
  793. if (textarea) {
  794. resize(textarea);
  795. textarea.addEventListener('input', (event) => resize(event.target));
  796.  
  797. }
  798.  
  799. document.body.addEventListener('mousedown', (event) => {
  800. if (event.detail > 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey && !event.defaultPrevented) {
  801. event.preventDefault();
  802. event.stopPropagation();
  803. event.stopImmediatePropagation();
  804. }
  805. }, true);
  806. },
  807. save: async (forgotten) => {
  808.  
  809. if (gmc.isOpen) {
  810. await GM.setValue('hiddenList', hiddenListStrToArr(forgotten.hiddenList));
  811.  
  812. UU.alert('settings saved');
  813. gmc.close();
  814. setTimeout(() => window.location.reload(false), 500);
  815. }
  816. }
  817. }
  818. });
  819. gmc.initialized = new Promise(r => (gmc.initializedResolve = r));
  820. await gmc.initialized.then();
  821. const customBlacklistRE = createRE((gmc.get('customBlacklist') || '').replace(/\s/g, '').split(',').join('|'), 'giu');
  822.  
  823. if (typeof GM.registerMenuCommand === 'function') {
  824. GM.registerMenuCommand('Configure', () => gmc.open());
  825. GM.registerMenuCommand('Reset Everything', () => {
  826. Promise.all([
  827. GM.deleteValue('hiddenList'),
  828. GM.deleteValue('lastMilestone'),
  829. GM.deleteValue('firstUse')
  830. ]).then(() => {
  831. setTimeout(() => window.location.reload(false), 50);
  832. })
  833. });
  834. }
  835.  
  836. UU.init({ id, logging: gmc.get('logging') });
  837. UU.log(nonLatins);
  838. UU.log(blacklist);
  839. UU.log(hiddenList);
  840.  
  841. const _VM = (typeof VM !== 'undefined' ? VM : null) || {
  842. shortcut: {
  843. register: () => { }
  844. }
  845. };
  846.  
  847.  
  848. function fixLibraryCodeURL(code_url) {
  849. code_url = code_url.replace(/\/scripts\/(\d+)(\-[^\/]+)\/code\//, '/scripts/$1/code/');
  850. let qm = code_url.indexOf('?');
  851. let s1 = code_url.substring(0, qm);
  852. let s2 = code_url.substring(qm + 1);
  853. code_url = `${decodeURI(s1)}?${s2}`;
  854. return code_url;
  855. }
  856.  
  857. function setClickToSelect(elm) {
  858. elm.addEventListener('click', function () {
  859. if (window.getSelection() + "" === "") {
  860. if (typeof this.select === 'function') {
  861. this.select();
  862. } else {
  863. const range = document.createRange(); // Create a range object
  864. range.selectNode(this); // Select the text within the element
  865. const selection = window.getSelection(); // Get the selection object
  866. selection.removeAllRanges(); // First clear any existing selections
  867. selection.addRange(range); // Add the new range to the selection
  868. }
  869. }
  870. });
  871. elm.addEventListener('drag', function (evt) {
  872. evt.preventDefault();
  873. });
  874. elm.addEventListener('drop', function (evt) {
  875. evt.preventDefault();
  876. });
  877. elm.addEventListener('dragstart', function (evt) {
  878. evt.preventDefault();
  879. });
  880. }
  881.  
  882. const copyText = typeof (((window.navigator || 0).clipboard || 0).writeText) === 'function' ? (text) => {
  883. navigator.clipboard.writeText(text).then(function () {
  884. //
  885. }).catch(function (err) {
  886. alert("Unable to Copy");
  887. });
  888. } : (text) => {
  889. const textToCopy = document.createElement('strong');
  890. textToCopy.style.position = 'fixed';
  891. textToCopy.style.opacity = '0';
  892. textToCopy.style.top = '-900vh';
  893. textToCopy.textContent = text;
  894. document.body.appendChild(textToCopy);
  895.  
  896. const range = document.createRange(); // Create a range object
  897. range.selectNode(textToCopy); // Select the text within the element
  898.  
  899. const selection = window.getSelection(); // Get the selection object
  900. selection.removeAllRanges(); // First clear any existing selections
  901. selection.addRange(range); // Add the new range to the selection
  902.  
  903. try {
  904. document.execCommand('copy'); // Try to copy the selected text
  905. } catch (err) {
  906. alert("Unable to Copy");
  907. }
  908.  
  909. selection.removeAllRanges(); // Remove the selection range after copying
  910. textToCopy.remove();
  911. };
  912.  
  913.  
  914. let avoidDuplication = 0;
  915. const avoidDuplicationF = () => {
  916. const p = avoidDuplication;
  917. avoidDuplication = Date.now();
  918. if (avoidDuplication - p < 30) return false;
  919. return true;
  920. }
  921. // https://violentmonkey.github.io/vm-shortcut/
  922. const shortcuts = [
  923. ['ctrlcmd-alt-keys', () => avoidDuplicationF() && gmc.open()],
  924. ['ctrlcmd-alt-keyb', () => avoidDuplicationF() && toggleListDisplayingItem('blacklisted')],
  925. ['ctrlcmd-alt-keyh', () => avoidDuplicationF() && toggleListDisplayingItem('hidden')]
  926. ]
  927. for (const [scKey, scFn] of shortcuts) {
  928. _VM.shortcut.register(scKey, scFn);
  929. }
  930.  
  931. const addSettingsToMenu = () => {
  932. const nav = document.querySelector('#site-nav > nav')
  933. if (!nav) return;
  934.  
  935. const scriptName = GM.info.script.name;
  936. const scriptVersion = GM.info.script.version;
  937. const menu = document.createElement('li');
  938. menu.classList.add(id);
  939. menu.setAttribute('alt', `${scriptName} ${scriptVersion}`);
  940. menu.setAttribute('title', `${scriptName} ${scriptVersion}`);
  941. const link = document.createElement('a');
  942. link.setAttribute('href', '#');
  943. link.textContent = GM.info.script.name;
  944. menu.appendChild(link);
  945. nav.insertBefore(menu, document.querySelector('#site-nav > nav > li:first-of-type'));
  946.  
  947. menu.addEventListener('click', (e) => {
  948. e.preventDefault();
  949. e.stopPropagation();
  950. e.stopImmediatePropagation();
  951. gmc.open();
  952. });
  953. };
  954.  
  955.  
  956. const toggleListDisplayingItem = (t) => {
  957.  
  958. const m = document.documentElement;
  959.  
  960. const p = t + '-shown';
  961. let currentIsShown = m.hasAttribute(p)
  962. if (!currentIsShown) {
  963. m.setAttribute(p, '')
  964. } else {
  965. m.removeAttribute(p)
  966. }
  967.  
  968. }
  969.  
  970. const createListOptionGroup = () => {
  971.  
  972. const html = `<div class="list-option-group" id="${id}-options">${GM.info.script.name} Lists:<ul>
  973. <li class="list-option blacklisted"><a href="#" id="hyperlink-35389"></a></li>
  974. <li class="list-option hidden"><a href="#" id="hyperlink-40361"></a></li>
  975. </ul></div>`;
  976. const firstOptionGroup = document.querySelector('.list-option-groups > div');
  977. firstOptionGroup && firstOptionGroup.insertAdjacentHTML('beforebegin', html);
  978.  
  979. const blacklistedOption = document.querySelector(`#${id}-options li.blacklisted`);
  980. blacklistedOption && blacklistedOption.addEventListener('click', (evt) => {
  981. evt.preventDefault();
  982. toggleListDisplayingItem('blacklisted');
  983. }, false);
  984.  
  985. const hiddenOption = document.querySelector(`#${id}-options li.hidden`);
  986. hiddenOption && hiddenOption.addEventListener('click', (evt) => {
  987. evt.preventDefault();
  988. toggleListDisplayingItem('hidden');
  989. }, false);
  990.  
  991. }
  992.  
  993. const addOptions = () => {
  994.  
  995. const gn = () => {
  996.  
  997. let aBlackList = document.querySelector('#hyperlink-35389');
  998. let aHidden = document.querySelector('#hyperlink-40361');
  999. if (!aBlackList || !aHidden) return;
  1000. aBlackList.textContent = `Blacklisted scripts (${document.querySelectorAll('.script-list li.blacklisted').length})`;
  1001. aHidden.textContent = `Hidden scripts (${document.querySelectorAll('.script-list li.hidden').length})`
  1002.  
  1003. }
  1004. const callback = (entries) => {
  1005. if (entries && entries.length >= 1) requestAnimationFrame(gn);
  1006. }
  1007.  
  1008. const setupScriptList = async () => {
  1009. let scriptList;
  1010. let i = 8;
  1011. while (i-- > 0) {
  1012. scriptList = document.querySelector('.script-list li')
  1013. if (scriptList) scriptList = scriptList.closest('.script-list')
  1014. if (scriptList) break;
  1015. await new Promise(r => requestAnimationFrame(r))
  1016. }
  1017. if (!scriptList) return;
  1018. createListOptionGroup();
  1019. const mo = new MutationObserver(callback);
  1020. mo.observe(scriptList, { childList: true, subtree: true });
  1021. gn();
  1022. }
  1023. setupScriptList();
  1024.  
  1025. };
  1026.  
  1027.  
  1028. /**
  1029. * Get script data from Greasy Fork API
  1030. *
  1031. * @param {number} id Script ID
  1032. * @returns {Promise} Script data
  1033. */
  1034. let networkMP1 = Promise.resolve();
  1035. let networkMP2 = Promise.resolve();
  1036. let previousIsCache = false;
  1037. // let ss = [];
  1038. // var sum = function(nums) {
  1039. // var total = 0;
  1040. // for (var i = 0, len = nums.length; i < len; i++) total += nums[i];
  1041. // return total;
  1042. // };
  1043. const getScriptData = async (id, noCache) => {
  1044. if (!(id >= 0)) return Promise.resolve()
  1045. const url = `https://${window.location.hostname}/scripts/${id}.json`;
  1046. return new Promise((resolve, reject) => {
  1047.  
  1048. networkMP1 = networkMP1.then(() => new Promise(unlock => {
  1049.  
  1050. const maxAgeInSeconds = 900;
  1051. const rd = previousIsCache ? 1 : Math.floor(Math.random() * 80 + 80);
  1052. let fetchStart = 0;
  1053. new Promise(r => setTimeout(r, rd))
  1054. .then(() => {
  1055. fetchStart = Date.now();
  1056. })
  1057. .then(() => fetch(url, noCache ? {
  1058. method: 'GET',
  1059. cache: 'reload',
  1060. credentials: 'omit',
  1061. headers: new Headers({
  1062. 'Cache-Control': `max-age=${maxAgeInSeconds}`,
  1063. })
  1064. } : {
  1065. method: 'GET',
  1066. cache: 'force-cache',
  1067. credentials: 'omit',
  1068. headers: new Headers({
  1069. 'Cache-Control': `max-age=${maxAgeInSeconds}`,
  1070. }),
  1071. }))
  1072. .then((response) => {
  1073.  
  1074. let fetchStop = Date.now();
  1075. // const dd = fetchStop - fetchStart;
  1076. // dd (cache) = {min: 1, max: 8, avg: 3.7}
  1077. // dd (normal) = {min: 136, max: 316, avg: 162.62}
  1078.  
  1079. // ss.push(dd)
  1080. // ss.maxValue = Math.max(...ss);
  1081. // ss.minValue = Math.min(...ss);
  1082. // ss.avgValue = sum(ss)/ss.length;
  1083. // console.log(dd)
  1084. // console.log(ss)
  1085. previousIsCache = (fetchStop - fetchStart) < (3.7 + 162.62) / 2;
  1086. UU.log(`${response.status}: ${response.url}`)
  1087. // UU.log(response)
  1088. if (response.ok === true) {
  1089. unlock();
  1090. return response.json()
  1091. }
  1092. if (response.status === 503) {
  1093. return new Promise(r => setTimeout(r, 270 + rd)).then(() => {
  1094. unlock();
  1095. return getScriptData(id, true);
  1096. });
  1097. }
  1098. if (response.status === 404 ){
  1099. // script XXXX has been reported and is pending review by a moderator.
  1100. unlock();
  1101. return null
  1102. }
  1103. console.warn(response.status, response);
  1104. new Promise(r => setTimeout(r, 470)).then(unlock); // reload later
  1105. })
  1106. .then((data) => resolve(data))
  1107. .catch((e) => {
  1108. unlock();
  1109. UU.log(id, url)
  1110. console.warn(e)
  1111. // reject(e)
  1112. })
  1113.  
  1114. })).catch(() => { })
  1115.  
  1116. });
  1117. }
  1118.  
  1119. /**
  1120. * Get user data from Greasy Fork API
  1121. *
  1122. * @param {string} userID User ID
  1123. * @returns {Promise} User data
  1124. */
  1125. const getUserData = (userID, noCache) => {
  1126.  
  1127. if (!(userID >= 0)) return Promise.resolve()
  1128.  
  1129. const url = `https://${window.location.hostname}/users/${userID}.json`;
  1130. return new Promise((resolve, reject) => {
  1131.  
  1132.  
  1133. networkMP2 = networkMP2.then(() => new Promise(unlock => {
  1134.  
  1135. const maxAgeInSeconds = 900;
  1136. const rd = Math.floor(Math.random() * 80 + 80);
  1137.  
  1138. new Promise(r => setTimeout(r, rd))
  1139. .then(() => fetch(url, noCache ? {
  1140. method: 'GET',
  1141. cache: 'reload',
  1142. credentials: 'omit',
  1143. headers: new Headers({
  1144. 'Cache-Control': `max-age=${maxAgeInSeconds}`,
  1145. })
  1146. } : {
  1147. method: 'GET',
  1148. cache: 'force-cache',
  1149. credentials: 'omit',
  1150. headers: new Headers({
  1151. 'Cache-Control': `max-age=${maxAgeInSeconds}`,
  1152. }),
  1153. }))
  1154. .then((response) => {
  1155. UU.log(`${response.status}: ${response.url}`)
  1156. if (response.ok === true) {
  1157. unlock();
  1158. return response.json()
  1159. }
  1160. if (response.status === 503) {
  1161. return new Promise(r => setTimeout(r, 270 + rd)).then(() => {
  1162. unlock();
  1163. return getUserData(userID, true); // reload later
  1164. });
  1165. }
  1166. if (response.status === 404 ){
  1167. // user XXXX has been reported and is pending review by a moderator. ????
  1168. unlock();
  1169. return null
  1170. }
  1171. console.warn(response.status, response);
  1172. new Promise(r => setTimeout(r, 470)).then(unlock);
  1173. })
  1174. .then((data) => resolve(data))
  1175. .catch((e) => {
  1176. setTimeout(() => {
  1177. unlock()
  1178. }, 270)
  1179. UU.log(userID, url)
  1180. console.warn(e)
  1181. // reject(e)
  1182. })
  1183.  
  1184.  
  1185.  
  1186. })).catch(() => { })
  1187.  
  1188. });
  1189. }
  1190. const getTotalInstalls = (data) => {
  1191. if (!data || !data.scripts) return;
  1192. return new Promise((resolve, reject) => {
  1193. const totalInstalls = [];
  1194.  
  1195. data.scripts.forEach((element) => {
  1196. totalInstalls.push(parseInt(element.total_installs, 10));
  1197. });
  1198.  
  1199. resolve(totalInstalls.reduce((a, b) => a + b, 0));
  1200. });
  1201. };
  1202.  
  1203.  
  1204. const communicationId = WinComm.newCommunicationId();
  1205. const wincomm = WinComm.createInstance(communicationId);
  1206.  
  1207.  
  1208. const isInstalled = (script) => {
  1209. return new Promise((resolve, reject) => {
  1210.  
  1211. promiseScriptCheck.then(d => {
  1212.  
  1213. if (!d) return null;
  1214.  
  1215. const data = d.data;
  1216. const al = data.type % 10;
  1217. if (al === 0) {
  1218. // no namespace
  1219. resolve([null, script.name, '']);
  1220. } else if (al === 1) {
  1221. // namespace
  1222.  
  1223. if (!script.namespace) {
  1224.  
  1225. getScriptData(script.id).then((script) => {
  1226. resolve([null, script.name, script.namespace]);
  1227. });
  1228.  
  1229. } else {
  1230.  
  1231. resolve([null, script.name, script.namespace]);
  1232. }
  1233.  
  1234. }
  1235.  
  1236.  
  1237. })
  1238.  
  1239.  
  1240. }).then((res) => {
  1241.  
  1242.  
  1243. return new Promise((resolve, reject) => {
  1244.  
  1245. if (!res) return '';
  1246.  
  1247.  
  1248. const [_, name, namespace] = res;
  1249. wincomm.request('installedVersion.req', {
  1250. name,
  1251. namespace
  1252. }).then(d => {
  1253. resolve(d.data.version)
  1254. })
  1255.  
  1256. })
  1257.  
  1258. })
  1259.  
  1260. /*
  1261. const external = unsafeWindow.external;
  1262. const scriptHandler = GM.info.scriptHandler;
  1263. if (external && external.Violentmonkey && (scriptHandler || 'Violentmonkey') === 'Violentmonkey') {
  1264. external.Violentmonkey.isInstalled(name, namespace).then((data) => resolve(data));
  1265. return;
  1266. }
  1267.  
  1268. if (external && external.Tampermonkey && (scriptHandler || 'Tampermonkey') === 'Tampermonkey') {
  1269. external.Tampermonkey.isInstalled(name, namespace, (data) => {
  1270. (data.installed) ? resolve(data.version) : resolve();
  1271. });
  1272. return;
  1273. }
  1274. */
  1275.  
  1276.  
  1277. };
  1278.  
  1279. const compareVersions = (v1, v2) => {
  1280. if (!v1 || !v2) return NaN;
  1281. if (v1 === null || v2 === null) return NaN;
  1282. if (v1 === v2) return 0;
  1283.  
  1284. const sv1 = v1.split('.').map((index) => parseInt(index));
  1285. const sv2 = v2.split('.').map((index) => parseInt(index));
  1286.  
  1287. for (let index = 0; index < Math.max(sv1.length, sv2.length); index++) {
  1288. if (isNaN(sv1[index]) || isNaN(sv2[index])) return NaN;
  1289. if (sv1[index] > sv2[index]) return 1;
  1290. if (sv1[index] < sv2[index]) return -1;
  1291. }
  1292.  
  1293. return 0;
  1294. };
  1295.  
  1296.  
  1297. /**
  1298. * Return label for the hide script button
  1299. *
  1300. * @param {boolean} hidden Is hidden
  1301. * @returns {string} Label
  1302. */
  1303. const blockLabel = (hidden) => {
  1304. return hidden ? (locales[lang] ? locales[lang].notHide : locales.en.notHide) : (locales[lang] ? locales[lang].hide : locales.en.hide)
  1305. }
  1306.  
  1307. /**
  1308. * Return label for the install button
  1309. *
  1310. * @param {number} update Update value
  1311. * @returns {string} Label
  1312. */
  1313. const installLabel = (update) => {
  1314. switch (update) {
  1315. case 0: {
  1316. return locales[lang] ? locales[lang].reinstall : locales.en.reinstall
  1317. }
  1318. case 1: {
  1319. return locales[lang] ? locales[lang].update : locales.en.update
  1320. }
  1321. case -1: {
  1322. return locales[lang] ? locales[lang].downgrade : locales.en.downgrade
  1323. }
  1324. default: {
  1325. return locales[lang] ? locales[lang].install : locales.en.install
  1326. }
  1327. }
  1328. }
  1329.  
  1330. const hideBlacklistedScript = (element, list) => {
  1331. if (!element) return;
  1332. const scriptLink = element.querySelector('.script-link')
  1333.  
  1334. const name = scriptLink ? scriptLink.textContent : '';
  1335. const descriptionElem = element.querySelector('.script-description')
  1336. const description = descriptionElem ? descriptionElem.textContent : '';
  1337.  
  1338. if (!name) return;
  1339.  
  1340. switch (list) {
  1341. case 'nonLatins':
  1342. if ((nonLatins.test(name) || nonLatins.test(description)) && !element.classList.contains('blacklisted')) {
  1343. element.classList.add('blacklisted', 'non-latins');
  1344. if (gmc.get('hideBlacklistedScripts') && gmc.get('debugging')) {
  1345. let scriptLink = element.querySelector('.script-link');
  1346. if (scriptLink) { scriptLink.textContent += ' (non-latin)'; }
  1347. }
  1348. }
  1349. break;
  1350. case 'blacklist':
  1351. if (blacklist && (blacklist.test(name) || blacklist.test(description)) && !element.classList.contains('blacklisted')) {
  1352. element.classList.add('blacklisted', 'blacklist');
  1353. if (gmc.get('hideBlacklistedScripts') && gmc.get('debugging')) {
  1354. let scriptLink = element.querySelector('.script-link');
  1355. if (scriptLink) { scriptLink.textContent += ' (blacklist)'; }
  1356. }
  1357. }
  1358. break;
  1359. case 'customBlacklist': {
  1360. const customBlacklist = customBlacklistRE;
  1361. if (customBlacklist && (customBlacklist.test(name) || customBlacklist.test(description)) && !element.classList.contains('blacklisted')) {
  1362. element.classList.add('blacklisted', 'custom-blacklist');
  1363. if (gmc.get('hideBlacklistedScripts') && gmc.get('debugging')) {
  1364. let scriptLink = element.querySelector('.script-link');
  1365. if (scriptLink) { scriptLink.textContent += ' (custom-blacklist)'; }
  1366. }
  1367. }
  1368. break;
  1369. }
  1370. default:
  1371. UU.log('No blacklists');
  1372. break;
  1373. }
  1374. };
  1375.  
  1376. const hideHiddenScript = (element, id, list) => {
  1377. id = +id;
  1378. if (!(id >= 0)) return;
  1379.  
  1380. const isInHiddenList = () => hiddenList.indexOf(id) !== -1;
  1381. const updateScriptLink = (shouldHide) => {
  1382. if (gmc.get('hideHiddenScript') && gmc.get('debugging')) {
  1383. let scriptLink = element.querySelector('.script-link');
  1384. if (scriptLink) {
  1385. if (shouldHide) {
  1386. scriptLink.innerHTML += ' (hidden)';
  1387. } else {
  1388. scriptLink.innerHTML = scriptLink.innerHTML.replace(' (hidden)', '');
  1389. }
  1390. }
  1391. }
  1392. };
  1393.  
  1394. // Check for initial state and set it
  1395. if (isInHiddenList()) {
  1396. element.classList.add('hidden');
  1397. updateScriptLink(true);
  1398. }
  1399.  
  1400. // Add button to hide the script
  1401. const insertButtonHTML = (selector, html) => {
  1402. const target = element.querySelector(selector);
  1403. if (!target) return;
  1404. let p = document.createElement('template');
  1405. p.innerHTML = html;
  1406. target.parentNode.insertBefore(p.content.firstChild, target.nextSibling);
  1407. };
  1408.  
  1409. const isHidden = element.classList.contains('hidden');
  1410. const blockButtonHTML = `<span class=block-button role=button style-16377>${blockLabel(isHidden)}</span>`;
  1411. const blockButtonHeaderHTML = `<span class=block-button role=button style-77329 style="">${blockLabel(isHidden)}</span>`;
  1412.  
  1413. insertButtonHTML('.badge-js, .badge-css', blockButtonHTML);
  1414. insertButtonHTML('header h2', blockButtonHeaderHTML);
  1415.  
  1416. // Add event listener
  1417. const button = element.querySelector('.block-button');
  1418. if (button) {
  1419. button.addEventListener('click', (event) => {
  1420. event.stopPropagation();
  1421. event.stopImmediatePropagation();
  1422.  
  1423. if (!isInHiddenList()) {
  1424. hiddenList.push(id);
  1425. GM.setValue('hiddenList', hiddenList);
  1426.  
  1427. element.classList.add('hidden');
  1428. updateScriptLink(true);
  1429.  
  1430. } else {
  1431. const index = hiddenList.indexOf(id);
  1432. hiddenList.splice(index, 1);
  1433. GM.setValue('hiddenList', hiddenList);
  1434.  
  1435. element.classList.remove('hidden');
  1436. updateScriptLink(false);
  1437. }
  1438.  
  1439. const blockBtn = element.querySelector('.block-button');
  1440. if (blockBtn) blockBtn.textContent = blockLabel(element.classList.contains('hidden'));
  1441. });
  1442. }
  1443. };
  1444.  
  1445. const insertButtonHTML = (element, selector, html) => {
  1446. const target = element.querySelector(selector);
  1447. if (!target) return;
  1448. let p = document.createElement('template');
  1449. p.innerHTML = html;
  1450. let button = p.content.firstChild
  1451. target.parentNode.insertBefore(button, target.nextSibling);
  1452. return button;
  1453. };
  1454.  
  1455. const addInstallButton = (element, url) => {
  1456. return insertButtonHTML(element, '.badge-js, .badge-css', `<a class="install-link" href="${url}" style-54998></a>`);
  1457. };
  1458.  
  1459. async function digestMessage(message, algo) {
  1460. const encoder = new TextEncoder();
  1461. const data = encoder.encode(message);
  1462. const hash = await crypto.subtle.digest(algo, data);
  1463. return hash;
  1464. }
  1465.  
  1466. function qexString(buffer) {
  1467. const byteArray = new Uint8Array(buffer);
  1468. const len = byteArray.length;
  1469. const hexCodes = new Array(len * 2);
  1470. const chars = 'a4b3c5d7e6f9h2t';
  1471. for (let i = 0, j = 0; i < len; i++) {
  1472. const byte = byteArray[i];
  1473. hexCodes[j++] = chars[byte >> 4];
  1474. hexCodes[j++] = chars[byte & 0x0F];
  1475. };
  1476. return hexCodes.join('');
  1477. }
  1478.  
  1479. const showInstallButton = async (scriptID, element) => {
  1480.  
  1481. // if(document.querySelector(`li[data-script-id="${scriptID}"]`))
  1482. let _baseScript = null;
  1483. if (element.nodeName === 'LI' && element.hasAttribute('data-script-id') && element.getAttribute('data-script-id') === `${scriptID}` && element.getAttribute('data-script-language') === 'js') {
  1484.  
  1485. const version = element.getAttribute('data-script-version') || ''
  1486. const name = element.getAttribute('data-script-name') || ''
  1487. // if (!/[^\x00-\x7F]/.test(name)) {
  1488.  
  1489. const scriptName = useHashedScriptName ? qexString(await digestMessage(`${+scriptID} ${version}`, 'SHA-1')).substring(0, 8) : encodeURI(name);
  1490. const token = useHashedScriptName ? `${scriptName.substring(0, 2)}${scriptName.substring(scriptName.length - 2, scriptName.length)}` : String.fromCharCode(Date.now() % 26 + 97) + Math.floor(Math.random() * 19861 + 19861).toString(36);
  1491. // let scriptFilename = `${encodeURI(name)}.user.js`;
  1492. const scriptFilename = `${scriptName}.user.js`;
  1493. _baseScript = {
  1494. id: +scriptID,
  1495. // name: name,
  1496. code_url: `https://${location.hostname}/scripts/${scriptID}-${token}/code/${scriptFilename}`,
  1497. version: version
  1498. }
  1499. // }
  1500.  
  1501. }
  1502.  
  1503. const baseScript = _baseScript || (await getScriptData(scriptID));
  1504.  
  1505.  
  1506. if((element.nodeName === 'LI' && element.getAttribute('data-script-type')==='library') ||(baseScript.code_url.includes('.js?version=')) ){
  1507.  
  1508. const script = baseScript.code_url.includes('.js?version=') ? baseScript : (await getScriptData(scriptID));
  1509. if(script.code_url.includes('.js?version=')){
  1510.  
  1511.  
  1512. const code_url = fixLibraryCodeURL(script.code_url);
  1513.  
  1514. const button = addInstallButton(element, code_url);
  1515. button.textContent = `Copy URL`;
  1516. button.addEventListener('click', function(evt){
  1517.  
  1518. const target = (evt||0).target;
  1519. if(!target) return;
  1520. let a = target.nodeName ==='A'?target : target.querySelector('a[href]');
  1521.  
  1522. if(!a )return ;
  1523. let href = target.getAttribute('href');
  1524. if(!href) return;
  1525.  
  1526. evt.preventDefault();
  1527.  
  1528. copyText(href);
  1529.  
  1530.  
  1531. });
  1532.  
  1533. }
  1534.  
  1535. }else{
  1536.  
  1537.  
  1538. if (!baseScript || !baseScript.code_url || !baseScript.version) return;
  1539. const button = addInstallButton(element, baseScript.code_url);
  1540. button.classList.add('install-status-checking');
  1541. button.textContent = `${installLabel()} ${baseScript.version}`;
  1542. const script = baseScript && baseScript.name && baseScript.namespace ? baseScript : (await getScriptData(scriptID));
  1543. if (!script) return;
  1544. const installed = await isInstalled(script);
  1545. const version = (
  1546. baseScript.version && script.version && compareVersions(baseScript.version, script.version) === 1
  1547. ) ? baseScript.version : script.version;
  1548. const update = compareVersions(version, installed); // NaN 1 -1 0
  1549. const label = installLabel(update);
  1550. button.textContent = `${label} ${version}`;
  1551. button.classList.remove('install-status-checking');
  1552.  
  1553. }
  1554.  
  1555. }
  1556.  
  1557.  
  1558. const foundScriptList = async (scriptList) => {
  1559.  
  1560. let rid = 0;
  1561. let g = () => {
  1562. if (!scriptList || scriptList.isConnected !== true) return;
  1563.  
  1564. const scriptElements = scriptList.querySelectorAll('li[data-script-id]:not([e8kk])');
  1565.  
  1566. for (const element of scriptElements) {
  1567. element.setAttribute('e8kk', '1');
  1568.  
  1569. const scriptID = +element.getAttribute('data-script-id');
  1570. if (!(scriptID > 0)) continue;
  1571.  
  1572. // blacklisted scripts
  1573. if (gmc.get('nonLatins')) hideBlacklistedScript(element, 'nonLatins');
  1574. if (gmc.get('blacklist')) hideBlacklistedScript(element, 'blacklist');
  1575. if (gmc.get('customBlacklist')) hideBlacklistedScript(element, 'customBlacklist');
  1576.  
  1577. // hidden scripts
  1578. if (gmc.get('hideHiddenScript')) hideHiddenScript(element, scriptID, true);
  1579.  
  1580. // install button
  1581. if (gmc.get('showInstallButton')) {
  1582. showInstallButton(scriptID, element)
  1583. }
  1584. }
  1585.  
  1586. }
  1587. let f = (entries) => {
  1588. const tid = ++rid
  1589. if (entries && entries.length) requestAnimationFrame(() => {
  1590. if (tid === rid) g();
  1591. });
  1592. }
  1593. let mo = new MutationObserver(f);
  1594. mo.observe(scriptList, { subtree: true, childList: true });
  1595.  
  1596. g();
  1597.  
  1598. }
  1599.  
  1600. let promiseScriptCheckResolve = null;
  1601. const promiseScriptCheck = new Promise(resolve => {
  1602. promiseScriptCheckResolve = resolve
  1603. });
  1604.  
  1605. const milestoneNotificationFn = async (o)=>{
  1606.  
  1607. const {userLink, userID} = o;
  1608.  
  1609.  
  1610. const milestones = gmc.get('milestoneNotification').replace(/\s/g, '').split(',').map(Number);
  1611.  
  1612. if (!userID) return;
  1613.  
  1614. const userData = await getUserData(+userID.match(/\d+(?=\D)/g));
  1615. if (!userData) return;
  1616.  
  1617. const [totalInstalls, lastMilestone] = await Promise.all([
  1618. getTotalInstalls(userData),
  1619. GM.getValue('lastMilestone', 0)]);
  1620.  
  1621. const milestone = milestones.filter(milestone => totalInstalls >= milestone).pop();
  1622.  
  1623. UU.log(`total installs are "${totalInstalls}", milestone reached is "${milestone}", last milestone reached is "${lastMilestone}"`);
  1624.  
  1625. if (milestone <= lastMilestone) return;
  1626.  
  1627. if (milestone && milestone >= 0) {
  1628.  
  1629.  
  1630. GM.setValue('lastMilestone', milestone);
  1631.  
  1632. const lang = document.documentElement.lang;
  1633. const text = (locales[lang] ? locales[lang].milestone : locales.en.milestone).replace('$1', milestone.toLocaleString());
  1634.  
  1635. if (typeof GM.notification === 'function') {
  1636. GM.notification({
  1637. text,
  1638. title: GM.info.script.name,
  1639. image: logo,
  1640. onclick: () => {
  1641. window.location = `https://${window.location.hostname}${userID}#user-script-list-section`;
  1642. }
  1643. });
  1644. } else {
  1645. UU.alert(text);
  1646. }
  1647.  
  1648. }
  1649.  
  1650. }
  1651. const onReady = async () => {
  1652.  
  1653. try {
  1654.  
  1655. const gminfo = GM.info || 0;
  1656. if (gminfo) {
  1657.  
  1658. const gminfoscript = gminfo.script || 0;
  1659.  
  1660.  
  1661. const scriptHandlerObject = {
  1662. scriptHandler: gminfo.scriptHandler || '',
  1663. scriptName: gminfoscript.name || '', // not name_i18n
  1664. scriptVersion: gminfoscript.version || '',
  1665. scriptNamespace: gminfoscript.namespace || '',
  1666. communicationId
  1667. };
  1668.  
  1669.  
  1670. wincomm.hook('_$GreasyFork$Msg$OnScriptInstallFeedback',
  1671. {
  1672.  
  1673. ready: (d, evt) => promiseScriptCheckResolve(d),
  1674. userScriptManagerNotDetected: (d, evt) => promiseScriptCheckResolve(null),
  1675. 'installedVersion.res': wincomm.handleResponse
  1676.  
  1677.  
  1678. })
  1679.  
  1680.  
  1681. document.head.appendChild(document.createElement('script')).textContent = `;(${mWindow.contentScriptText})(${JSON.stringify(scriptHandlerObject)}, ${WinComm.createInstance});`;
  1682.  
  1683.  
  1684. }
  1685.  
  1686.  
  1687. addSettingsToMenu();
  1688.  
  1689.  
  1690. setTimeout(() => {
  1691. let installBtn = document.querySelector('a[data-script-id][data-script-version]')
  1692. let scriptID = installBtn && installBtn.textContent ? +installBtn.getAttribute('data-script-id') : 0;
  1693. if (scriptID > 0) {
  1694. getScriptData(scriptID, true);
  1695. } else {
  1696.  
  1697.  
  1698. const userLink = document.querySelector('#site-nav .user-profile-link a[href]');
  1699. let userID = userLink ? userLink.getAttribute('href') : '';
  1700.  
  1701. userID = userID ? /users\/(\d+)/.exec(userID) : null;
  1702. if (userID) userID = userID[1];
  1703. if (userID) {
  1704. userID = +userID;
  1705. if (userID > 0) {
  1706. getUserData(userID, true);
  1707. }
  1708. }
  1709.  
  1710.  
  1711. }
  1712. }, 740);
  1713.  
  1714. const userLink = document.querySelector('.user-profile-link a[href]');
  1715. const userID = userLink ? userLink.getAttribute('href') : undefined;
  1716.  
  1717. // blacklisted scripts / hidden scripts / install button
  1718. if (window.location.pathname !== userID && !/discussions/.test(window.location.pathname) && (gmc.get('hideBlacklistedScripts') || gmc.get('hideHiddenScript') || gmc.get('showInstallButton'))) {
  1719.  
  1720. const scriptList = document.querySelector('.script-list');
  1721. if (scriptList) {
  1722. foundScriptList(scriptList);
  1723. } else {
  1724. const timeout = Date.now() + 3000;
  1725. /** @type {MutationObserver | null} */
  1726. let mo = null;
  1727. const mutationCallbackForScriptList = () => {
  1728. if (!mo) return;
  1729. const scriptList = document.querySelector('.script-list');
  1730. if (scriptList) {
  1731. mo.disconnect();
  1732. mo.takeRecords();
  1733. mo = null;
  1734. foundScriptList(scriptList);
  1735. } else if (Date.now() > timeout) {
  1736. mo.disconnect();
  1737. mo.takeRecords();
  1738. mo = null;
  1739. }
  1740. }
  1741. mo = new MutationObserver(mutationCallbackForScriptList);
  1742. mo.observe(document, { subtree: true, childList: true });
  1743. }
  1744.  
  1745.  
  1746. // hidden scripts on details page
  1747. const installLinkElement = document.querySelector('#script-info .install-link[data-script-id]');
  1748. if (gmc.get('hideHiddenScript') && installLinkElement) {
  1749. const id = +installLinkElement.getAttribute('data-script-id');
  1750. hideHiddenScript(document.querySelector('#script-info'), id, false);
  1751. }
  1752.  
  1753. // add options and style for blacklisted/hidden scripts
  1754. if (gmc.get('hideBlacklistedScripts') || gmc.get('hideHiddenScript')) {
  1755. addOptions();
  1756. UU.addStyle(mWindow.pageCSS);
  1757. }
  1758.  
  1759. if (installLinkElement && location.pathname.includes('/scripts/')) {
  1760.  
  1761. installLinkElement.addEventListener('click', async function (e) {
  1762. if (e && e.isTrusted && location.pathname.includes('/scripts/')) {
  1763.  
  1764. await new Promise(r => setTimeout(r, 800));
  1765. await new Promise(r => window.requestAnimationFrame(r));
  1766. await new Promise(r => setTimeout(r, 100));
  1767. document.dispatchEvent(new Event("DOMContentLoaded"));
  1768. }
  1769. })
  1770. }
  1771. }
  1772.  
  1773. // total installs
  1774. if (gmc.get('showTotalInstalls') && document.querySelector('#user-script-list')) {
  1775. const dailyInstalls = [];
  1776. const totalInstalls = [];
  1777.  
  1778. const dailyInstallElements = document.querySelectorAll('#user-script-list li dd.script-list-daily-installs');
  1779. for (const element of dailyInstallElements) {
  1780. dailyInstalls.push(parseInt(element.textContent.replace(/\D/g, ''), 10));
  1781. }
  1782.  
  1783. const totalInstallElements = document.querySelectorAll('#user-script-list li dd.script-list-total-installs');
  1784. for (const element of totalInstallElements) {
  1785. totalInstalls.push(parseInt(element.textContent.replace(/\D/g, ''), 10));
  1786. }
  1787.  
  1788. const dailyInstallsSum = dailyInstalls.reduce((a, b) => a + b, 0);
  1789. const totalInstallsSum = totalInstalls.reduce((a, b) => a + b, 0);
  1790.  
  1791. const convertLi = (li) => {
  1792.  
  1793. if (!li) return null;
  1794. const a = li.firstElementChild
  1795. if (a === null) return li;
  1796. if (a === li.lastElementChild && a.nodeName === 'A') return a;
  1797.  
  1798.  
  1799. return null;
  1800. }
  1801.  
  1802. const plusSign = document.querySelector('#user-script-list-section a[rel="next"][href*="page="], #user-script-list-section a[rel="prev"][href*="page="]') ? '+' : '';
  1803.  
  1804. const dailyOption = convertLi(document.querySelector('#script-list-sort .list-option:nth-child(1)'));
  1805. dailyOption && dailyOption.insertAdjacentHTML('beforeend', `<span> (${dailyInstallsSum.toLocaleString()}${plusSign})</span>`);
  1806.  
  1807. const totalOption = convertLi(document.querySelector('#script-list-sort .list-option:nth-child(2)'));
  1808. totalOption && totalOption.insertAdjacentHTML('beforeend', `<span> (${totalInstallsSum.toLocaleString()}${plusSign})</span>`);
  1809. }
  1810.  
  1811. // milestone notification
  1812. if (gmc.get('milestoneNotification')) {
  1813. milestoneNotificationFn({userLink, userID});
  1814. }
  1815.  
  1816. if (isScriptFirstUse) GM.setValue('firstUse', false).then(() => {
  1817. gmc.open();
  1818. });
  1819.  
  1820.  
  1821. let xpath = "//code[contains(text(), '.js?version=')]";
  1822. let snapshot = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1823. for (let i = 0; i < snapshot.snapshotLength; i++) {
  1824. let element = snapshot.snapshotItem(i);
  1825. if (element.firstElementChild) continue;
  1826. element.textContent = element.textContent.replace(/\bhttps:\/\/(greasyfork|sleazyfork)\.org\/scripts\/\d+\-[^\/]+\/code\/[^\.]+\.js\?version=\d+\b/, (_) => {
  1827. return fixLibraryCodeURL(_);
  1828. });
  1829. element.parentNode.insertBefore(document.createTextNode('\u200B'), element);
  1830. element.style.display = 'inline-flex';
  1831. setClickToSelect(element);
  1832. }
  1833.  
  1834. } catch (e) {
  1835. console.log(e);
  1836. }
  1837.  
  1838. }
  1839.  
  1840.  
  1841.  
  1842. Promise.resolve().then(() => {
  1843. if (document.readyState !== 'loading') {
  1844. onReady();
  1845. } else {
  1846. window.addEventListener("DOMContentLoaded", onReady, false);
  1847. }
  1848. });
  1849.  
  1850. })();