From 45f727ed7eddb54918f8c0e0b21f3ae9e2e66ba0 Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 23 Apr 2024 15:10:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=BC=82=E5=B8=B8,=E5=B9=B6?= =?UTF-8?q?=E7=BB=99=E5=87=BA=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/aliExpress.js | 5 +++-- src/api/chromeApi.js | 2 ++ src/entry/background.js | 5 ++--- src/view/selection/AliExpressCopy.vue | 16 +++++++++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/api/aliExpress.js b/src/api/aliExpress.js index 58446d5..a8b0cb7 100644 --- a/src/api/aliExpress.js +++ b/src/api/aliExpress.js @@ -6,8 +6,8 @@ * @returns {*} */ -const getSign = (token, appKey, formData) => { - token = token.split("_")[0] +export const getSign = (token, appKey, formData) => { + token = token?.split("_")[0] const t = (new Date()).getTime(); return { t, sign: function (e) { @@ -158,3 +158,4 @@ const getSign = (token, appKey, formData) => { }(token + "&" + t + "&" + appKey + "&" + formData) } } + diff --git a/src/api/chromeApi.js b/src/api/chromeApi.js index 6c01f49..26202ac 100644 --- a/src/api/chromeApi.js +++ b/src/api/chromeApi.js @@ -86,6 +86,8 @@ export function sendChromeNotification(message) { */ export function sendAliexpressAPIMessage(message) { message.type = 'aliexpress' + const {mtopConfig = {appKey: "12574478"}} = window + message.appKey = message.appKey || mtopConfig.appKey return new Promise((resolve) => { chrome.runtime.sendMessage(message, resolve) }) diff --git a/src/entry/background.js b/src/entry/background.js index e09ef6d..e32a4b1 100644 --- a/src/entry/background.js +++ b/src/entry/background.js @@ -131,8 +131,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { headers['Content-Type'] = 'text/html'; headers.cookie = getAliexpressCookie(); const {_m_h5_c, _m_h5_tk} = cookie2Obj(headers.cookie) - const {mtopConfig = {appKey: "12574478"}} = window - const {appKey = mtopConfig.appKey, formData} = request + const {appKey, formData} = request const {sign, t} = getSign(_m_h5_c || _m_h5_tk, appKey, formData) const url = new URL(request.url) let params = new URLSearchParams(url.search); @@ -253,7 +252,7 @@ function getSheinCookie() { function getAliexpressCookie() { - const url = new URL("https://www.aliexpress.com/"); + const url = new URL("https://csp.aliexpress.com/"); let cStr = ''; chrome.cookies.getAll({domain: url.host}, (cookie) => { cookie.map((c) => { diff --git a/src/view/selection/AliExpressCopy.vue b/src/view/selection/AliExpressCopy.vue index dffaecf..5bd37ad 100644 --- a/src/view/selection/AliExpressCopy.vue +++ b/src/view/selection/AliExpressCopy.vue @@ -69,8 +69,7 @@