From 1625a46529b90c73569e49801c0b2870ef051ad3 Mon Sep 17 00:00:00 2001 From: Agampreet Singh <68941022+agam778@users.noreply.github.com> Date: Sun, 11 Jun 2023 22:50:00 +0530 Subject: [PATCH] Only keep "Block Ads and Trackers" option --- app/main.js | 10 --------- app/menu.js | 60 +++++++---------------------------------------------- 2 files changed, 7 insertions(+), 63 deletions(-) diff --git a/app/main.js b/app/main.js index 3207c97..38c03ad 100644 --- a/app/main.js +++ b/app/main.js @@ -56,11 +56,6 @@ function createWindow() { if (getValue("discordrpcstatus") === "true") { setActivity(`On "${win.webContents.getTitle()}"`); } - if (getValue("blockads") === "true") { - ElectronBlocker.fromPrebuiltAdsOnly(fetch).then((blocker) => { - blocker.enableBlockingInSession(win.webContents.session); - }); - } if (getValue("blockadsandtrackers") === "true") { ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => { blocker.enableBlockingInSession(win.webContents.session); @@ -299,11 +294,6 @@ app.on("browser-window-created", (event, window) => { setActivity(`On "${window.webContents.getTitle()}"`); } }); - if (getValue("blockads") === "true") { - ElectronBlocker.fromPrebuiltAdsOnly(fetch).then((blocker) => { - blocker.enableBlockingInSession(window.webContents.session); - }); - } if (getValue("blockadsandtrackers") === "true") { ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => { blocker.enableBlockingInSession(window.webContents.session); diff --git a/app/menu.js b/app/menu.js index 0522d0d..c9e25de 100644 --- a/app/menu.js +++ b/app/menu.js @@ -100,7 +100,6 @@ getValueOrDefault("enterprise-or-normal", "https://microsoft365.com/?auth=1"); getValueOrDefault("autohide-menubar", "false"); getValueOrDefault("useragentstring", useragents.Windows); getValueOrDefault("discordrpcstatus", "false"); -getValueOrDefault("blockads", "false"); getValueOrDefault("blockadsandtrackers", "false"); const menulayout = [ @@ -321,49 +320,6 @@ const menulayout = [ checked: getValue("discordrpcstatus") === "true", }, { type: "separator" }, - { - label: "Block Ads", - type: "checkbox", - click: () => { - if (getValue("blockads") === "true") { - setValue("blockads", "false"); - dialog.showMessageBoxSync({ - type: "info", - title: "Block Ads", - message: "Ads will no longer be blocked.", - buttons: ["OK"], - }); - if (!getValue("blockadsandtrackers") === "true") { - ElectronBlocker.fromPrebuiltAdsOnly(fetch).then((blocker) => - blocker.disableBlockingInSession( - BrowserWindow.getFocusedWindow().webContents.session - ) - ); - } - return; - } - if ( - getValue("blockads") === "false" || - getValue("blockads") === undefined - ) { - setValue("blockads", "true"); - ElectronBlocker.fromPrebuiltAdsOnly(fetch).then((blocker) => - blocker.enableBlockingInSession( - BrowserWindow.getFocusedWindow().webContents.session - ) - ); - - dialog.showMessageBoxSync({ - type: "info", - title: "Block Ads", - message: "Ads will now be blocked.", - buttons: ["OK"], - }); - return; - } - }, - checked: getValue("blockads") === "true", - }, { label: "Block Ads and Trackers", type: "checkbox", @@ -376,15 +332,13 @@ const menulayout = [ message: "Ads and trackers will no longer be blocked.", buttons: ["OK"], }); - if (!getValue("blockads") === "true") { - ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then( - (blocker) => { - blocker.disableBlockingInSession( - BrowserWindow.getFocusedWindow().webContents.session - ); - } - ); - } + ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then( + (blocker) => { + blocker.disableBlockingInSession( + BrowserWindow.getFocusedWindow().webContents.session + ); + } + ); return; } if (