Adblock Support for Embeds (#308)
Fixes #307 - Adds optional adblock support, via wabac.js (dependent on webrecorder/wabac.js#167). - For now, adblock enabled only for embeds via the `useAdblock` attribute, and can be enabled per archived item. - By default, adblock filter rules from [EasyList](https://easylist.to/easylist/easylist.txt) are used, however, a custom filter rules file can be used via `adblockRulesUrl` attribute (default is ./adblock/adblock.gz) - Added `fetch-adblock.sh` script to fetch latest easylist, filter out `##` rules and compress to `./adblock/adblock.gz` - Not yet possible to enable adblock for standalone browsing via replayweb.page - bumps version to 2.0.0-beta.3
This commit is contained in:
@@ -608,6 +608,11 @@ export class ReplayWebApp extends LitElement {
|
||||
this.loadInfo!.extraConfig.baseUrl = this.pageParams.get("basePageUrl");
|
||||
}
|
||||
|
||||
if (this.pageParams.get("adblockUrl")) {
|
||||
this.loadInfo!.extraConfig = this.loadInfo!.extraConfig || {};
|
||||
this.loadInfo!.extraConfig.adblockUrl = this.pageParams.get("adblockUrl");
|
||||
}
|
||||
|
||||
if (this.pageParams.get("customColl")) {
|
||||
this.loadInfo!.customColl = this.pageParams.get("customColl");
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ let defaultReplayFile = "";
|
||||
|
||||
const DEFAULT_REPLAY_BASE = "https://replayweb.page/";
|
||||
|
||||
const DEFAULT_ADBLOCK_FILE = "./adblock/adblock.gz";
|
||||
|
||||
// ===========================================================================
|
||||
class Embed extends LitElement {
|
||||
@property({ type: String }) url = "";
|
||||
@@ -64,6 +66,9 @@ class Embed extends LitElement {
|
||||
@property({ type: Boolean }) noCache = false;
|
||||
@property({ type: Boolean }) hideOffscreen: boolean | undefined;
|
||||
|
||||
@property({ type: Boolean }) useAdblock = false;
|
||||
@property({ type: String }) adblockRulesUrl = DEFAULT_ADBLOCK_FILE;
|
||||
|
||||
@property({ type: String }) newWindowBase = "";
|
||||
|
||||
@property({ type: String }) errorMessage:
|
||||
@@ -287,6 +292,7 @@ class Embed extends LitElement {
|
||||
loading?: "eager";
|
||||
swName?: string;
|
||||
ruffle?: "1";
|
||||
adblockUrl?: string;
|
||||
} = {
|
||||
source,
|
||||
customColl: this.coll,
|
||||
@@ -324,6 +330,10 @@ class Embed extends LitElement {
|
||||
params.ruffle = "1";
|
||||
}
|
||||
|
||||
if (this.useAdblock && this.adblockRulesUrl) {
|
||||
params.adblockUrl = this.adblockRulesUrl;
|
||||
}
|
||||
|
||||
this.paramString = new URLSearchParams(
|
||||
// Converting to unknown here so that we can ignore the URL -> string conversion necessary for the types to work out
|
||||
params as unknown as Record<string, string>,
|
||||
|
||||
@@ -72,6 +72,7 @@ export type LoadInfo = {
|
||||
baseUrl?: unknown;
|
||||
headers?: unknown;
|
||||
recording?: unknown;
|
||||
adblockUrl?: string | null;
|
||||
};
|
||||
customColl?: string | null;
|
||||
noWebWorker?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user