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

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

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

  1. // ==UserScript==
  2. // @name Magic Userscript+ : Show Site All UserJS
  3. // @name:zh Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger
  4. // @name:zh-CN Magic Userscript+ : 显示当前网站所有可用的UserJS脚本 Jaeger
  5. // @name:zh-TW Magic Userscript+ : 顯示當前網站所有可用的UserJS腳本 Jaeger
  6. // @name:ja Magic Userscript+ : 現在のサイトの利用可能なすべてのUserJSスクリプトを表示するJaeger
  7. // @name:ru-RU Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
  8. // @name:ru Magic Userscript+ : Показать пользовательские скрипты (UserJS) для сайта. Jaeger
  9. // @description Show current site all UserJS,The easier way to install UserJs for Tampermonkey.
  10. // @description:zh 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
  11. // @description:zh-CN 显示当前网站的所有可用UserJS(Tampermonkey)脚本,交流QQ群:104267383
  12. // @description:zh-TW 顯示當前網站的所有可用UserJS(Tampermonkey)腳本,交流QQ群:104267383
  13. // @description:ja 現在のサイトで利用可能なすべてのUserJS(Tampermonkey)スクリプトを表示します。
  14. // @description:ru-RU Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
  15. // @description:ru Показывает пользовательские скрипты (UserJS) для сайта. Легкий способ установить пользовательские скрипты для Tampermonkey.
  16. // @author Magic of Lolis <magicoflolis@gmail.com>
  17. // @namespace https://github.com/magicoflolis/Userscript-Plus
  18. // @homepageURL https://github.com/magicoflolis/Userscript-Plus#magic-userscript
  19. // @supportURL https://github.com/magicoflolis/Userscript-Plus/issues/new
  20. // @version 2.3.12
  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/code/ljs.js
  74. // @require https://greasyfork.org/scripts/428620/code/userjs-base.js?_=1624989578203
  75. // @resource uiJs https://cdn.jsdelivr.net/gh/magicoflolis/Userscript-Plus@master/dist/ui.gf.js?_=1624989578203
  76. // @resource count https://greasyfork.org/scripts/by-site.json
  77. // @resource adult https://sleazyfork.org/scripts/by-site.json
  78. // @grant GM_xmlhttpRequest
  79. // @grant GM_getResourceText
  80. // @grant GM_getValue
  81. // @grant GM_setValue
  82. // @grant unsafeWindow
  83. // @noframes
  84. // @connect greasyfork.org
  85. // @connect sleazyfork.org
  86. // @connect cdn.jsdelivr.net
  87. // @run-at document-end
  88. // ==/UserScript==
  89.  
  90. /**
  91. * Enable built-in "Greasyfork Search with Sleazyfork Results include"
  92. * 启用内置"使用 Sleazyfork 搜索"结果包括"
  93. * 組み込みの「スライジーフォークの結果を含む脂っこく検索」を有効にする
  94. * Включить встроенный "Greasyfork Поиск с Sleazyfork Результаты включают"
  95. * https://greasyfork.org/scripts/23840
  96. */
  97. let sleazyfork_redirect = false; // "true" to enable, "false" to disable
  98.  
  99. unsafeWindow.GmAjax = GM_xmlhttpRequest;
  100.  
  101. (() => {
  102. const iframe = {
  103. write: (iframeDom, content) => {
  104. if (iframeDom.tagName && "iframe" == iframeDom.tagName.toLowerCase()) {
  105. let c = iframeDom.contentWindow.document;
  106.  
  107. try {
  108. c.open(), c.write(content), c.close();
  109. } catch (d) {
  110. console.log("append HTML to [iframe:" + iframeDom.name + "] ERROR!");
  111. }
  112. }
  113. }
  114. },
  115. qs = element => {
  116. return document.querySelector(element);
  117. },
  118. sleazy = () => {
  119. let otherSite = /greasyfork\.org/.test(location.hostname) ? "sleazyfork" : "greasyfork";
  120. 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;
  121. };
  122.  
  123. class FetchUserjs {
  124. constructor() {
  125. this.host = window.location.hostname.split(".").splice(-2).join(".");
  126. this.showTime = 10;
  127. this.quietKey = "jae_fetch_userjs_quiet";
  128. this.countKey = "jae_fetch_userjs_count";
  129. this.adultKey = "jae_fetch_userjs_adult";
  130. this.tplBox = `<div id="jae_userscript_box">
  131. <style>.jae-userscript{
  132. position:fixed;
  133. width:370px;
  134. bottom:10px;
  135. right:20px;
  136. z-index:9999999999;
  137. height:56px
  138. }
  139. .jae-userscript-shadow{
  140. box-shadow:0 1px 4px rgba(0,0,0,.3);
  141. }
  142. .jae-userscript-shadow::before,
  143. .jae-userscript-shadow::after{
  144. content:"";
  145. position:absolute;
  146. z-index:-1;
  147. bottom:15px;
  148. left:10px;
  149. width:50%;
  150. height:20%;
  151. box-shadow:0 15px 10px rgba(0,0,0,.7);
  152. }
  153. .jae-userscript-shadow::before{
  154. transform:rotate(-3deg)
  155. }
  156. .jae-userscript-shadow::after{
  157. right:10px; left:auto;
  158. transform:rotate(3deg)
  159. }
  160. @media screen and (max-width:1228px) {
  161. .jae-userscript {
  162. max-width: 100%;
  163. width: 100%;
  164. height: 100%;
  165. }
  166. }
  167. </style><div class="jae-userscript"></div></div>`;
  168. }
  169.  
  170. getCountData(host) {
  171. let countData = GM_getResourceText('count');
  172. countData = JSON.parse(countData);
  173. let count = countData[host];
  174. sessionStorage.setItem(this.countKey, count);
  175. return count;
  176. }
  177.  
  178. setSize(w, h) {
  179. $('.jae-userscript').css({
  180. width: w,
  181. height: h
  182. });
  183. }
  184.  
  185. addEventListener(eventName, handler) {
  186. qs('#jae_userscript_box').addEventListener(eventName, handler);
  187. }
  188.  
  189. bindEvent() {
  190. this.timeId = setTimeout(() => {
  191. qs('#jae_userscript_box').remove();
  192. }, this.showTime * 1000);
  193. this.addEventListener('max', () => {
  194. this.setSize(860, 492);
  195. $('.jae-userscript').addClass('jae-userscript-shadow');
  196. clearTimeout(this.timeId);
  197. });
  198. this.addEventListener('min', () => {
  199. $('.jae-userscript').removeClass('jae-userscript-shadow');
  200. new Promise(resolve => setTimeout(resolve, 500));
  201. this.setSize(370, 56);
  202. });
  203. this.addEventListener('close', () => {
  204. sessionStorage.setItem(this.quietKey, 1);
  205. qs('#jae_userscript_box').remove();
  206. });
  207. this.addEventListener('loading', () => {
  208. clearTimeout(this.timeId);
  209. });
  210. }
  211.  
  212. execFrameJs(frameWindow) {
  213. let uiJs = GM_getResourceText('uiJs');
  214. return function (jsStr) {
  215. frameWindow.eval(jsStr);
  216. }.call(frameWindow, uiJs);
  217. }
  218.  
  219. get isQuiet() {
  220. let quiet = sessionStorage.getItem(this.quietKey);
  221. return quiet ? true : false;
  222. }
  223.  
  224. render() {
  225. if (!this.isQuiet) {
  226. let count = this.getCountData(this.host);
  227.  
  228. if (count) {
  229. $("body").append(this.tplBox);
  230. let ui = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Show Site All UserJS</title></head><body style="background: none transparent"><div id="app"></div></body></html>',
  231. dom = document.getElementsByClassName('jae-userscript')[0];
  232. dom.innerHTML = '<iframe name="jaeFetchUserJSFrame" src="about:blank" style="width:100%;height:100%;border:0px;display: block!important;" allowTransparency="true"></iframe>';
  233. let iframeDom = dom.children[0];
  234. iframe.write(iframeDom, ui);
  235. this.execFrameJs(jaeFetchUserJSFrame.window);
  236. this.bindEvent();
  237. }
  238. }
  239. }
  240.  
  241. }
  242.  
  243. let fu = new FetchUserjs();
  244. ljs.exec(['jQuery'], () => {
  245. /greasyfork\.org/.test(location.hostname) && sleazyfork_redirect ? sleazy() : false;
  246. fu.render();
  247. });
  248. })();