mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-22 00:00:04 +08:00
fix: websocket
This commit is contained in:
parent
41619f7700
commit
6753c062e7
24
docs/FixWebSocket.md
Normal file
24
docs/FixWebSocket.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# WebSocket修复
|
||||||
|
|
||||||
|
自 nw0.76.0 开始,调试器的WebSocket无法建立链接。
|
||||||
|
|
||||||
|
## 原因
|
||||||
|
|
||||||
|
旧版本似乎不会对websocket请求进行拦截,而在某一版本开始chrome支持websocket请求拦截;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 解决
|
||||||
|
|
||||||
|
文件路径:`cache/core.wxvpkg.ext/f67cdfd87843382519d9c48d8a0bd4dc.js`
|
||||||
|
|
||||||
|
添加以下内容:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
(this._onBeforeRequest = (e) => {
|
||||||
|
console.warn('----webview request for:', e)
|
||||||
|
if (/^wss?:\/\//i.test(e.url)) return void 0; // add
|
||||||
|
if ("function" == typeof this.onBeforeRequest)
|
||||||
|
return this.onBeforeRequest(e);
|
||||||
|
}),
|
||||||
|
```
|
@ -125,6 +125,16 @@ else
|
|||||||
warn "theme位置未找到"
|
warn "theme位置未找到"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# fix WebSocket for nw >= v0.76.0
|
||||||
|
notice "fix WebSocket"
|
||||||
|
find_result=$( grep -lr "this._onBeforeRequest=e=>{if" "$tmp_dir/core.wxvpkg" )
|
||||||
|
echo "WebSocket: $find_result"
|
||||||
|
if [[ -n $find_result ]];then
|
||||||
|
sed -i 's#this._onBeforeRequest=e=>{if#this._onBeforeRequest=(e)=>{/*for nw >= v0.76.0*/if (/^wss?:\\/\\//i.test(e.url)) return void 0;if#' $find_result
|
||||||
|
else
|
||||||
|
warn "WebSocket位置未找到"
|
||||||
|
fi
|
||||||
|
|
||||||
# fix update check
|
# fix update check
|
||||||
notice "fix update check"
|
notice "fix update check"
|
||||||
sed -i 's#</body><script src=../js/core#</body><script src="../js/unpack/hackrequire/index.js"></script><script src=../js/core#' "$package_dir/html/whatsnew.html"
|
sed -i 's#</body><script src=../js/core#</body><script src="../js/unpack/hackrequire/index.js"></script><script src=../js/core#' "$package_dir/html/whatsnew.html"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user