NGA Agent

非常时期的非常手段

目前为 2022-10-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name NGA Agent
  3. // @namespace https://gf.qytechs.cn/users/263018
  4. // @version 1.3.6
  5. // @author snyssss
  6. // @description 非常时期的非常手段
  7. // @license MIT
  8.  
  9. // @match *://bbs.nga.cn/*
  10. // @match *://ngabbs.com/*
  11. // @match *://nga.178.com/*
  12.  
  13. // @grant GM_registerMenuCommand
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @grant unsafeWindow
  17. // @noframes
  18. // ==/UserScript==
  19.  
  20. (({ commonui: ui, __CURRENT_UID: uid }) => {
  21. !function(t,r){for(var n in r)t[n]=r[n]}(window,function(t){function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n={};return r.m=t,r.c=n,r.i=function(t){return t},r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=2)}([function(t,r,n){"use strict";function e(t,r){var n={};for(var e in t)n[e]=t[e];return n.target=n.currentTarget=r,n}function o(t,r){function n(r){return function(){var n=this.hasOwnProperty(r+"_")?this[r+"_"]:this.xhr[r],e=(t[r]||{}).getter;return e&&e(n,this)||n}}function o(r){return function(n){var o=this.xhr,i=this,u=t[r];if("on"===r.substring(0,2))i[r+"_"]=n,o[r]=function(u){u=e(u,i),t[r]&&t[r].call(i,o,u)||n.call(i,u)};else{var c=(u||{}).setter;n=c&&c(n,i)||n,this[r+"_"]=n;try{o[r]=n}catch(t){}}}}function i(r){return function(){var n=[].slice.call(arguments);if(t[r]){var e=t[r].call(this,n,this.xhr);if(e)return e}return this.xhr[r].apply(this.xhr,n)}}return r=r||window,r[c]=r[c]||r.XMLHttpRequest,r.XMLHttpRequest=function(){for(var t=new r[c],e=0;e<a.length;++e){var f="on"+a[e];void 0===t[f]&&(t[f]=null)}for(var s in t){var l="";try{l=u(t[s])}catch(t){}"function"===l?this[s]=i(s):Object.defineProperty(this,s,{get:n(s),set:o(s),enumerable:!0})}var h=this;t.getProxy=function(){return h},this.xhr=t},Object.assign(r.XMLHttpRequest,{UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4}),r[c]}function i(t){t=t||window,t[c]&&(t.XMLHttpRequest=t[c]),t[c]=void 0}Object.defineProperty(r,"__esModule",{value:!0});var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};r.configEvent=e,r.hook=o,r.unHook=i;var c="__xhr",a=r.events=["load","loadend","timeout","error","readystatechange","abort"]},,function(t,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ah=void 0;var e=n(0);r.ah={hook:e.hook,unHook:e.unHook}}]));
  22. //# sourceMappingURL=ajaxhook.core.min.js.map
  23.  
  24. // KEY
  25. const USER_AGENT_KEY = "USER_AGENT_KEY";
  26. const AUTO_CHECK_IN_ENABLE_KEY = "AUTO_CHECK_IN_ENABLE_KEY";
  27. const AUTO_CHECK_IN_LAST_TIME_KEY = "AUTO_CHECK_IN_LAST_TIME_KEY";
  28.  
  29. // User Agent
  30. const USER_AGENT = (() => {
  31. const data = GM_getValue(USER_AGENT_KEY) || "Nga_Official";
  32.  
  33. GM_registerMenuCommand(`修改UA${data}`, () => {
  34. const value = prompt("修改UA", data);
  35.  
  36. if (value) {
  37. GM_setValue(USER_AGENT_KEY, value);
  38.  
  39. location.reload();
  40. }
  41. });
  42.  
  43. return data;
  44. })();
  45.  
  46. // RedirectUri
  47. const redirectUri = (() => {
  48. const params = new URLSearchParams(location.search);
  49.  
  50. return params.get("redirectUri");
  51. })();
  52.  
  53. // Skip
  54. if (!document.title || location.href.indexOf('/misc/') > 0) {
  55. return;
  56. }
  57.  
  58. // Hook
  59. const hooked = (() => {
  60. const isSameOrigin = (url) => {
  61. return url.indexOf("/") === 0 || url.indexOf(location.host) >= 0;
  62. }
  63.  
  64. if (ui && ui.hooked) {
  65. return true;
  66. }
  67.  
  68. if (location.pathname === "/") {
  69. ah.hook(
  70. {
  71. open: (args, xhr) => {
  72. xhr._url = args[1];
  73.  
  74. return false;
  75. },
  76. send: (_, xhr) => {
  77. const url = xhr._url || "";
  78.  
  79. if (isSameOrigin(url)) {
  80. xhr.setRequestHeader("X-User-Agent", USER_AGENT);
  81. }
  82.  
  83. return false;
  84. },
  85. },
  86. ui._w
  87. );
  88.  
  89. const f = __NUKE.doRequest;
  90.  
  91. __NUKE.doRequest = (args) => {
  92. const u = args.u.u || args.u;
  93. const a = args.u.a;
  94.  
  95. if (isSameOrigin(u) && !a) {
  96. return f({
  97. ...args,
  98. xr: 1,
  99. u: {
  100. u,
  101. a,
  102. },
  103. });
  104. }
  105.  
  106. return f(args);
  107. };
  108.  
  109.  
  110. ui.hooked = true;
  111.  
  112. return true;
  113. }
  114.  
  115. return false;
  116. })();
  117.  
  118. // Redirect
  119. if (!hooked && redirectUri === null) {
  120. location.href = `/?redirectUri=${encodeURIComponent(location.href)}`;
  121. return;
  122. }
  123.  
  124. // Clear body event
  125. (() => {
  126. const temp = document.createElement("DIV");
  127.  
  128. temp.append(...document.body.childNodes);
  129.  
  130. document.body.outerHTML = document.body.outerHTML;
  131. document.body.innerHTML = "";
  132. document.body.append(...temp.childNodes);
  133. })();
  134.  
  135. // Reload lib
  136. (() => {
  137. const c = ui.topicArg;
  138.  
  139. __SCRIPTS.syncLoad("forum", "loaderRead", () => {
  140. if (_LOADERREAD) {
  141. _LOADERREAD.init();
  142.  
  143. // Reload page
  144. if (redirectUri) {
  145. ui.htmlLoader.go(33, {
  146. url: encodeURI(decodeURIComponent(redirectUri)),
  147. });
  148. }
  149.  
  150. ui.topicArg = c;
  151. }
  152. });
  153. })();
  154.  
  155. // Auto check in
  156. (() => {
  157. const autoCheckInEnable = GM_getValue(AUTO_CHECK_IN_ENABLE_KEY) || false;
  158. const autoCheckInLastTime = GM_getValue(AUTO_CHECK_IN_LAST_TIME_KEY) || 0;
  159.  
  160. if (autoCheckInEnable) {
  161. GM_registerMenuCommand("自动签到:启用", () => {
  162. GM_setValue(AUTO_CHECK_IN_ENABLE_KEY, false);
  163. GM_setValue(AUTO_CHECK_IN_LAST_TIME_KEY, 0);
  164. location.reload();
  165. });
  166. } else {
  167. GM_registerMenuCommand("自动签到:禁用", () => {
  168. GM_setValue(AUTO_CHECK_IN_ENABLE_KEY, true);
  169. location.reload();
  170. });
  171. }
  172.  
  173. if (autoCheckInEnable && uid) {
  174. const today = new Date();
  175.  
  176. const lastTime = new Date(autoCheckInLastTime);
  177.  
  178. const isToday =
  179. lastTime.getDate() === today.getDate() &&
  180. lastTime.getMonth() === today.getMonth() &&
  181. lastTime.getFullYear() === today.getFullYear();
  182.  
  183. if (isToday === false) {
  184. fetch(`/nuke.php?__lib=check_in&__act=check_in&lite=js`, {
  185. method: "POST",
  186. headers: {
  187. "X-User-Agent": USER_AGENT,
  188. },
  189. })
  190. .then((res) => res.blob())
  191. .then((blob) => {
  192. const reader = new FileReader();
  193.  
  194. reader.onload = () => {
  195. const text = reader.result;
  196. const result = JSON.parse(
  197. text.replace("window.script_muti_get_var_store=", "")
  198. );
  199.  
  200. const { data, error } = result;
  201.  
  202. if (data || error) {
  203. alert((data || error)[0]);
  204. }
  205.  
  206. GM_setValue(AUTO_CHECK_IN_LAST_TIME_KEY, today.getTime());
  207. };
  208.  
  209. reader.readAsText(blob, "GBK");
  210. });
  211. }
  212. }
  213. })();
  214. })(unsafeWindow);

QingJ © 2025

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