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

Merge latest #2

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
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
56 changes: 45 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@

## Make WSJ & NYTimes Great Again:

#### Get around the paywall for many Wall Street Journal, New York Times and Financial Times content
#### Get around the paywalls for Wall Street Journal, New York Times, Financial Times and Bloomberg.
#### Now support [Firefox](#install-instructions-for-firefox) and [Microsoft Edge](#install-instructions-for-microsoft-edge).

### Supported Websites:
* [Wall Street Journal](https://www.wsj.com/)
* [New York Times](https://www.nytimes.com/)
* [Financial Times](https://www.ft.com/)
* [Bloomberg](https://www.bloomberg.com/)
* [Washington Post](https://www.washingtonpost.com)
* [Business Journals](https://www.bizjournals.com/)
* [Philly.com](https://www.philly.com/)
* [Kleine Zeitung](http://www.kleinezeitung.at/)
* [The Globe and Mail](https://www.theglobeandmail.com/)
* [New York Daily News](http://www.nydailynews.com/)

### Update in Jan 2018:
* Thank [Scratch](https://github.com/Scrxtchy) for adding Firefox and Edge support of this extension! See [this pull request](https://github.com/njuljsong/wsjUnblock/pull/25) for details. Also add [`kleinezeitung.at`](https://github.com/njuljsong/wsjUnblock/pull/22), [`bizjournals.com`](https://github.com/njuljsong/wsjUnblock/pull/14), [`theglobeandmail.com`](https://github.com/njuljsong/wsjUnblock/pull/26) and `philly.com`

### Update in Oct 2017:
* Thank [hotcap](https://github.com/hotcap) for adding [Washington Post](https://www.washingtonpost.com) to our list. See [this pull request](https://github.com/njuljsong/wsjUnblock/pull/7) for details.

### Update in Aug 2017:
* Thank [apank](https://github.com/apank) for adding [Bloomberg](https://www.bloomberg.com/businessweek) to our list.
* Thank [strafer](https://github.com/strafer) for creating an issue that [New York Times Cooking section](https://cooking.nytimes.com/) has separate paywall. We fixed it by just injecting CSS to the pages to hide the pop up dialog and still keep JavaScript working as expected. See [this pull request](https://github.com/njuljsong/wsjUnblock/pull/3) for details.

### Update in Apr 2017:
* **Fact**: WSJ has an advertisement popping up *every single time* we read an article, too much!
Expand Down Expand Up @@ -31,20 +54,31 @@

* **Idea**: Block those Javascript files from downloading :)

* **Sugggestion For NYTimes Developers**: concatenate the minified Javascript files, and maybe attach a random string in your concatenated Javascript filename?
* **Suggestion For NYTimes Developers**: concatenate the minified Javascript files, and maybe attach a random string in your concatenated Javascript filename?

#### Interested in development process?
* I wrote a blog [How to bypass WSJ and NYTimes paywalls?](http://blog.jinsongli.com/) about the details on my website.


### Install Instructions
* click "clone or download", download zip. The downloaded file is an unpacked chrome extension, unzip it into a directory.
* Visit `chrome://extensions` (via omnibox or menu -> Tools -> Extensions).
* Enable Developer mode by ticking the checkbox in the upper-right corner.
* Click on the "Load unpacked extension..." button.
* Select the directory containing your *unpacked* extension.
* Reference: [How to install an unpacked chrome extension](http://stackoverflow.com/questions/24577024/install-chrome-extension-not-in-the-store/24577660#24577660)

### Want to contribute?
* You are welcome to use the same logic to get around sites you are interested in, if it works, submit a Pull Request, and I'd love to merge it. Thank you!

### Install Instructions for Chrome
* click "clone or download", download zip. The downloaded file is an unpacked chrome extension, unzip it into a directory.
* Visit `chrome://extensions` (via omnibox or menu -> Tools -> Extensions).
* Enable Developer mode by ticking the checkbox in the upper-right corner.
* Click on the "Load unpacked extension..." button.
* Select the directory containing your *unpacked* extension.
* Reference: [How to install an unpacked chrome extension](http://stackoverflow.com/questions/24577024/install-chrome-extension-not-in-the-store/24577660#24577660)

### Install Instructions for Firefox
* Open Firefox
* Enter "about:debugging" in the URL bar
* Click "Load Temporary Add-on"
* Open the extension's directory and select `manifest.json` inside the extension.
* Read [Temporary installation in Firefox](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Temporary_Installation_in_Firefox) For details.

### Install Instructions for Microsoft Edge
* Read [Adding, moving, and removing extensions for Microsoft Edge](https://docs.microsoft.com/en-us/microsoft-edge/extensions/guides/adding-and-removing-extensions)

### License
This is free and unencumbered software released into the public domain.
Expand Down
29 changes: 29 additions & 0 deletions css/nyt.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Note about why we need to override these attributes
*
* there is this class on html and body:
* .nytc---modal-window---noScroll {
* height: 100%;
* overflow: hidden;
* position: relative;
* };
*
* It causes issues:
* 1: unable to scroll
* So we need to override `overflow` to make page scrollable.
* [ref](https://davidwalsh.name/prevent-body-scrolling)
* 2: images should be lazyloaded but are not loaded at all
* I just accidently find it out that removing this `height: 100%` will restore javascript's
* functionality to lazyload images, so we are all set!
*/
html {
height: auto !important;
overflow: scroll !important;
}

/**
* We do not want to see the pop up for signup, so just hide it
*/
#app-container div[role=dialog] {
display: none !important;
}
31 changes: 27 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "Make WSJ & NYT Great Again",
"version": "0.2",
"version": "0.4",
"manifest_version": 2,
"description": "Get around the paywall for many WSJ, NYT & FT content",
"author": "Jinsong Li",
"homepage_url": "http://blog.jinsongli.com",
"icons": {
"48": "icons/eric_cartman.png"
Expand All @@ -13,6 +14,12 @@
],
"persistent": true
},
"content_scripts": [
{
"matches": ["https://cooking.nytimes.com/*"],
"css" : ["css/nyt.css"]
}
],
"permissions": [
"webRequest",
"webRequestBlocking",
Expand All @@ -24,6 +31,22 @@
"https://*.nytimes.com/*",
"http://*.nytimes.com/*",
"https://*.nyt.com/*",
"http://*.nyt.com/*"
]
}
"http://*.nyt.com/*",
"https://*.bloomberg.com/*",
"http://*.bloomberg.com/*",
"https://*.bwbx.io/*",
"http://*.bwbx.io/*",
"https://*.washingtonpost.com/*",
"http://*.washingtonpost.com/*",
"http://*.philly.com/*",
"https://*.bizjournals.com/*",
"http://*.bizjournals.com/*",
"http://www.kleinezeitung.at/*",
"https://*.theglobeandmail.com/*",
"http://*.theglobeandmail.com/*",
"https://*.nydailynews.com/*",
"http://*.nydailynews.com/*",
"https://*.tribdss.com/*",
"http://*.tribdss.com/*"
]
}
87 changes: 70 additions & 17 deletions src/bg/background.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

// new http header parameters to override
var newHeader = {
const newHeader = {
referer: {
name: "Referer",
value: "https://www.twitter.com", // or "https://www.facebook.com"
value: "https://www.facebook.com", // or "https://www.twitter.com"
},
cookie: {
name: "Cookie",
Expand All @@ -16,52 +16,105 @@ var newHeader = {
};

// sites that we want to access
var sites = {
const sites = {
washingtonpost: {
js: [
"*://*.washingtonpost.com/*pwapi/*.js*", // this one causes paywall/ad-wall lightbox for every article
"*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*", // this one causes paywall/ad-wall lightbox sometimes with Adblock Plus enabled
]
},
wsj: {
url: "*://*.wsj.com/*",
js: "*://*/*cxense-candy.js" // this one causing a pop up advertisement for every article
js: [
"*://*/*cxense-candy.js", // this one causes a pop up advertisement for every article
]
},
ft: {
url: "*://*.ft.com/*",
},
nyt: {
js: "*://*.com/*mtr.js" // this one causing a pop up asking for subscription
js: [
"*://*.com/*mtr.js", // this one causes a pop up asking for subscription
]
},
bloomberg: {
url: "*://*.bloomberg.com/*",
js: [
"*://*.bwbx.io/s3/javelin/public/javelin/js/pianola/*",
]
},
bizjournals: {
url: "*://*.bizjournals.com/*",
js: [
"*://*.bizjournals.com/dist/js/article.min.js*"
]
},
philly: {
url: "*://*.philly.com/*",
},
kleinezeitung: {
url: "*://*.kleinezeitung.at/*",
},
globeandmail: {
js: [
"*://*.theglobeandmail.com/pb/gr/c/default/*/story-bundle/*.js*"
]
},
nydailynews: {
url: "*://*.nydailynews.com/*",
js: [
"*://*.tribdss.com/reg/tribune/*"
]
}
};

chrome.webRequest.onBeforeRequest.addListener(
// extract all script urls we want to block
var script_urls = Object.values(sites)
.map(site => site.js)
.filter(Array.isArray)
.reduce((prev, curr) => prev.concat(curr), []);

// extract all main_frame urls we want to override
var main_frame_urls = Object.values(sites)
.map(site => site.url)
.filter(url => url);

// add Firefox and Edge support with the global `browser` object
browser = typeof browser !== "undefined" ? browser : chrome;

browser.webRequest.onBeforeRequest.addListener(
function() {
console.log( "we are going to block some low energy javascripts" );
console.log("we are going to block some low energy javascripts");

return { cancel: true };
}, {
urls: [ sites.nyt.js, sites.wsj.js ],
urls: script_urls,
// target is script
types: [ "script" ]
},
[ "blocking" ]
);

chrome.webRequest.onBeforeSendHeaders.addListener(
function( details ) {
console.log( "we are going to override some request headers" );
browser.webRequest.onBeforeSendHeaders.addListener(
function(details) {
console.log("we are going to override some request headers");

// remove existing referer and cookie
for ( var i = 0; i < details.requestHeaders.length; i++) {
if ( details.requestHeaders[i].name === newHeader.referer.name || details.requestHeaders[i].name === newHeader.cookie.name ) {
for (let i = 0; i < details.requestHeaders.length; i++) {
if (details.requestHeaders[i].name === newHeader.referer.name || details.requestHeaders[i].name === newHeader.cookie.name) {
details.requestHeaders.splice(i, 1);
i--;
}
}

// add new referer
details.requestHeaders.push( newHeader.referer );
details.requestHeaders.push(newHeader.referer);
// remove cache
details.requestHeaders.push( newHeader.cachecontrol );
details.requestHeaders.push(newHeader.cachecontrol);

return { requestHeaders: details.requestHeaders };
}, {
urls: [ sites.wsj.url, sites.ft.url ],
urls: main_frame_urls,
// target is the document that is loaded for a top-level frame
types: [ "main_frame" ]
},
Expand Down