Skip to content

Commit

Permalink
fix: remove electron's default user-agent keep browser user agent (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiCoco authored Sep 11, 2024
1 parent 961a75c commit adb39bc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit adb39bc

Please sign in to comment.