Only keep "Block Ads and Trackers" option

This commit is contained in:
Agampreet Singh
2023-06-11 22:50:00 +05:30
parent 1526a81d1c
commit 1625a46529
2 changed files with 7 additions and 63 deletions

View File

@@ -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);

View File

@@ -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 (