获取anti_content完成
This commit is contained in:
		| @@ -1,4 +1,5 @@ | |||||||
| import store from '@/store' | import store from '@/store' | ||||||
|  | import {genAnti} from "@/api/genAnti"; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 向Chrome发送消息 |  * 向Chrome发送消息 | ||||||
| @@ -7,13 +8,27 @@ import store from '@/store' | |||||||
| export function sendChromeAPIMessage(message) { | export function sendChromeAPIMessage(message) { | ||||||
|   message.type = 'api' |   message.type = 'api' | ||||||
|   message.url = "https://kuajing.pinduoduo.com/" + message.url; |   message.url = "https://kuajing.pinduoduo.com/" + message.url; | ||||||
|   message.anti = false |   message.anti = message.anti||false | ||||||
|   if (message.needMallId) { |   if (message.needMallId) { | ||||||
|     // 如果参数中没有携带MallId,则从state中获取 |     // 如果参数中没有携带MallId,则从state中获取 | ||||||
|     if (!message.mallId) { |     if (!message.mallId) { | ||||||
|       message.mallId = store.state.mallId; |       message.mallId = store.state.mallId; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |   if(message.anti) { | ||||||
|  |     message.anti = genAnti()["messagePack"]({ | ||||||
|  |       touchEventData: !0, | ||||||
|  |       clickEventData: !0, | ||||||
|  |       focusblurEventData: !0, | ||||||
|  |       changeEventData: !0, | ||||||
|  |       locationInfo: !0, | ||||||
|  |       referrer: !0, | ||||||
|  |       browserSize: !0, | ||||||
|  |       browserInfo: !0, | ||||||
|  |       token: !0, | ||||||
|  |       fingerprint: !0 | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|   return new Promise((resolve) => { |   return new Promise((resolve) => { | ||||||
|     // @ts-ignore |     // @ts-ignore | ||||||
|     chrome.runtime.sendMessage(message, resolve) |     chrome.runtime.sendMessage(message, resolve) | ||||||
|   | |||||||
							
								
								
									
										4968
									
								
								src/api/genAnti.js
									
									
									
									
									
								
							
							
						
						
									
										4968
									
								
								src/api/genAnti.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -1,12 +1,3 @@ | |||||||
| /** |  | ||||||
|  * 获取Anti-Content |  | ||||||
|  */ |  | ||||||
| export const getAntiContent = message => { |  | ||||||
|   message.type = "genAnti" |  | ||||||
|   return new Promise((resolve) => { |  | ||||||
|     chrome.runtime.sendMessage(message, resolve) |  | ||||||
|   }) |  | ||||||
| } |  | ||||||
| /** | /** | ||||||
|  利用chrome的fetch来避免跨域 |  利用chrome的fetch来避免跨域 | ||||||
|  **/ |  **/ | ||||||
| @@ -18,7 +9,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { | |||||||
|         headers.Mallid = request.mallId; |         headers.Mallid = request.mallId; | ||||||
|       } |       } | ||||||
|       if (request.anti) { |       if (request.anti) { | ||||||
|         headers["Anti-Content"] = getAntiContent() |         headers["Anti-Content"] = request.anti | ||||||
|       } |       } | ||||||
|       headers['Content-Type'] = 'application/json'; |       headers['Content-Type'] = 'application/json'; | ||||||
|       headers.cookie = getCookie(); |       headers.cookie = getCookie(); | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ export default { | |||||||
|       this.$router.push('/login') |       this.$router.push('/login') | ||||||
|     } else { |     } else { | ||||||
|       this.$store.dispatch('getUserInfo'); |       this.$store.dispatch('getUserInfo'); | ||||||
|       sendChromeAPIMessage({url: 'bg/quiet/api/mms/userInfo', needMallId: false, data: {}}).then((res) => { |       sendChromeAPIMessage({url: 'bg/quiet/api/mms/userInfo',anti:true, needMallId: false, data: {}}).then((res) => { | ||||||
|         if (res.errorCode == 1000000) { |         if (res.errorCode == 1000000) { | ||||||
|           if (res.result.companyList[0].malInfoList.length == 1) { |           if (res.result.companyList[0].malInfoList.length == 1) { | ||||||
|             this.$store.commit('setMallId', `${res.result.companyList[0].malInfoList[0].mallId}`) |             this.$store.commit('setMallId', `${res.result.companyList[0].malInfoList[0].mallId}`) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user