WA云控,星河云控,四海云控,火箭云控,WS云控,七星云控,UU云控,INS云控,WhatsApp群发,WhatsApp云控,WhatsApp协议号,WhatsApp频道号,WhatsApp软件,星火出海营销,AK云控,浩瀚云控,007云控,聚星云控,巨鲸云控,启航云控,闪电云控,拉客宝云控,方舟云控

WhatsApp云控|WhatsApp协议号

合作咨询 TG:XH518178
创造有活力的品牌网站 提升用户体验和品牌价值感
如何拦截并重定向请求?
人气 

作者:Ran

2020-10-15 Ran

以WhatsApp网页版为例,通过拦截并重定向请求可以注入自定义逻辑。

/**

* 请求重定向

*/

chrome.webRequest.onBeforeRequest.addListener(

function (details) {

const matchURL = details.url

const replaceBaseURL = ‘http://localhost:3001’

const scriptReg = /https:\/\/web\.whatsapp\.com\/([^.]+)\.?([^.]*)\.js/

const fileName = scriptReg.exec(matchURL)[1]

const fileHash = scriptReg.exec(matchURL)[2]

const replaceURL = `${replaceBaseURL}/whatsapp/override/${fileName}${fileHash ? ‘.’ + fileHash : ”}.js`

console.log(`onBeforeRequest: ${matchURL} → ${replaceURL}`, new Date())

return {

redirectUrl: replaceURL

}

},

{

urls: [

‘https://web.whatsapp.com/app.*.js’,

‘https://web.whatsapp.com/app2.*.js’,

],

types: [‘script’]

},

[‘blocking’]

)