油猴助手

帮助坚持访问的网站是否有油猴插件

  1. // ==UserScript==
  2. // @name 油猴助手
  3. // @description 帮助坚持访问的网站是否有油猴插件
  4. // @author 018(lyb018@gmail.com)
  5. // @contributor Rhilip
  6. // @connect *
  7. // @grant GM_xmlhttpRequest
  8. // @grant GM_setClipboard
  9. // @grant GM_addStyle
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_listValues
  13. // @grant GM_deleteValue
  14. // @grant GM_registerMenuCommand
  15. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js
  16. // @include *
  17. // @version 0.1.2
  18. // @icon https://gf.qytechs.cn/packs/media/images/blacklogo16-5421a97c75656cecbe2befcec0778a96.png
  19. // @run-at document-end
  20. // @namespace http://018.ai
  21. // ==/UserScript==
  22.  
  23. // This Userscirpt can't run under Greasemonkey 4.x platform
  24. if (typeof GM_xmlhttpRequest === 'undefined') {
  25. alert('不支持Greasemonkey 4.x,请换用暴力猴或Tampermonkey')
  26. return
  27. }
  28.  
  29. ;(function () {
  30. 'use strict';
  31.  
  32. $(document).ready(function () {
  33. sniffer(location.host)
  34. })
  35.  
  36. function sniffer(host) {
  37. var url = 'https://gf.qytechs.cn/zh-CN/scripts/by-site/' + host + '?filter_locale=0'
  38. loadDoc(url, {url: url}, function(doc, responseDetail, meta) {
  39. var list = doc.querySelector('#browse-script-list');
  40. if (list) {
  41. $('body').after('<style type="text/css" nonce="A3C4C117-4422-47B2-A80D-795EAAB84A46">/*! normalize.css v3.0.1 | MIT License | git.io/normalize */\
  42. .greasyfork-alert {\
  43. cursor: pointer;\
  44. left: 0;\
  45. top: 0;\
  46. position: fixed !important;\
  47. z-index: 2147483647 !important;\
  48. width: 40px !important;\
  49. height: 40px !important;\
  50. zoom: 1 !important;\
  51. display: inline-block !important;\
  52. margin: 0 !important;\
  53. border: 0 !important;\
  54. padding: 0 !important;\
  55. will-change: transform;\
  56. opacity: 1;\
  57. touch-action: none;\
  58. -ms-touch-action: none;\
  59. min-height: auto !important;\
  60. max-height: auto !important;\
  61. min-width: auto !important;\
  62. max-width: auto !important;\
  63. background-size: 28px!important;\
  64. background-position: center center!important;\
  65. background-repeat: no-repeat !important;\
  66. background-color: #fff !important;\
  67. border: none !important;\
  68. box-shadow: 0 0 10px 3px rgba(162, 161, 161, 0.3) !important;\
  69. border-radius: 100% !important;\
  70. transition: background-color 0.3s ease;\
  71. }\
  72. .greasyfork-alert.sg_hide_element {\
  73. display: none!important;\
  74. }\
  75. .greasyfork-alert.logo-small {\
  76. width: 24px !important;\
  77. height: 24px !important;\
  78. background-position: 50% 6px!important;\
  79. background-size: 14px!important;\
  80. }\
  81. .greasyfork-alert:hover {\
  82. background-color: #ccf0d4 !important;\
  83. }\
  84. @media print {\
  85. .greasyfork-alert {\
  86. display: none!important;\
  87. }\
  88. }\
  89. .greasyfork-assistant-button-main-logo {\
  90. background-image: url(https://gf.qytechs.cn/vite/assets/blacklogo96-e0c2c761.png) !important;\
  91. }\
  92. .greasyfork-assistant-button-bottom {\
  93. top: auto;\
  94. bottom: 0;\
  95. }\
  96. .greasyfork-assistant-button-bottom.greasyfork-assistant-button-left {\
  97. left: 0;\
  98. right: auto;\
  99. transform: translate3d(10px, -10px, 0);\
  100. }\
  101. .greasyfork-assistant-button-bottom.greasyfork-assistant-button-right {\
  102. left: auto;\
  103. right: 0;\
  104. transform: translate3d(-10px, -10px, 0);\
  105. }\
  106. .greasyfork-assistant-button-right {\
  107. left: auto;\
  108. right: 0;\
  109. }\
  110. </style>\
  111. <a class="greasyfork-alert greasyfork-assistant-button-main-logo greasyfork-assistant-button-bottom greasyfork-assistant-button-right" href="' + meta.url +
  112. '" title="找到油猴插件" onclick="this.style.visibility = \'hidden\'" target="_blank"></a>');
  113. } else if(host.indexOf('.') > -1) {
  114. sniffer(host.replace(/^[a-zA-z0-9\-_]*\./, ''))
  115. }
  116. }, function(responseDetail, meta) {
  117. console.error(responseDetail)
  118. });
  119. }
  120.  
  121. // 对使用GM_xmlhttpRequest返回的html文本进行处理并返回DOM树
  122. function page_parser(responseText) {
  123. // 替换一些信息防止图片和页面脚本的加载,同时可能加快页面解析速度
  124. responseText = responseText.replace(/s+src=/ig, ' data-src='); // 图片,部分外源脚本
  125. responseText = responseText.replace(/<script[^>]*?>[\S\s]*?<\/script>/ig, ''); //页面脚本
  126. return (new DOMParser()).parseFromString(responseText, 'text/html');
  127. }
  128.  
  129. // 加载网页
  130. function loadDoc (url, meta, callback, fail) {
  131. GM_xmlhttpRequest({
  132. method: 'GET',
  133. url: url,
  134. onload: function (responseDetail) {
  135. if (responseDetail.status === 200) {
  136. let doc = page_parser(responseDetail.responseText)
  137. callback(doc, responseDetail, meta)
  138. } else if (fail){
  139. fail(responseDetail, meta);
  140. }
  141. },
  142. onerror: function(err) {
  143. if (fail) {
  144. fail(err, meta);
  145. }
  146. }
  147. })
  148. }
  149.  
  150. // get请求
  151. function doGet (url, meta, callback, fail) {
  152. GM_xmlhttpRequest({
  153. method: 'GET',
  154. url: url,
  155. onload: function (responseDetail) {
  156. if (responseDetail.status === 200) {
  157. callback(JSON.parse(responseDetail.responseText), responseDetail, meta)
  158. } else if (fail){
  159. fail(responseDetail, meta);
  160. }
  161. },
  162. onerror: function(err) {
  163. if (fail) {
  164. fail(err, meta);
  165. }
  166. }
  167. })
  168. }
  169.  
  170. // post请求
  171. function doPost (url, headers, data, meta, callback, fail) {
  172. GM_xmlhttpRequest({
  173. method: "POST",
  174. url: url,
  175. data: data,
  176. headers: headers,
  177. onload: function(responseDetail){
  178. if (responseDetail.status === 200) {
  179. callback(JSON.parse(responseDetail.responseText), responseDetail, meta)
  180. } else if (fail){
  181. fail(responseDetail, meta);
  182. }
  183. },
  184. onerror: function(err) {
  185. if (fail) {
  186. fail(err, meta);
  187. }
  188. }
  189. })
  190. }
  191. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址