From 43cead701a533695d8dfbf527792441d281ecf36 Mon Sep 17 00:00:00 2001 From: Kurisu Date: Wed, 11 Sep 2024 23:15:23 +0800 Subject: [PATCH] fix: remove Electron, Follow from the default user-agent. --- src/main/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/index.ts b/src/main/index.ts index ae2ffe36a0..2afcb031d1 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -53,6 +53,17 @@ function bootsharp() { registerUpdater() + //remove Electron, Follow from user agent + session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => { + let userAgent = details.requestHeaders["User-Agent"] + if (userAgent) { + userAgent = userAgent.replace(/\s?Electron\/[\d.]+/, "") + userAgent = userAgent.replace(/\s?Follow\/[\d.a-zA-Z-]+/, "") + } + details.requestHeaders["User-Agent"] = userAgent + callback({ cancel: false, requestHeaders: details.requestHeaders }) + }) + app.on("activate", () => { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open.