From fc32b8b862acccccaa8fdfe0eef5117775adccd4 Mon Sep 17 00:00:00 2001 From: luochaolun
Date: Sun, 7 Jan 2024 08:59:51 +0800 Subject: [PATCH] Optimizing bugs --- README.md | 6 +- electron/proxyServer.js | 120 +++++----------------------------------- electron/utils.js | 8 +-- package.json | 1 + src/App.jsx | 4 +- src/fsm.js | 5 +- 6 files changed, 30 insertions(+), 114 deletions(-) diff --git a/README.md b/README.md index 5c41f4a..d35c111 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # 微信视频号下载器 -# 修改自https://github.com/lecepin/WeChatVideoDownloader +修改自https://github.com/lecepin/WeChatVideoDownloader # 自己实现了“复制视频”、“解密视频”功能,并修改解密下载每次都要选择保存目录的不变之处,改为第一次选择保存目录,之后不用选择保存目录。 因为ai方面比较菜,“复制视频”、“解密视频”点击都没有提示! -# 折腾好几天,终于可以了!运行后网络不通、捕获不了的看过来: +折腾好几天,终于可以了!运行后网络不通、捕获不了的看过来: -# 进入安装目录,打开powershell,从powershell命令行里运行wechatvideodownloader. exe,就可以了。 +进入安装目录,打开powershell,从powershell命令行里运行wechatvideodownloader. exe,就可以了。 > 🔥🔥🔥 V2.x版本支持加密视频的下载,可到 Release 中下载更新。 diff --git a/electron/proxyServer.js b/electron/proxyServer.js index 0a74827..f6bea21 100644 --- a/electron/proxyServer.js +++ b/electron/proxyServer.js @@ -11,68 +11,10 @@ if (process.platform === 'win32') { process.env.OPENSSL_CONF = CONFIG.OPEN_SSL_CNF_PATH; } -const WVDS_DEBUG = process.env.WVDS_DEBUG !== undefined; +const my_injection_script = ` +let receiver_url = "https://aaaa.com"; -const injection_html = ` - -`; - -// setTimeout to allow working in macOS -// in windows: H5ExtTransfer:ok -// in macOS: finderH5ExtTransfer:ok -const injection_script = ` -setTimeout(() => { - if (window.wvds !== undefined) return; - ${ - WVDS_DEBUG - ? ` - document.body.style.border = "2px solid #0000FF"; - let ele_app = document.getElementById("app"); - let ele_btn1 = document.createElement("a"); - let ele_btn2 = document.createElement("a"); - let ele_debug = document.createElement("textarea"); - ` - : '' - } - function debug_wvds(msg) { - ${WVDS_DEBUG ? `ele_debug.value += "\\n" + msg;` : ''} - } - - ${ - WVDS_DEBUG - ? ` - ele_btn1.style = "position:absolute;top:3px;left:20px;width:80px;height:30px;cursor:pointer;"; - ele_btn1.text = "Source"; - ele_btn1.onclick = () => { - var source = ""; - source += document.getElementsByTagName('html')[0].innerHTML; - source += ""; - debug_wvds(source); - }; - ele_app.appendChild(ele_btn1); - - ele_btn2.style = "position:absolute;top:3px;left:120px;width:80px;height:30px;cursor:pointer;"; - ele_btn2.text = "Test"; - ele_btn2.onclick = () => { - debug_wvds("Hello WeChatVideo Downloader!"); - }; - ele_app.appendChild(ele_btn2); - - ele_debug.setAttribute("rows", "60"); - ele_debug.setAttribute("cols", "60"); - ele_debug.style = "position:absolute;top:600px;left:20px;width:600px;height:300px;border:2px solid #FF00FF;"; - ele_debug.value = "Debug:\\n"; - ele_app.appendChild(ele_debug); - ` - : '' - } - let receiver_url = "https://aaaa.com"; - - function send_response_if_is_video(response) { - if (response == undefined) return; - // debug_wvds(JSON.stringify(response)); - debug_wvds("send 1: " + response["err_msg"]); - if (!response["err_msg"].includes("H5ExtTransfer:ok")) return; +function send_response_if_is_video(response) { let value = JSON.parse(response["jsapi_resp"]["resp_json"]); // debug_wvds("send 2: " + JSON.stringify(value)); if (value["object"] == undefined || value["object"]["object_desc"] == undefined || value["object"]["object_desc"]["media"].length == 0) { @@ -81,7 +23,7 @@ setTimeout(() => { let media = value["object"]["object_desc"]["media"][0]; // debug_wvds("send 3: " + JSON.stringify(media)); let description = value["object"]["object_desc"]["description"].trim(); - debug_wvds("send x decode key: " + media["decode_key"] + " for " + description); + let video_data = { "decode_key": media["decode_key"], "url": media["url"]+media["url_token"], @@ -89,39 +31,35 @@ setTimeout(() => { "description": description, "uploader": value["object"]["nickname"] }; - fetch(receiver_url, { + + fetch(receiver_url, { method: "POST", mode: "no-cors", body: JSON.stringify(video_data), }).then((resp) => { - debug_wvds(\`video data for \${video_data["description"]} sent!\`); + //alert(\`video data for \${video_data["description"]} sent!\`); }); - } +} - function wrapper(name,origin) { +function wrapper(name,origin) { return function() { let cmdName = arguments[0]; if (arguments.length == 3) { let original_callback = arguments[2]; arguments[2] = async function () { if (arguments.length == 1) { - debug_wvds("wrapper 3: " + JSON.stringify(arguments[0])); send_response_if_is_video(arguments[0]); } return await original_callback.apply(this, arguments); } - debug_wvds("wrapper 1: " + cmdName + ", " + typeof(arguments[1]) + ", " + typeof(arguments[2])); - } else { - debug_wvds("wrapper 2: " + cmdName + ", " + arguments.length + ", " + arguments[1] + ", " + typeof(arguments[2])); } let result = origin.apply(this,arguments); return result; } - } - window.WeixinJSBridge.invoke = wrapper("WeixinJSBridge.invoke", window.WeixinJSBridge.invoke); - window.wvds = true; - debug_wvds("Invoke WechatVideoDownloader Service!"); -}, 1000);`; +} + +window.WeixinJSBridge.invoke = wrapper("WeixinJSBridge.invoke", window.WeixinJSBridge.invoke); +window.wvds = true;`; export async function startServer({ win, setProxyErrorCallback = f => f }) { const port = await getPort(); @@ -167,41 +105,13 @@ export async function startServer({ win, setProxyErrorCallback = f => f }) { as: 'string', }, async (req, res) => { - if (req.url.includes('/web/pages/feed')) { - res.string = res.string.replace('