您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
it can hook all ajax
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/426753/932839/Hook%20Ajax.js
// ==UserScript== // @name Hook Ajax // @namespace https://gitee.com/HGJing/everthing-hook/ // @version 0.1.0 // @description it can hook all ajax // @author Cangshi // @include * // @run-at document-start // @grant none // ==/UserScript== !function (t, e) { "object" == typeof exports && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define(["exports"], e) : e((t = "undefined" != typeof globalThis ? globalThis : t || self).$hookAjax = {}) }(this, (function (t) { "use strict"; function e(t, e) { (null == e || e > t.length) && (e = t.length); for (var n = 0, r = new Array(e); n < e; n++) r[n] = t[n]; return r } function n(t, n) { return function (t) { if (Array.isArray(t)) return t }(t) || function (t, e) { var n = t && ("undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"]); if (null != n) { var r, o, i = [], u = !0, c = !1; try { for (n = n.call(t); !(u = (r = n.next()).done) && (i.push(r.value), !e || i.length !== e); u = !0) ; } catch (t) { c = !0, o = t } finally { try { u || null == n.return || n.return() } finally { if (c) throw o } } return i } }(t, n) || function (t, n) { if (t) { if ("string" == typeof t) return e(t, n); var r = Object.prototype.toString.call(t).slice(8, -1); return "Object" === r && t.constructor && (r = t.constructor.name), "Map" === r || "Set" === r ? Array.from(t) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? e(t, n) : void 0 } }(t, n) || function () { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") }() } function r(t) { if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t } function o(t, e) { return (o = Object.setPrototypeOf || function (t, e) { return t.__proto__ = e, t })(t, e) } function i(t) { return (i = "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 })(t) } function u(t, e) { return !e || "object" !== i(e) && "function" != typeof e ? r(t) : e } function c(t) { return (c = Object.setPrototypeOf ? Object.getPrototypeOf : function (t) { return t.__proto__ || Object.getPrototypeOf(t) })(t) } function a(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") } function f(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(t, r.key, r) } } function s(t, e, n) { return e in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t } var l = function (t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") }; function p(t, e) { return t(e = {exports: {}}, e.exports), e.exports } var y = p((function (t) { function e(n, r) { return t.exports = e = Object.setPrototypeOf || function (t, e) { return t.__proto__ = e, t }, e(n, r) } t.exports = e })); var v = function (t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), e && y(t, e) }, h = p((function (t) { function e(n) { return "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? t.exports = e = function (t) { return typeof t } : t.exports = e = function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t }, e(n) } t.exports = e })); var b = function (t) { if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t }; var d = function (t, e) { return !e || "object" !== h(e) && "function" != typeof e ? b(t) : e }, g = p((function (t) { function e(n) { return t.exports = e = Object.setPrototypeOf ? Object.getPrototypeOf : function (t) { return t.__proto__ || Object.getPrototypeOf(t) }, e(n) } t.exports = e })); var m = function (t, e) { (null == e || e > t.length) && (e = t.length); for (var n = 0, r = new Array(e); n < e; n++) r[n] = t[n]; return r }; var O = function (t) { if (Array.isArray(t)) return m(t) }; var w = function (t) { if ("undefined" != typeof Symbol && Symbol.iterator in Object(t)) return Array.from(t) }; var j = function (t, e) { if (t) { if ("string" == typeof t) return m(t, e); var n = Object.prototype.toString.call(t).slice(8, -1); return "Object" === n && t.constructor && (n = t.constructor.name), "Map" === n || "Set" === n ? Array.from(t) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? m(t, e) : void 0 } }; var S = function () { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") }; var x = function (t) { return O(t) || w(t) || j(t) || S() }; function R(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(t, r.key, r) } } var k = function (t, e, n) { return e && R(t.prototype, e), n && R(t, n), t }; var A = function (t, e) { for (; !Object.prototype.hasOwnProperty.call(t, e) && null !== (t = g(t));) ; return t }, P = p((function (t) { function e(n, r, o) { return "undefined" != typeof Reflect && Reflect.get ? t.exports = e = Reflect.get : t.exports = e = function (t, e, n) { var r = A(t, e); if (r) { var o = Object.getOwnPropertyDescriptor(r, e); return o.get ? o.get.call(n) : o.value } }, e(n, r, o || n) } t.exports = e })); var H = function (t) { return -1 !== Function.toString.call(t).indexOf("[native code]") }; var E = function () { if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], (function () { }))), !0 } catch (t) { return !1 } }, _ = p((function (t) { function e(n, r, o) { return E() ? t.exports = e = Reflect.construct : t.exports = e = function (t, e, n) { var r = [null]; r.push.apply(r, e); var o = new (Function.bind.apply(t, r)); return n && y(o, n.prototype), o }, e.apply(null, arguments) } t.exports = e })), T = p((function (t) { function e(n) { var r = "function" == typeof Map ? new Map : void 0; return t.exports = e = function (t) { if (null === t || !H(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, e) } function e() { return _(t, arguments, g(this).constructor) } return e.prototype = Object.create(t.prototype, { constructor: { value: e, enumerable: !1, writable: !0, configurable: !0 } }), y(e, t) }, e(n) } t.exports = e })); function I(t, e) { var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "initAssign", r = Object.getPrototypeOf(e); return Object.setPrototypeOf(t, r), "function" == typeof r[n] && r[n].call(t, e), t } function D(t) { return Number(Math.random().toString().substr(3, t) + Date.now()).toString(36) } function q(t) { var e = function () { if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Date.prototype.toString.call(Reflect.construct(Date, [], (function () { }))), !0 } catch (t) { return !1 } }(); return function () { var n, r = g(t); if (e) { var o = g(this).constructor; n = Reflect.construct(r, arguments, o) } else n = r.apply(this, arguments); return d(this, n) } } !function (t, e) { t(e = {exports: {}}, e.exports) }((function (t) { function e(n) { return "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? t.exports = e = function (t) { return typeof t } : t.exports = e = function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t }, e(n) } t.exports = e })); var M = { instanceType: function (t) { v(n, t); var e = q(n); function n() { return l(this, n), e.apply(this, arguments) } return k(n, [{ key: "initAssign", value: function (t) { this.id = D(7), function (t, e, n, r) { e && void 0 !== e[n] ? t[n] = e[n] : "function" == typeof r && (t[n] = r()) }(this, t, "uniqueId", (function () { return D(7) })) } }, { key: "bind", value: function (t) { var e, r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : []; return I((e = P(g(n.prototype), "bind", this)).call.apply(e, [this, t].concat(x(r))), this) } }, { key: "before", value: function (t) { var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; return this.surround({before: t, adaptAsync: e}) } }, { key: "after", value: function (t) { var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; return this.surround({after: t, adaptAsync: e}) } }, { key: "surround", value: function (t) { var e = t.before, n = void 0 === e ? void 0 : e, r = t.after, o = void 0 === r ? void 0 : r, i = t.onError, u = void 0 === i ? void 0 : i, c = t.adaptAsync, a = void 0 !== c && c, f = this; return "function" != typeof f ? f : I((function () { for (var t = this, e = arguments.length, r = new Array(e), i = 0; i < e; i++) r[i] = arguments[i]; var c = {}, s = {origin: f, args: r, trans: c}, l = "function" == typeof u; try { var p, y, v = !1; return "function" == typeof n && (p = n.call(this, Object.assign({}, s, { preventDefault: function () { v = !0 } })), v) ? p : (y = p instanceof Promise && a ? p.then((function () { return f.apply(t, r) })) : f.apply(this, r), "function" == typeof o && (y = y instanceof Promise && a ? y.then((function (e) { return o.call(t, Object.assign({}, s, {lastValue: e})) })) : o.call(this, Object.assign({}, s, {lastValue: y}))), y instanceof Promise && a && l ? y.catch((function (e) { var n = !1, r = ""; return Promise.resolve(u.call(t, Object.assign({}, s, { error: e, resolve: function (t) { r = t, n = !0 } }))).then((function (t) { if (!n) throw e; return r || t })) })) : y) } catch (t) { if (!l) throw t; var h = !1, b = "", d = function (t) { b = t, h = !0 }, g = u.call(this, Object.assign({}, s, {error: t, resolve: d})); if (!h) throw t; return b || g } }), this) } }, { key: "then", value: function (t) { var e = this; return I((function () { for (var n = arguments.length, r = new Array(n), o = 0; o < n; o++) r[o] = arguments[o]; var i = e.apply(this, r); return Promise.resolve(i).then(t) }), this) } }, { key: "catch", value: function (t) { var e = this; return I((function () { var n; try { for (var r = arguments.length, o = new Array(r), i = 0; i < r; i++) o[i] = arguments[i]; if ((n = e.apply(this, o)) instanceof Promise) return n.catch(t) } catch (e) { n = t.call(this, e) } return n }), this) } }, { key: "finally", value: function (t) { var e = this; return I((function () { var n = function () { try { t.call(this) } catch (t) { } }; try { for (var r = arguments.length, o = new Array(r), i = 0; i < r; i++) o[i] = arguments[i]; var u = e.apply(this, o); return u instanceof Promise ? "function" == typeof u.finally ? u.finally((function () { return n() })) : u.catch((function (t) { return t })).then((function (t) { if (n(), t instanceof Error) throw t })) : (n(), u) } catch (t) { throw n(), t } }), this) } }, { key: "register", value: function () { var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; return this.registerClass((function (e) { var n = function (t) { v(n, t); var e = q(n); function n() { return l(this, n), e.apply(this, arguments) } return n }(e); return Object.assign(n.prototype, t), n })) } }, { key: "registerClass", value: function (t) { var e = t(this.constructor), n = this.bind(this); if (Object.setPrototypeOf(n, e.prototype), "function" != typeof e || !(n instanceof this.constructor)) throw new Error("Registered class must extend FunctionInstance"); return n } }]), n }(T(Function)) }; function C(t, e) { var n = function () { for (var e = arguments.length, n = new Array(e), r = 0; r < e; r++) n[r] = arguments[r]; return (t || function () { }).apply(this, n) }; return function (t, e) { var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "initAssign", r = e.prototype; Object.setPrototypeOf(t, r), "function" == typeof r[n] && r[n].call(t) }(n, (e = Object.assign({}, M, e)).instanceType), n } var N = {protect: !1, syncDesc: !0, native: !1}, L = Object.defineProperty, F = Object.defineProperties; function $(t, e, n) { var r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {}, o = t[e]; if ("function" == typeof o) { var i = Object.assign({}, N, r), u = i.native, c = n(u ? o : C(o)); t[e] = u ? c : function () { for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) e[n] = arguments[n]; try { return c.apply(this, e) } catch (t) { return console.warn("[Hook JS]", "Hooks running lost once."), o.apply(this, e) } }; var a = i.protect, f = i.syncDesc; a && J(t, e), f && U(o, t[e]) } } function J(t, e) { L.call(Object, t, e, {writable: !1}) } function U(t, e) { F.call(Object, e, { toString: { enumerable: !1, writable: !0, value: function () { return t.toString() } }, toLocaleString: { enumerable: !1, writable: !0, value: function () { return t.toLocaleString() } } }) } function B(t, e) { var n = "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"]; if (!n) { if (Array.isArray(t) || (n = function (t, e) { if (!t) return; if ("string" == typeof t) return V(t, e); var n = Object.prototype.toString.call(t).slice(8, -1); "Object" === n && t.constructor && (n = t.constructor.name); if ("Map" === n || "Set" === n) return Array.from(t); if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return V(t, e) }(t)) || e && t && "number" == typeof t.length) { n && (t = n); var r = 0, o = function () { }; return { s: o, n: function () { return r >= t.length ? {done: !0} : {done: !1, value: t[r++]} }, e: function (t) { throw t }, f: o } } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") } var i, u = !0, c = !1; return { s: function () { n = n.call(t) }, n: function () { var t = n.next(); return u = t.done, t }, e: function (t) { c = !0, i = t }, f: function () { try { u || null == n.return || n.return() } finally { if (c) throw i } } } } function V(t, e) { (null == e || e > t.length) && (e = t.length); for (var n = 0, r = new Array(e); n < e; n++) r[n] = t[n]; return r } function X(t) { var e = function () { if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function () { }))), !0 } catch (t) { return !1 } }(); return function () { var n, r = c(t); if (e) { var o = c(this).constructor; n = Reflect.construct(r, arguments, o) } else n = r.apply(this, arguments); return u(this, n) } } var z, G = 0; function K() { return G++ } !function (t) { t.SEND = "send", t.OPEN = "open" }(z || (z = {})); var Q = function () { function t() { var e = this; a(this, t), s(this, "urlHooks", {}), s(this, "responseHooks", {}); var n = this; !function (t, e, n) { var r = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {}; $(t, e, n, Object.assign({}, r, {native: !0})) }(window, "XMLHttpRequest", (function (t) { return function (t) { !function (t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), e && o(t, e) }(i, t); var e = X(i); function i() { var t; a(this, i); for (var o = arguments.length, u = new Array(o), c = 0; c < o; c++) u[c] = arguments[c]; return s(r(t = e.call.apply(e, [this].concat(u))), "id", void 0), t.id = K(), t.addEventListener("readystatechange", (function () { (4 == t.readyState || [200, 304, 201, 202, 203].includes(t.state)) && n.onResponse(r(t)) })), t } return i }(t) })), Object.values(z).forEach((function (t) { $(window.XMLHttpRequest.prototype, t, e.getHookedRequestHandler(t)) })) } var e, i, u; return e = t, (i = [{ key: "getHookedRequestHandler", value: function (t) { var e = this; return function (n) { return n.before((function (n) { var r = n.args, o = n.preventDefault; return e.onRequest(this, t, r, o) })) } } }, { key: "onRequest", value: function (t, e, r, o) { var i, u = n(r, 2)[1]; for (var c in this.urlHooks) if (new RegExp(u).test(u)) { var a = {args: r, type: e, prevent: o}, f = this.urlHooks[c]; "function" == typeof f.onRequest && (i = f.onRequest.call(t, a) || i), e === z.OPEN && this.signResponseHooks(t.id, f) } return i } }, { key: "onResponse", value: function (t) { if (4 === t.readyState || [200, 201, 202, 304].includes(t.status)) { var e, n = ["", "text"].includes(t.responseType) ? t.responseText : t.response; try { e = JSON.parse(n) } catch (t) { e = n } var r, o = { response: e, originResponse: n, replace: function (t) { o.response = t }, define: function (e, n) { Object.defineProperty(t, e, {writable: !1, configurable: !0, value: n}) } }, i = t.id, u = B(this.responseHooks[i] || []); try { for (u.s(); !(r = u.n()).done;) { var c = r.value; c && "function" == typeof c && (c.call(t, o), "string" != typeof (a = o.response) && (a = JSON.stringify(a)), Object.defineProperties(t, { response: { writable: !1, configurable: !0, value: a }, responseText: {writable: !1, configurable: !0, value: a} })) } } catch (t) { u.e(t) } finally { u.f() } this.clearResponseHooks(i) } var a } }, { key: "signResponseHooks", value: function (t, e) { if (e.onResponse && "function" == typeof e.onResponse) { var n = this.responseHooks[t] || []; n.push(e.onResponse), this.responseHooks[t] = n } } }, { key: "clearResponseHooks", value: function (t) { this.responseHooks[t] = [] } }, { key: "register", value: function (t, e) { this.urlHooks[t] = e } }]) && f(e.prototype, i), u && f(e, u), t }(); t.AjaxInterceptor = Q, Object.defineProperty(t, "__esModule", {value: !0}) }));
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址