Skip to content

Commit

Permalink
Fix block main document (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
remusao committed Sep 2, 2019
1 parent a54cd72 commit 388c165
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 31 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,12 @@

*not released*

## 1.0.2

*2019-09-02*

* fix: do not block main document requests [#312](https://github.com/cliqz-oss/adblocker/pull/312)

## 1.0.1

*2019-08-28*
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "1.0.1"
"version": "1.0.2"
}
4 changes: 2 additions & 2 deletions packages/adblocker-benchmarks/package.json
@@ -1,7 +1,7 @@
{
"name": "@cliqz/adblocker-benchmarks",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"description": "Content blockers benchmark",
"author": {
"name": "Cliqz"
Expand All @@ -25,7 +25,7 @@
"adblock-rs": "^0.1.22"
},
"dependencies": {
"@cliqz/adblocker": "^1.0.1",
"@cliqz/adblocker": "^1.0.2",
"jsdom": "^15.1.1",
"sandboxed-module": "^2.0.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker-circumvention/package.json
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker-circumvention",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker circumvention for Chrome",
"author": {
"name": "Cliqz"
Expand Down Expand Up @@ -78,6 +78,6 @@
"typescript": "^3.5.3"
},
"dependencies": {
"@cliqz/adblocker-content": "^1.0.1"
"@cliqz/adblocker-content": "^1.0.2"
}
}
2 changes: 1 addition & 1 deletion packages/adblocker-content/package.json
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker-content",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker library (content-scripts helpers)",
"author": {
"name": "Cliqz"
Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker-electron-example/package.json
@@ -1,7 +1,7 @@
{
"name": "@cliqz/adblocker-electron-example",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker Puppeteer wrapper",
"author": {
"name": "Cliqz"
Expand Down Expand Up @@ -59,7 +59,7 @@
}
],
"dependencies": {
"@cliqz/adblocker-electron": "^1.0.1",
"@cliqz/adblocker-electron": "^1.0.2",
"electron": "^6.0.1",
"node-fetch": "^2.6.0",
"ts-node": "^8.3.0"
Expand Down
8 changes: 7 additions & 1 deletion packages/adblocker-electron/adblocker.ts
Expand Up @@ -145,7 +145,13 @@ export class ElectronBlocker extends FiltersEngine {
details: Electron.OnBeforeRequestDetails,
callback: (a: Electron.Response) => void,
): void => {
const { redirect, match } = this.match(fromElectronDetails(details));
const request = fromElectronDetails(details);
if (request.isMainFrame()) {
callback({});
return;
}

const { redirect, match } = this.match(request);

if (redirect) {
callback({ redirectURL: redirect.dataUrl });
Expand Down
6 changes: 3 additions & 3 deletions packages/adblocker-electron/package.json
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker-electron",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker Electron wrapper",
"author": {
"name": "Cliqz"
Expand Down Expand Up @@ -37,8 +37,8 @@
"electron": "^6.0.1"
},
"dependencies": {
"@cliqz/adblocker": "^1.0.1",
"@cliqz/adblocker-content": "^1.0.1"
"@cliqz/adblocker": "^1.0.2",
"@cliqz/adblocker-content": "^1.0.2"
},
"devDependencies": {
"@types/chrome": "^0.0.88",
Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker-puppeteer-example/package.json
@@ -1,7 +1,7 @@
{
"name": "@cliqz/adblocker-puppeteer-example",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker Puppeteer wrapper",
"author": {
"name": "Cliqz"
Expand All @@ -24,7 +24,7 @@
"url": "https://github.com/cliqz-oss/adblocker/issues"
},
"dependencies": {
"@cliqz/adblocker-puppeteer": "^1.0.1",
"@cliqz/adblocker-puppeteer": "^1.0.2",
"node-fetch": "^2.6.0",
"puppeteer": "^1.18.1",
"ts-node": "^8.3.0"
Expand Down
16 changes: 11 additions & 5 deletions packages/adblocker-puppeteer/adblocker.ts
Expand Up @@ -113,19 +113,25 @@ export class PuppeteerBlocker extends FiltersEngine {
}
}

private onRequest = (request: puppeteer.Request): void => {
const { redirect, match } = this.match(fromPuppeteerDetails(request));
private onRequest = (details: puppeteer.Request): void => {
const request = fromPuppeteerDetails(details)
if (request.isMainFrame()) {
details.continue();
return;
}

const { redirect, match } = this.match(request);

if (redirect !== undefined) {
const { body, contentType } = redirect;
request.respond({
details.respond({
body,
contentType,
});
} else if (match === true) {
request.abort('blockedbyclient');
details.abort('blockedbyclient');
} else {
request.continue();
details.continue();
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/adblocker-puppeteer/package.json
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker-puppeteer",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker Puppeteer wrapper",
"author": {
"name": "Cliqz"
Expand Down Expand Up @@ -37,8 +37,8 @@
"puppeteer": "^1.18.1"
},
"dependencies": {
"@cliqz/adblocker": "^1.0.1",
"@cliqz/adblocker-content": "^1.0.1",
"@cliqz/adblocker": "^1.0.2",
"@cliqz/adblocker-content": "^1.0.2",
"@types/puppeteer": "^1.12.4",
"tldts-experimental": "^5.3.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker-webextension-cosmetics/package.json
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker-webextension-cosmetics",
"version": "1.0.1",
"version": "1.0.2",
"description": "Enable cosmetics in WebExtension content blocker using Cliqz adblocker",
"author": {
"name": "Cliqz"
Expand Down Expand Up @@ -84,6 +84,6 @@
"typescript": "^3.5.3"
},
"dependencies": {
"@cliqz/adblocker-content": "^1.0.1"
"@cliqz/adblocker-content": "^1.0.2"
}
}
6 changes: 3 additions & 3 deletions packages/adblocker-webextension-example/package.json
@@ -1,7 +1,7 @@
{
"name": "@cliqz/adblocker-webextension-example",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"description": "Example of WebExtension adblocker using Cliqz",
"author": {
"name": "Cliqz"
Expand Down Expand Up @@ -29,8 +29,8 @@
"url": "https://github.com/cliqz-oss/adblocker/issues"
},
"dependencies": {
"@cliqz/adblocker-webextension": "^1.0.1",
"@cliqz/adblocker-webextension-cosmetics": "^1.0.1"
"@cliqz/adblocker-webextension": "^1.0.2",
"@cliqz/adblocker-webextension-cosmetics": "^1.0.2"
},
"devDependencies": {
"@types/chrome": "^0.0.88",
Expand Down
4 changes: 4 additions & 0 deletions packages/adblocker-webextension/adblocker.ts
Expand Up @@ -97,6 +97,10 @@ export class WebExtensionBlocker extends FiltersEngine {
details: WebRequestBeforeRequestDetails,
): chrome.webRequest.BlockingResponse => {
const request = fromWebRequestDetails(details);
if (request.isMainFrame()) {
return {};
}

const { redirect, match } = this.match(request);

if (redirect !== undefined) {
Expand Down
6 changes: 3 additions & 3 deletions packages/adblocker-webextension/package.json
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker-webextension",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker WebExtension wrapper",
"author": {
"name": "Cliqz"
Expand Down Expand Up @@ -50,8 +50,8 @@
"typescript": "^3.5.3"
},
"dependencies": {
"@cliqz/adblocker": "^1.0.1",
"@cliqz/adblocker-content": "^1.0.1",
"@cliqz/adblocker": "^1.0.2",
"@cliqz/adblocker-content": "^1.0.2",
"tldts-experimental": "^5.3.0"
},
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker/package.json
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker library",
"author": {
"name": "Cliqz"
Expand Down

0 comments on commit 388c165

Please sign in to comment.