diff --git a/background.js b/background.js new file mode 100644 index 0000000..8fba098 --- /dev/null +++ b/background.js @@ -0,0 +1,44 @@ +function evadePaywalls(details) { + var reqHeaders = details.requestHeaders.filter(function(header) { + // drop cookies, referer and UA + if (header.name === "Cookie" || header.name === "Referer" || header.name === "User-Agent") { + return false; + } + + return true; + }) + + // Add the spoofed ones back + reqHeaders.push({ + "name": "Referer", + "value": "https://www.google.com/" + }) + reqHeaders.push({ + "name": "User-Agent", + "value": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" + }) + + return {requestHeaders: reqHeaders}; +} + +function blockCookies(details) { + var responseHeaders = details.responseHeaders.filter(function(header) { + if (header.name === "Cookie") { + return false; + } + + return true; + }) + + return {responseHeaders: responseHeaders}; +} + +chrome.webRequest.onBeforeSendHeaders.addListener(evadePaywalls, { + urls: [""], + types: ["main_frame"], +}, ["requestHeaders", "blocking"]); + +chrome.webRequest.onHeadersReceived.addListener(blockCookies, { + urls: [""], + types: ["main_frame"], +}, ["responseHeaders", "blocking"]); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..6ea4e8f --- /dev/null +++ b/manifest.json @@ -0,0 +1,66 @@ +{ + "name": "Anti-Paywall", + "version": "0.1", + "description": "This will prevent cookies from being stored, spoof the user-agent and mangle the referrer to maximize the chances of bypassing paywalls.", + "permissions": ["webRequest", "webRequestBlocking", + "*://*.adelaidenow.com.au/*", + "*://*.asia.nikkei.com/*", + "*://*.baltimoresun.com/*", + "*://*.barrons.com/*", + "*://*.bostonglobe.com/*", + "*://*.chicagobusiness.com/*", + "*://*.chicagotribune.com/*", + "*://*.courant.com/*", + "*://*.couriermail.com.au/*", + "*://*.cricketarchive.com/*", + "*://*.dailypress.com/*", + "*://*.economist.com/*", + "*://*.fd.nl/*", + "*://*.forbes.com/*", + "*://*.ft.com/*", + "*://*.geelongadvertiser.com.au/*", + "*://*.glassdoor.com/*", + "*://*.haaretz.co.il/*", + "*://*.haaretz.com/*", + "*://*.hbr.org/*", + "*://*.heraldsun.com.au/*", + "*://*.inc.com/*", + "*://*.independent.co.uk/*", + "*://*.investingdaily.com/*", + "*://*.irishtimes.com/*", + "*://*.latimes.com/*", + "*://*.letemps.ch/*", + "*://*.mcall.com/*", + "*://*.medscape.com/*", + "*://*.nationalpost.com/*", + "*://*.newsweek.com/*", + "*://*.newyorker.com/*", + "*://*.nnsl.com/*", + "*://*.nrc.nl/*", + "*://*.nytimes.com/*", + "*://*.ocregister.com/*", + "*://*.orlandosentinel.com/*", + "*://*.quora.com/*", + "*://*.scmp.com/*", + "*://*.seattletimes.com/*", + "*://*.smh.com.au/*", + "*://*.sun-sentinel.com/*", + "*://*.technologyreview.com/*", + "*://*.telegraph.co.uk/*", + "*://*.theage.com.au/*", + "*://*.theaustralian.com.au/*", + "*://*.theglobeandmail.com/*", + "*://*.thenation.com/*", + "*://*.thestreet.com/*", + "*://*.thesundaytimes.co.uk/*", + "*://*.thetimes.co.uk/*", + "*://*.volkskrant.nl/*", + "*://*.washingtonpost.com/*", + "*://*.wsj.com/*" + ], + "background": { + "scripts": ["background.js"] + }, + "manifest_version": 2 +} +