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

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

目前為 2022-06-19 提交的版本,檢視 最新版本

  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. // @namespace https://github.com/magicoflolis/Userscript-Plus
  18. // @homepageURL https://github.com/magicoflolis/Userscript-Plus
  19. // @supportURL https://github.com/magicoflolis/Userscript-Plus/issues/new
  20. // @version 2.3.13
  21. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3ggEBCQHM3fXsAAAAVdJREFUOMudkz2qwkAUhc/goBaGJBgUtBCZyj0ILkpwAW7Bws4yO3AHLiCtEFD8KVREkoiFxZzX5A2KGfN4F04zMN+ce+5c4LMUgDmANYBnrnV+plBSi+FwyHq9TgA2LQpvCiEiABwMBtzv95RSfoNEHy8DYBzHrNVqVEr9BWKcqNFoxF6vx3a7zc1mYyC73a4MogBg7vs+z+czO50OW60Wt9stK5UKp9Mpj8cjq9WqDTBHnjAdxzGQZrPJw+HA31oulzbAWgLoA0CWZVBKIY5jzGYzdLtdE9DlcrFNrY98zobqOA6TJKHW2jg4nU5sNBpFDp6mhVe5rsvVasUwDHm9Xqm15u12o+/7Hy0gD8KatOd5vN/v1FozTVN6nkchxFuI6hsAAIMg4OPxMJCXdtTbR7JJCMEgCJhlGUlyPB4XfumozInrupxMJpRSRtZlKoNYl+m/6/wDuWAjtPfsQuwAAAAASUVORK5CYII=
  22. // @license MIT
  23. // @include *
  24. // @exclude *://paypal.com/*
  25. // @exclude *://mega.nz
  26. // @exclude *://*.alipay.com/*
  27. // @exclude *://*bank.*/*
  28. // @exclude *://*perfectmoney.*/*
  29. // @exclude *://*stripe.com/*
  30. // @exclude *://*ica.yandex.com/*
  31. // @exclude *://*authorize.net/*
  32. // @exclude *://*2checkout.com/*
  33. // @exclude *://192.168*
  34. // @exclude *://127.0.0*
  35. // @exclude *://router.*.*/*
  36. // @exclude *://gitlab.com/*
  37. // @exclude *://10.0.0*
  38. // @exclude *://*skrill.com/*
  39. // @exclude *://*zalo.me/*
  40. // @exclude *://pay.amazon.*/*
  41. // @exclude *://*.opayo.co.uk/*
  42. // @exclude *://*.payza.org/*
  43. // @exclude *://*.bluesnap.com/*
  44. // @exclude *://securionpay.com/*
  45. // @exclude *://*.unionpayintl.*/*
  46. // @exclude *://*.99bill.com/*
  47. // @exclude *://*.yeepay.com/*
  48. // @exclude *://*payoneer.com/*
  49. // @exclude *://*myetherwallet.com/*
  50. // @exclude *://bitpay.com/*
  51. // @exclude *://*.*/login
  52. // @exclude *://*.*/join
  53. // @exclude *://*.*/signin
  54. // @exclude *://*.*/signup
  55. // @exclude *://*.*/sign-up
  56. // @exclude *://*.*/cart
  57. // @exclude *://*.*.gov/*
  58. // @exclude *://*.*/password_reset
  59. // @exclude *://*.*/checkout*
  60. // @exclude *://*.*/settings/*
  61. // @exclude *://*.*/options/*
  62. // @exclude *://*.*.*/login
  63. // @exclude *://*.*.*/join
  64. // @exclude *://*.*.*/signin
  65. // @exclude *://*.*.*/signup
  66. // @exclude *://*.*.*/sign-up
  67. // @exclude *://*.*.*/cart
  68. // @exclude *://*.*.*/checkout*
  69. // @exclude *://*.*.*/settings/*
  70. // @exclude *://*.*.*/options/*
  71. // @exclude *://*.*.*.gov/*
  72. // @exclude *://*.*.*/password_reset
  73. // @require https://greasyfork.org/scripts/23419-l-js/code/ljs.js
  74. // @resource uiJs https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/dist/ui.js?_=1655670065574
  75. // @resource count https://greasyfork.org/scripts/by-site.json
  76. // @resource adult https://sleazyfork.org/scripts/by-site.json
  77. // @grant GM_xmlhttpRequest
  78. // @grant GM_getResourceText
  79. // @grant GM_getValue
  80. // @grant GM_setValue
  81. // @grant unsafeWindow
  82. // @noframes
  83. // @connect greasyfork.org
  84. // @connect sleazyfork.org
  85. // @connect cdn.jsdelivr.net
  86. // @run-at document-end
  87. // ==/UserScript==
  88.  
  89. /**
  90. * Enable built-in "Greasyfork Search with Sleazyfork Results include"
  91. * 启用内置"使用 Sleazyfork 搜索"结果包括"
  92. * 組み込みの「スライジーフォークの結果を含む脂っこく検索」を有効にする
  93. * Включить встроенный "Greasyfork Поиск с Sleazyfork Результаты включают"
  94. * https://greasyfork.org/scripts/23840
  95. */
  96. const sleazyfork_redirect = false, // "true" to enable, "false" to disable
  97. /**
  98. * Injected stylesheet
  99. * https://github.com/magicoflolis/Userscript-Plus/tree/master/src/sass
  100. */
  101. boxCSS = `*:not(select){scrollbar-color:#fff #2e323d;scrollbar-width:thin}::-webkit-scrollbar{max-width:8px !important;max-height:8px !important}::-webkit-scrollbar-thumb{background:#fff}::-webkit-scrollbar-track{background-color:#2e323d}body.userjs-popup{color:#fff !important;background-color:#2e323d !important;width:800px !important;height:550px;top:0px;left:0px}body.userjs-popup #app{position:fixed;width:inherit;display:grid;grid-template-rows:repeat(4, 1fr)}body.userjs-popup #app .ivu-card{width:100%;height:100%;padding:0px}body.userjs-popup #app .ivu-card-extra{top:8px !important}body.userjs-popup #app .ivu-card-head{border-bottom:1px solid #fff !important;padding:2.5% 16px !important}body.userjs-popup #app .ivu-badge{padding:0px 5px}body.userjs-popup #app .ivu-tooltip{border-color:#fff !important;border-radius:4px !important;background-color:#fff !important}body.userjs-popup #app .ivu-btn-icon-only,body.userjs-popup #app .ivu-modal-body,body.userjs-popup #app .ivu-table{color:#fff !important;background-color:#2e323d !important}body.userjs-popup #app .ivu-btn-icon-only td,body.userjs-popup #app .ivu-btn-icon-only th,body.userjs-popup #app .ivu-modal-body td,body.userjs-popup #app .ivu-modal-body th,body.userjs-popup #app .ivu-table td,body.userjs-popup #app .ivu-table th{color:#fff !important;background-color:#2e323d !important}body.userjs-popup #app .ivu-btn-icon-only-body,body.userjs-popup #app .ivu-modal-body-body,body.userjs-popup #app .ivu-table-body{overflow-x:hidden}body.userjs-popup #app .ivu-btn-icon-only-row-highlight,body.userjs-popup #app .ivu-btn-icon-only-row-hover,body.userjs-popup #app .ivu-modal-body-row-highlight,body.userjs-popup #app .ivu-modal-body-row-hover,body.userjs-popup #app .ivu-table-row-highlight,body.userjs-popup #app .ivu-table-row-hover{color:#9cc3e7 !important}body.userjs-popup #app .card-title{color:#fff !important;cursor:pointer}body.userjs-popup #app .table-footer{position:fixed;bottom:0;padding-left:10px;width:100%;background-color:#fff}body.userjs-popup #app .table-footer a{color:#ed3f14}body.userjs-popup #app .circle{width:56px;height:56px;line-height:56px;border-radius:28px;float:right;right:40px}body.userjs-popup #app .badge{top:-17px;left:-6%;width:26px;height:26px;line-height:26px;border-radius:13px}@media screen and (max-width: 1228px){.jae-userscript{max-width:100%;width:100%;height:100%}}.jae-userscript{position:fixed;width:370px;bottom:10px;right:20px;z-index:9999999999;height:56px;background:rgba(0,0,0,0)}.jae-userscript iframe{width:100%;height:100%;border:0px;border-radius:15px;display:block !important}.jae-userscript span{background-color:#2e323d;color:#fff;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;display:block;padding:1rem;border-radius:15px;right:10px;position:fixed}.jae-userscript-shadow{box-shadow:0 1px 4px rgba(0,0,0,.3)}.jae-userscript-shadow:after,.jae-userscript-shadow:before{content:"";position:absolute;z-index:-1;bottom:15px;left:10px;width:50%;height:20%;box-shadow:0 15px 10px rgba(0,0,0,.7)}.jae-userscript-shadow:after{right:10px;left:auto;transform:rotate(3deg)}.jae-userscript-shadow:before{transform:rotate(-3deg)}@media(prefers-color-scheme: dark){body.userjs-options :root{background-color:#202023;color:#e8eaed}body.userjs-options section:not(:first-child){border-top:1px solid #4c4c4e}}body.userjs-options form{font-size:1.25em}body.userjs-options section:not(:first-child){border-top:1px solid #4c4c4e}body.userjs-options section.checkbox>label,body.userjs-options section.checkboxlist>label,body.userjs-options section.select{display:flex;justify-content:space-between;padding:.825em}body.userjs-options section.checkbox>label,body.userjs-options section.checkboxlist>label{cursor:pointer}body.userjs-options section.checkboxlist{padding-left:.825em;padding-bottom:.5em}body.userjs-options section.checkboxlist>label{padding-top:.5em;padding-bottom:.5em}body.userjs-options section.checkboxlist p{margin-bottom:.5em}body.userjs-options .switch{position:relative;width:38px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}body.userjs-options .switch input{display:none}body.userjs-options .switch input:checked+label{background-color:#5a6f93;margin-left:0}body.userjs-options .switch input:checked+label:before{right:0px;background-color:#8ab4f8}body.userjs-options .switch label{display:block;overflow:hidden;cursor:pointer;height:16px;padding:0;line-height:16px;border:0px solid #fff;border-radius:20px;background-color:#9aa0a6}body.userjs-options .switch label:before{content:"";display:block;width:20px;height:20px;margin:-2px;background:#dadce0;position:absolute;top:0;right:20px;border-radius:20px}/*# sourceMappingURL=magicuserjs.css.map */
  102. `,
  103. err = (...error) => {
  104. console.error('[%cUserJS%c] %cERROR', 'color: rgb(29, 155, 240);', '', 'color: rgb(249, 24, 128);', ...error);
  105. };
  106.  
  107. if(typeof unsafeWindow === "undefined") {
  108. err('[%cUserJS%c] %cERROR', 'color: rgb(29, 155, 240);', '', 'color: rgb(249, 24, 128);', "Unsupported: unsafeWindow");
  109. } else {
  110. unsafeWindow.GmAjax = GM_xmlhttpRequest;
  111. };
  112.  
  113. /* eslint-disable no-undef */
  114. (() => {
  115. ljs.addAliases({
  116. jQuery:'https://cdn.jsdelivr.net/gh/jquery/jquery/dist/jquery.slim.min.js'
  117. });
  118. const win = self ?? window,
  119. doc = win.document,
  120. qs = (element, selector) => {
  121. selector = selector ?? doc ?? doc.body;
  122. return selector.querySelector(element);
  123. },
  124. delay = (ms) => {
  125. return new Promise(resolve => setTimeout(resolve, ms));
  126. },
  127. iframe = {
  128. write: () => {
  129. const root = qs('#jae_userscript_box > .jae-userscript',doc.body),
  130. dom = root.children[0],
  131. domDoc = `<!DOCTYPE html><html>
  132. <head>
  133. <meta charset="utf-8">
  134. <title>Show Site All UserJS</title>
  135. </head>
  136. <body style="background: none transparent">
  137. <div id="app"></div>
  138. </body></html>`;
  139. if (dom.tagName && "iframe" == dom.tagName.toLowerCase()) {
  140. let c = dom.contentDocument ?? dom.contentWindow.document;
  141. try {
  142. c.open();
  143. c.write(domDoc);
  144. c.close();
  145. } catch (d) {
  146. err(`loading "${dom.name}"`);
  147. if(root) {
  148. root.innerHTML = `<span>[ERROR] loading "${dom.name}"</span>`;
  149. delay(2500).then(() => {
  150. root.innerHTML = "";
  151. });
  152. };
  153. }
  154. }
  155. }
  156. },
  157. sleazy = () => {
  158. let otherSite = /greasyfork\.org/.test(location.hostname) ? "sleazyfork" : "greasyfork";
  159. qs('span.sign-in-link') ? /scripts\/\d+/.test(location.href) ? !qs("#script-info") && (otherSite == "greasyfork" || qs("div.width-constraint>section>p>a")) ? location.href = location.href.replace(/\/\/([^\.]+\.)?(greasyfork|sleazyfork)\.org/, "//$1" + otherSite + "\.org") : false : false : false;
  160. };
  161.  
  162. class FetchUserjs {
  163. constructor() {
  164. this.host = win.location.hostname.split(".").splice(-2).join(".");
  165. this.showTime = 10;
  166. this.quietKey = "jae_fetch_userjs_quiet";
  167. this.countKey = "jae_fetch_userjs_count";
  168. this.adultKey = "jae_fetch_userjs_adult";
  169. this.tplBox = `<div id="jae_userscript_box">
  170. <style>${boxCSS}</style>
  171. <div class="jae-userscript">
  172. <iframe class="UserJSFrame" name="jaeFetchUserJSFrame" src="about:blank" allowTransparency="true"></iframe>
  173. </div>
  174. </div>`;
  175. }
  176.  
  177. getCountData(host) {
  178. let countData = GM_getResourceText('count');
  179. countData = JSON.parse(countData);
  180. let count = countData[host];
  181. sessionStorage.setItem(this.countKey, count);
  182. return count;
  183. }
  184.  
  185. setSize(w, h) {
  186. qs('#jae_userscript_box > .jae-userscript',doc.body).setAttribute('style', `width: ${w}px;height: ${h}px;`);
  187. // $('.jae-userscript').css({
  188. // width: w,
  189. // height: h
  190. // });
  191. }
  192.  
  193. addEventListener(eventName, handler) {
  194. qs('#jae_userscript_box').addEventListener(eventName, handler);
  195. }
  196.  
  197. bindEvent() {
  198. this.timeId = setTimeout(() => {
  199. qs('#jae_userscript_box').remove();
  200. }, this.showTime * 1000);
  201. this.addEventListener('max', () => {
  202. this.setSize(860, 492);
  203. // qs('#jae_userscript_box > .jae-userscript').classList.add('jae-userscript-shadow');
  204. clearTimeout(this.timeId);
  205. });
  206. this.addEventListener('min', () => {
  207. // qs('#jae_userscript_box > .jae-userscript').classList.remove('jae-userscript-shadow');
  208. this.setSize(370, 56);
  209. // delay(500).then(() => {
  210. // this.setSize(370, 56);
  211. // });
  212. });
  213. this.addEventListener('close', () => {
  214. sessionStorage.setItem(this.quietKey, 1);
  215. qs('#jae_userscript_box').remove();
  216. });
  217. this.addEventListener('loading', () => {
  218. clearTimeout(this.timeId);
  219. });
  220. }
  221.  
  222. execFrameJs(frameWindow) {
  223. let uiJs = GM_getResourceText('uiJs');
  224. return function (jsStr) {
  225. frameWindow.eval(jsStr);
  226. }.call(frameWindow, uiJs);
  227. }
  228.  
  229. get isQuiet() {
  230. let quiet = sessionStorage.getItem(this.quietKey);
  231. return quiet ? true : false;
  232. }
  233.  
  234. render() {
  235. if (!this.isQuiet) {
  236. if (this.getCountData(this.host)) {
  237. $("body").append(this.tplBox);
  238. iframe.write();
  239. this.execFrameJs(jaeFetchUserJSFrame.window);
  240. this.bindEvent();
  241. }
  242. }
  243. }
  244.  
  245. }
  246.  
  247. let fu = new FetchUserjs();
  248. ljs.exec(['jQuery'], () => {
  249. /greasyfork\.org/.test(location.hostname) && sleazyfork_redirect ? sleazy() : false;
  250. fu.render();
  251. });
  252.  
  253. })();
  254.