ghostery / adblocker

Efficient embeddable adblocker library

Home Page:https://www.ghostery.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[adblocker-electron] Reddit and X.com broken with `fromPrebuiltFull`

spikecodes opened this issue · comments

Reddit doesn't load in Electron when either the ElectronBlocker.fromPrebuiltAdsAndTracking or ElectronBlocker.fromPrebuiltFull method is used on the session.

Code to reproduce is attached below. Here's a repo I made to test it.

const { app, BrowserWindow } = require("electron");
const { ElectronBlocker } = require("@cliqz/adblocker-electron");

let mainWindow;

function createWindow() {
  mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    titleBarStyle: "hidden",
  });

  mainWindow.loadURL("https://reddit.com");

  mainWindow.webContents.openDevTools();

  ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
    blocker.enableBlockingInSession(mainWindow.webContents.session);
  });
}

app.on("ready", createWindow);

app.on("window-all-closed", () => {
  app.quit();
});

image

Some other websites I tested that seem to be broken from loading by either one or both of these blocking options:

Both do work, though, when using fromPrebuiltAdsOnly.

Hey, did you try creating the browser window using the settings shown in the example here? https://github.com/ghostery/adblocker/blob/master/packages/adblocker-electron-example/index.ts#L20

I know there are some isolation settings which can prevent the adblocker from working properly in Electron.

Thanks for the quick response. Even with those settings, x.com and reddit.com don't load with fromPrebuiltFull (although they used to a couple months ago).
image