r/electronjs • u/Few-Fishing5063 • 5h ago
Electron adblocking package built on AdGuard's filter engine. No IPC. No Preload. cross-origin and same-origin cosmetic filtering
Introducing an Electron adblocking package built on AdGuard's filter engine.
- No IPC.
- No Preload.
- Full cross-origin and same-origin cosmetic filtering.
- Consumer owned event handlers (`onBeforeRequest` |`setWindowOpenHandler`).
- Consumer-controlled filter mirror
Adblock-Electron originated from a practical requirement: removing advertising, trackers, and intrusive pop-ups from streaming websites while retaining the ability to inspect their source code and runtime behavior.
Existing solutions, including Ghostery and other available Electron ad-blocking packages, proved insufficient. Either they couldn't provide the cross-origin frame access I needed, or their approach to network filtering required taking ownership of Electron's `onBeforeRequest` handler.
Many streaming websites employ techniques specifically designed to interfere with developer tools, including debugger traps, execution pauses, console manipulation, and scripts intended to detect DevTools activity.
Adblock-Electron incorporates mechanisms to counteract interference through targeted blocking of DevTools-related scripts and requests. To focus the scope of this package, automatic debugger resumption and console-clearing inhibitors were removed, leaving a very effective network filtering, cross-origin cosmetic filtering, and script injection implementation.
The package fetches resources from either the default repository or a consumer owned repository cloned from adtidy-filter-mirror
A simple demo application is provided for real world results.:
Load any of the 14 streaming sites setting `withConsole: true` logs handler initialisation, main-frame and cross-origin filtering, session tracking, cosmetic / script injection and blocked network request metrics.
The following snippet is an example log. Showing page load, movie selection and embedded player load. Note that Adguard's tsurlfilter package returns filters based on path as well as hostname
──────────────────────────────────────────
HANDLER INITIALISATION
──────────────────────────────────────────
{
setWindowOpenHandler: { registered: true, withWindowOpenHandler: false, owner: 'adblock' },
onBeforeRequest: { registered: true, withBeforeRequest: false, owner: 'adblock' }
}
──────────────────────────────────────────────────────────────────────────────────────
MAIN_FRAME CAPABILITY
───────────────────────────────────────────
{
sessionId: 'main',
Capability: 'fullSet',
Protocols: [
{ Protocol: 'Network', Enabled: true },
{ Protocol: 'DOM', Enabled: true },
{ Protocol: 'Runtime', Enabled: true },
{ Protocol: 'Target', Enabled: true },
{ Protocol: 'Page', Enabled: true }
],
AutoAttach: true,
Active: [ 'main' ],
Inactive: []
}
──────────────────────────────────────────────────────────────────────────────────────
COSMETIC INJECTION
───────────────────────────────────────────
{
type: 'CSS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy.cyou/',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
SCRIPTLET INJECTION
───────────────────────────────────────────
{
type: 'JS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy. cyou/',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
COSMETIC INJECTION
───────────────────────────────────────────
{
type: 'CSS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy. cyou/movies',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
SCRIPTLET INJECTION
───────────────────────────────────────────
{
type: 'JS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy. cyou/movies',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
NETWORK REQUESTS BLOCKED
───────────────────────────────────────────
{
total: 2,
requests: [
{
url: 'https //platform-api.sharethis.com/js/sharethis.js#property=6919e156a804e14d4991f69a&product=inline-share-buttons',
resourceType: 'script'
},
{ url: 'https //s10.histats.com/js15_as.js', resourceType: 'script' }
]
}
──────────────────────────────────────────────────────────────────────────────────────
COSMETIC INJECTION
───────────────────────────────────────────
{
type: 'CSS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy.cyou/movie/1368337',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
SCRIPTLET INJECTION
───────────────────────────────────────────
{
type: 'JS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy.cyou/movie/1368337',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
NETWORK REQUESTS BLOCKED
───────────────────────────────────────────
{
total: 3,
requests: [
{
url: 'https //createlouisville.org/14/ca0843f2a5e7d293c826930890ccf5f5',
resourceType: 'script'
},
{
url: 'https //tagivi.com/1/9f1c268d58f04723465fe5c884b4cea2',
resourceType: 'script'
},
{ url: 'https //s10.histats.com/js15_as.js', resourceType: 'script' }
]
}
──────────────────────────────────────────────────────────────────────────────────────
COSMETIC INJECTION
────────────────────────────────────────────────────────────────────────
{
type: 'CSS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy.cyou/watch/movie/1368337',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
SCRIPTLET INJECTION
───────────────────────────────────────────
{
type: 'JS',
frameId: '89E567F247610993C145C28B401054C6',
sessionId: 'main',
url: 'https //streamzippy.cyou/watch/movie/1368337',
frame: 'main_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
NETWORK REQUESTS BLOCKED
───────────────────────────────────────────
{
total: 3,
requests: [
{
url: 'https //createlouisville.org/14/ca0843f2a5e7d293c826930890ccf5f5',
resourceType: 'script'
},
{
url: 'https //tagivi.com/1/9f1c268d58f04723465fe5c884b4cea2',
resourceType: 'script'
},
{ url: 'https //s10.histats.com/js15_as.js', resourceType: 'script' }
]
}
──────────────────────────────────────────────────────────────────────────────────────
SUB_FRAME CAPABILITY
───────────────────────────────────────────
{
sessionId: '9F7B7134B514D5585B865903E0C6FCFD',
Capability: 'fullSet',
Protocols: [
{ Protocol: 'Network', Enabled: true },
{ Protocol: 'DOM', Enabled: true },
{ Protocol: 'Runtime', Enabled: true },
{ Protocol: 'Target', Enabled: true }
],
AutoAttach: true,
Active: [ 'main', '9F7B7134B514D5585B865903E0C6FCFD' ],
Inactive: []
}
──────────────────────────────────────────────────────────────────────────────────────
COSMETIC INJECTION
───────────────────────────────────────────
{
type: 'CSS',
frameId: '6785D89A251BE77E6559321E87F3527A',
sessionId: '9F7B7134B514D5585B865903E0C6FCFD',
url: 'https //embed.vidsrc.si/embed/movie/1368337?autoplay=1&ds_lang=en',
frame: 'sub_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
SCRIPTLET INJECTION
───────────────────────────────────────────
{
type: 'JS',
frameId: '6785D89A251BE77E6559321E87F3527A',
sessionId: '9F7B7134B514D5585B865903E0C6FCFD',
url: 'https //embed.vidsrc.si/embed/movie/1368337?autoplay=1&ds_lang=en',
frame: 'sub_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
NETWORK REQUESTS BLOCKED
───────────────────────────────────────────
{
total: 3,
requests: [
{
url: 'https //createlouisville.org/14/ca0843f2a5e7d293c826930890ccf5f5',
resourceType: 'script'
},
{
url: 'https //tagivi.com/1/9f1c268d58f04723465fe5c884b4cea2',
resourceType: 'script'
},
{ url: 'https //s10.histats.com/js15_as.js', resourceType: 'script' }
]
}
──────────────────────────────────────────────────────────────────────────────────────
SUB_FRAME CAPABILITY
───────────────────────────────────────────
{
sessionId: 'E95C10422D5029FE8516C79A81757164',
Capability: 'fullSet',
Protocols: [
{ Protocol: 'Network', Enabled: true },
{ Protocol: 'DOM', Enabled: true },
{ Protocol: 'Runtime', Enabled: true },
{ Protocol: 'Target', Enabled: true }
],
AutoAttach: true,
Active: [ 'main', '9F7B7134B514D5585B865903E0C6FCFD', 'E95C10422D5029FE8516C79A81757164' ],
Inactive: []
}
──────────────────────────────────────────────────────────────────────────────────────
COSMETIC INJECTION
───────────────────────────────────────────
{
type: 'CSS',
frameId: 'D8600195EF48E3A4E7C7FC878E6B5E2F',
sessionId: 'E95C10422D5029FE8516C79A81757164',
url: 'https //stellarconductornexus.com/embed/movie/1368337?vs=wlDM3JyFJnBa2tDIKVzKDEqvTzJ7AhHeZm71xbaSgTzB_k8kT1gWtg3tXgG8KMzeli_V8D1BM1BcSFHUZgpNyd99SmeEEaD2aaZy0DiDf7KnNMM2VvwP84X9KSKoR65rzyaXOkMVKadIw35tDiej1Q&autoplay=1&ds_lang=en',
frame: 'sub_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
SCRIPTLET INJECTION
───────────────────────────────────────────
{
type: 'JS',
frameId: 'D8600195EF48E3A4E7C7FC878E6B5E2F',
sessionId: 'E95C10422D5029FE8516C79A81757164',
url: 'https //stellarconductornexus.com/embed/movie/1368337?vs=wlDM3JyFJnBa2tDIKVzKDEqvTzJ7AhHeZm71xbaSgTzB_k8kT1gWtg3tXgG8KMzeli_V8D1BM1BcSFHUZgpNyd99SmeEEaD2aaZy0DiDf7KnNMM2VvwP84X9KSKoR65rzyaXOkMVKadIw35tDiej1Q&autoplay=1&ds_lang=en',
frame: 'sub_frame',
injected: true
}
──────────────────────────────────────────────────────────────────────────────────────
NETWORK REQUESTS BLOCKED
───────────────────────────────────────────
{
total: 5,
requests: [
{
url: 'https //embed.vidsrc.si/assets/disable-devtool.js?v=1785879645',
resourceType: 'script'
},
{ url: 'https //s10.histats.com/js15_as.js', resourceType: 'script' },
{ url: 'https //pmi.nxu1qz1kfov756.cfd/kjXIERfG32z92/VvMrO', resourceType: 'script' },
{
url: 'https //embed.vidsrc.si/cdn-cgi/zaraz/s.js?z=JTdCJTIyZXhlY3V0ZWQlMjIlM0ElNUIlNUQlMkMlMjJ0JTIyJTNBJTIyUGxheWVyJTIyJTJDJTIyeCUyMiUzQTAuMzk3Njg2MTc1NTQ5MTg4MyUyQyUyMnclMjIlM0ExOTIwJTJDJTIyaCUyMiUzQTEyMDAlMkMlMjJqJTIyJTNBNzAyJTJDJTIyZSUyMiUzQTEyNDYlMkMlMjJsJTIyJTNBJTIyaHR0cHMlM0ElMkYlMkZlbWJlZC52aWRzcmMuc2klMkZlbWJlZCUyRm1vdmllJTJGMTM2ODMzNyUzRmF1dG9wbGF5JTNEMSUyNmRzX2xhbmclM0RlbiUyMiUyQyUyMnIlMjIlM0ElMjJodHRwcyUzQSUyRiUyRnN0cmVhbXppcHB5LmN5b3UlMkYlMjIlMkMlMjJrJTIyJTNBMjQlMkMlMjJuJTIyJTNBJTIyVVRGLTglMjIlMkMlMjJvJTIyJTNBMCUyQyUyMnElMjIlM0ElNUIlNUQlN0Q=',
resourceType: 'script'
},
{
url: 'https //4zc561.65z9cgbzjzicvf.rest/k2uIWfJ9wMt6KX/VvMrO',
resourceType: 'script'
}
]
}
───────────────────────────────────────────
Basic test-site results



