mirror of
https://github.com/agam778/MS-365-Electron.git
synced 2026-02-17 09:02:10 +00:00
Enable/Disable ad blocking in all windows when turned on/off from menu
This commit is contained in:
46
app/menu.js
46
app/menu.js
@@ -394,13 +394,15 @@ const menulayout = [
|
||||
message: "Ads and trackers will no longer be blocked.",
|
||||
buttons: ["OK"],
|
||||
});
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then(
|
||||
(blocker) => {
|
||||
blocker.disableBlockingInSession(
|
||||
BrowserWindow.getFocusedWindow().webContents.session
|
||||
);
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
|
||||
BrowserWindow.getAllWindows().forEach(window => {
|
||||
blocker.disableBlockingInSession(window.webContents.session);
|
||||
});
|
||||
}).catch((error) => {
|
||||
if (error.message !== "Trying to disable blocking which was not enabled") {
|
||||
console.error(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (
|
||||
@@ -408,11 +410,10 @@ const menulayout = [
|
||||
getValue("blockadsandtrackers") === undefined
|
||||
) {
|
||||
setValue("blockadsandtrackers", "true");
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then(
|
||||
(blocker) => {
|
||||
blocker.enableBlockingInSession(
|
||||
BrowserWindow.getFocusedWindow().webContents.session
|
||||
);
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
|
||||
BrowserWindow.getAllWindows().forEach(window => {
|
||||
blocker.enableBlockingInSession(window.webContents.session);
|
||||
})
|
||||
dialog.showMessageBoxSync({
|
||||
type: "info",
|
||||
title: "Block Ads and Trackers",
|
||||
@@ -749,13 +750,15 @@ const menulayout = [
|
||||
message: "Ads and trackers will no longer be blocked.",
|
||||
buttons: ["OK"],
|
||||
});
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then(
|
||||
(blocker) => {
|
||||
blocker.disableBlockingInSession(
|
||||
BrowserWindow.getFocusedWindow().webContents.session
|
||||
);
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
|
||||
BrowserWindow.getAllWindows().forEach(window => {
|
||||
blocker.disableBlockingInSession(window.webContents.session);
|
||||
});
|
||||
}).catch((error) => {
|
||||
if (error.message !== "Trying to disable blocking which was not enabled") {
|
||||
console.error(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (
|
||||
@@ -763,11 +766,10 @@ const menulayout = [
|
||||
getValue("blockadsandtrackers") === undefined
|
||||
) {
|
||||
setValue("blockadsandtrackers", "true");
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then(
|
||||
(blocker) => {
|
||||
blocker.enableBlockingInSession(
|
||||
BrowserWindow.getFocusedWindow().webContents.session
|
||||
);
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
|
||||
BrowserWindow.getAllWindows().forEach(window => {
|
||||
blocker.enableBlockingInSession(window.webContents.session);
|
||||
})
|
||||
dialog.showMessageBoxSync({
|
||||
type: "info",
|
||||
title: "Block Ads and Trackers",
|
||||
|
||||
Reference in New Issue
Block a user