diff --git a/src/entry/background.js b/src/entry/background.js index 34a7167..6f2c01d 100644 --- a/src/entry/background.js +++ b/src/entry/background.js @@ -1,51 +1,55 @@ - /** - 利用chrome的fetch来避免跨域 -**/ + 利用chrome的fetch来避免跨域 + **/ +import {genAnti} from "@/entry/genAnti"; + chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (request.type == 'api') { new Promise((resolve, reject) => { let headers = {}; - + if (request.needMallId) { headers.Mallid = request.mallId; } headers['Content-Type'] = 'application/json'; - headers.cookie = getCookie(); - - fetch(request.url, { + // Promise.resolve(genAnti()).then(r => { + // headers["Anti-Content"] = r + // }) + Promise.resolve().then(() => fetch(request.url, { 'headers': headers, 'method': 'POST', 'referrerPolicy': 'no-referrer', 'credentials': 'include', 'body': JSON.stringify(request.data), 'mode': 'cors' - }).then((res) => { + })).then((res) => { resolve(res.json()); }); }).then((res) => { sendResponse(res); }); + } else if (request.type == 'init') { + fetch(request.url,{headers:{cookie: getCookie()}}).then(res => sendResponse(res.text())); } else if (request.type == 'notify') { chrome.notifications.create( - "" + Math.random(), { - type: "basic", - title: "TEMU助手", - message: "您店铺【" + request.mallName + "】的商品【" + request.productName + "】成功加入发货台,请尽快处理", - iconUrl: "./icons/48.png" - }, null + "" + Math.random(), { + type: "basic", + title: "TEMU助手", + message: "您店铺【" + request.mallName + "】的商品【" + request.productName + "】成功加入发货台,请尽快处理", + iconUrl: "./icons/48.png" + }, null ) } - + return true; }); chrome.action.onClicked.addListener(function () { chrome.tabs.create({ - url: "./popup.html" + url: "./popup.html" }, function (tab) { - console.log('tab is:' + tab); + console.log('tab is:' + tab); }); }); @@ -58,4 +62,4 @@ function getCookie() { }); }); return cStr; -} \ No newline at end of file +} diff --git a/src/entry/genAnti.js b/src/entry/genAnti.js new file mode 100644 index 0000000..b27ddad --- /dev/null +++ b/src/entry/genAnti.js @@ -0,0 +1,419 @@ +const genAnti = function () { + const x = { + touchEventData: !0, + clickEventData: !0, + focusblurEventData: !0, + changeEventData: !0, + locationInfo: !0, + referrer: !0, + browserSize: !0, + browserInfo: !0, + token: !0, + fingerprint: !0 + }, w = {_2827c887a48a351a: !1, serverTime: NaN} + + function l(t, e, r, n, o, i, a) { + try { + var s = t[i](a), u = s.value + } catch (l) { + return void r(l) + } + s.done ? e(u) : Promise.resolve(u).then(n, o) + } + + function c(t) { + return function () { + var e = this, r = arguments; + return new Promise((function (n, o) { + var i = t.apply(e, r); + + function a(t) { + l(i, n, o, a, s, "next", t) + } + + function s(t) { + l(i, n, o, a, s, "throw", t) + } + + a(void 0) + })) + } + } + + function u() { + u = function () { + return t + }; + var t = {}, e = Object.prototype, r = e.hasOwnProperty, n = "function" == typeof Symbol ? Symbol : {}, + o = n.iterator || "@@iterator", i = n.asyncIterator || "@@asyncIterator", + a = n.toStringTag || "@@toStringTag"; + + function s(t, e, r) { + return Object.defineProperty(t, e, {value: r, enumerable: !0, configurable: !0, writable: !0}), t[e] + } + + try { + s({}, "") + } catch (E) { + s = function (t, e, r) { + return t[e] = r + } + } + + function l(t, e, r, n) { + var o = e && e.prototype instanceof d ? e : d, i = Object.create(o.prototype), a = new O(n || []); + return i._invoke = function (t, e, r) { + var n = "suspendedStart"; + return function (o, i) { + if ("executing" === n) throw new Error("Generator is already running"); + if ("completed" === n) { + if ("throw" === o) throw i; + return k() + } + for (r.method = o, r.arg = i; ;) { + var a = r.delegate; + if (a) { + var s = x(a, r); + if (s) { + if (s === f) continue; + return s + } + } + if ("next" === r.method) r.sent = r._sent = r.arg; else if ("throw" === r.method) { + if ("suspendedStart" === n) throw n = "completed", r.arg; + r.dispatchException(r.arg) + } else "return" === r.method && r.abrupt("return", r.arg); + n = "executing"; + var u = c(t, e, r); + if ("normal" === u.type) { + if (n = r.done ? "completed" : "suspendedYield", u.arg === f) continue; + return {value: u.arg, done: r.done} + } + "throw" === u.type && (n = "completed", r.method = "throw", r.arg = u.arg) + } + } + }(t, r, a), i + } + + function c(t, e, r) { + try { + return {type: "normal", arg: t.call(e, r)} + } catch (E) { + return {type: "throw", arg: E} + } + } + + t.wrap = l; + var f = {}; + + function d() { + } + + function p() { + } + + function h() { + } + + var v = {}; + s(v, o, (function () { + return this + })); + var g = Object.getPrototypeOf, m = g && g(g(C([]))); + m && m !== e && r.call(m, o) && (v = m); + var b = h.prototype = d.prototype = Object.create(v); + + function y(t) { + ["next", "throw", "return"].forEach((function (e) { + s(t, e, (function (t) { + return this._invoke(e, t) + })) + })) + } + + function w(t, e) { + function n(o, i, a, s) { + var u = c(t[o], t, i); + if ("throw" !== u.type) { + var l = u.arg, f = l.value; + return f && "object" == typeof f && r.call(f, "__await") ? e.resolve(f.__await).then((function (t) { + n("next", t, a, s) + }), (function (t) { + n("throw", t, a, s) + })) : e.resolve(f).then((function (t) { + l.value = t, a(l) + }), (function (t) { + return n("throw", t, a, s) + })) + } + s(u.arg) + } + + var o; + this._invoke = function (t, r) { + function i() { + return new e((function (e, o) { + n(t, r, e, o) + })) + } + + return o = o ? o.then(i, i) : i() + } + } + + function x(t, e) { + var r = t.iterator[e.method]; + if (void 0 === r) { + if (e.delegate = null, "throw" === e.method) { + if (t.iterator.return && (e.method = "return", e.arg = void 0, x(t, e), "throw" === e.method)) return f; + e.method = "throw", e.arg = new TypeError("The iterator does not provide a 'throw' method") + } + return f + } + var n = c(r, t.iterator, e.arg); + if ("throw" === n.type) return e.method = "throw", e.arg = n.arg, e.delegate = null, f; + var o = n.arg; + return o ? o.done ? (e[t.resultName] = o.value, e.next = t.nextLoc, "return" !== e.method && (e.method = "next", e.arg = void 0), e.delegate = null, f) : o : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f) + } + + function _(t) { + var e = {tryLoc: t[0]}; + 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e) + } + + function S(t) { + var e = t.completion || {}; + e.type = "normal", delete e.arg, t.completion = e + } + + function O(t) { + this.tryEntries = [{tryLoc: "root"}], t.forEach(_, this), this.reset(!0) + } + + function C(t) { + if (t) { + var e = t[o]; + if (e) return e.call(t); + if ("function" == typeof t.next) return t; + if (!isNaN(t.length)) { + var n = -1, i = function e() { + for (; ++n < t.length;) if (r.call(t, n)) return e.value = t[n], e.done = !1, e; + return e.value = void 0, e.done = !0, e + }; + return i.next = i + } + } + return {next: k} + } + + function k() { + return {value: void 0, done: !0} + } + + return p.prototype = h, s(b, "constructor", h), s(h, "constructor", p), p.displayName = s(h, a, "GeneratorFunction"), t.isGeneratorFunction = function (t) { + var e = "function" == typeof t && t.constructor; + return !!e && (e === p || "GeneratorFunction" === (e.displayName || e.name)) + }, t.mark = function (t) { + return Object.setPrototypeOf ? Object.setPrototypeOf(t, h) : (t.__proto__ = h, s(t, a, "GeneratorFunction")), t.prototype = Object.create(b), t + }, t.awrap = function (t) { + return {__await: t} + }, y(w.prototype), s(w.prototype, i, (function () { + return this + })), t.AsyncIterator = w, t.async = function (e, r, n, o, i) { + void 0 === i && (i = Promise); + var a = new w(l(e, r, n, o), i); + return t.isGeneratorFunction(r) ? a : a.next().then((function (t) { + return t.done ? t.value : a.next() + })) + }, y(b), s(b, a, "Generator"), s(b, o, (function () { + return this + })), s(b, "toString", (function () { + return "[object Generator]" + })), t.keys = function (t) { + var e = []; + for (var r in t) e.push(r); + return e.reverse(), function r() { + for (; e.length;) { + var n = e.pop(); + if (n in t) return r.value = n, r.done = !1, r + } + return r.done = !0, r + } + }, t.values = C, O.prototype = { + constructor: O, reset: function (t) { + if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = !1, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(S), !t) for (var e in this) "t" === e.charAt(0) && r.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = void 0) + }, stop: function () { + this.done = !0; + var t = this.tryEntries[0].completion; + if ("throw" === t.type) throw t.arg; + return this.rval + }, dispatchException: function (t) { + if (this.done) throw t; + var e = this; + + function n(r, n) { + return a.type = "throw", a.arg = t, e.next = r, n && (e.method = "next", e.arg = void 0), !!n + } + + for (var o = this.tryEntries.length - 1; o >= 0; --o) { + var i = this.tryEntries[o], a = i.completion; + if ("root" === i.tryLoc) return n("end"); + if (i.tryLoc <= this.prev) { + var s = r.call(i, "catchLoc"), u = r.call(i, "finallyLoc"); + if (s && u) { + if (this.prev < i.catchLoc) return n(i.catchLoc, !0); + if (this.prev < i.finallyLoc) return n(i.finallyLoc) + } else if (s) { + if (this.prev < i.catchLoc) return n(i.catchLoc, !0) + } else { + if (!u) throw new Error("try statement without catch or finally"); + if (this.prev < i.finallyLoc) return n(i.finallyLoc) + } + } + } + }, abrupt: function (t, e) { + for (var n = this.tryEntries.length - 1; n >= 0; --n) { + var o = this.tryEntries[n]; + if (o.tryLoc <= this.prev && r.call(o, "finallyLoc") && this.prev < o.finallyLoc) { + var i = o; + break + } + } + i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); + var a = i ? i.completion : {}; + return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, f) : this.complete(a) + }, complete: function (t, e) { + if ("throw" === t.type) throw t.arg; + return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), f + }, finish: function (t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), S(r), f + } + }, catch: function (t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.tryLoc === t) { + var n = r.completion; + if ("throw" === n.type) { + var o = n.arg; + S(r) + } + return o + } + } + throw new Error("illegal catch attempt") + }, delegateYield: function (t, e, r) { + return this.delegate = { + iterator: C(t), + resultName: e, + nextLoc: r + }, "next" === this.method && (this.arg = void 0), f + } + }, t + } + + function f() { + return f = Object.assign ? Object.assign.bind() : function (t) { + for (var e = 1; e < arguments.length; e++) { + var r = arguments[e]; + for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]) + } + return t + }, f.apply(this, arguments) + } + + const b = function () { + var t = function () { + return (new Date).getTime() + }(); + if (t) return new Promise((function (e) { + console.log(e.toString()) + return e(t) + })); + return new Promise((function (t) { + var e = function () { + return new Promise((function (t) { + var e = function (e) { + p("riskUtilGetServerTimeFallback", e), t((new Date).getTime()) + }, r = new XMLHttpRequest; + r.open("HEAD", window.location.href, !0), r.setRequestHeader("Content-type", "application/json; charset=utf-8"), r.withCredentials = !0, r.onreadystatechange = function () { + if (4 === r.readyState) { + var n = r.getResponseHeader("Date"); + if (n) { + var o = new Date(n).getTime(); + o || e("date invalid " + JSON.stringify(n)); + var i = (new Date).getTime(); + window.bgbRisk.timeBaseline = { + serverTime: o, + localTime: i + }, t(o), g(o, i) && p("getServerTimeFallback timeDiffOverOneHour", JSON.stringify({ + serverTime: o, + localTime: i + })) + } else e("date not exsit, " + r.statusText) + } + }, r.send(null) + })).then(t).catch((function (e) { + p("riskUtilGetServerTimeFallback", "catch " + (null == e ? void 0 : e.stack)), t((new Date).getTime()) + })) + }, r = new XMLHttpRequest; + r.open("GET", "/api/server/_stm", !0), r.setRequestHeader("Content-type", "application/json; charset=utf-8"), r.withCredentials = !0, r.onreadystatechange = function () { + if (4 === r.readyState) { + try { + var n = JSON.parse(r.responseText).server_time; + if (n && "number" === typeof n) { + var o = (new Date).getTime(); + return window.bgbRisk.timeBaseline = { + serverTime: n, + localTime: o + }, t(n), void (g(n, o) && p("getServerTime timeDiffOverOneHour", JSON.stringify({ + serverTime: n, + localTime: o + }))) + } + } catch (i) { + console.error(i) + } + e() + } + }, r.send() + })) + } + const r377 = function (e, t) { + return {enumerable: !(1 && e), configurable: !(2 && e), writable: !(4 && e), value: t} + } + const S = function () { + var t = c(u().mark((function t() { + var e, r; + return u().wrap((function (t) { + for (; ;) { + console.log(t.next) + switch (t.prev = t.next) { + case 0: + return t.next = 2, b(); + case 2: + let y; + return e = t.sent, t.next = 3, y = new r377(e, t).a(f({}, w, {serverTime: e})), console.log(y), y; + case 3: + return e = t.sent, r = e.messagePack(x), e.clearCache(), t.abrupt("return", r); + case 9: + t.prev = 9 + return t.abrupt("return", ""); + case 13: + case"end": + return t.stop() + } + } + }), t, null, [[0, 9]]) + }))); + return function () { + return t.apply(this, arguments) + } + }() + return S() +} + +Promise.resolve(genAnti()).then(r => { + // console.log(r.toString()) +}) diff --git a/src/entry/popup.js b/src/entry/popup.js index f2b2cd9..d0a35d5 100644 --- a/src/entry/popup.js +++ b/src/entry/popup.js @@ -16,7 +16,7 @@ var relativeTime = require('dayjs/plugin/relativeTime') require('dayjs/locale/zh-cn') dayjs.extend(relativeTime) Vue.prototype.$dayjs = dayjs - +Vue.prototype.$base = "https://kuajing.pinduoduo.com" Object.keys(utils).forEach(v => Vue.prototype[`$${v}`] = utils[v]) Vue.prototype.$http = instance diff --git a/src/view/popup.vue b/src/view/popup.vue index 1d52ec7..9e0018f 100644 --- a/src/view/popup.vue +++ b/src/view/popup.vue @@ -5,52 +5,57 @@