Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not block main document requests #312

Merged
merged 4 commits into from
Sep 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cliqz/adblocker",
"version": "1.0.1",
"version": "1.0.2",
"description": "Cliqz adblocker library",
"author": {
"name": "Cliqz"
Expand Down