Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Paywall Removal
// ==UserScript==
// @name Paywall removal
// @namespace https://www.joshuapack.com
// @updateURL https://gist.githubusercontent.com/joshuapack/b13eadb53dee68a4ac40984439e8cc9b/raw/paywallremoval.user.js
// @downloadURL https://gist.githubusercontent.com/joshuapack/b13eadb53dee68a4ac40984439e8cc9b/raw/paywallremoval.user.js
// @version 0.1.16
// @description I hate paywalls
// @author Joshua Pack
// @match https://*.forbes.com/*
// @match https://*.latimes.com/*
// @match https://*.thewebflash.com/*
// @match https://*.charlotteobserver.com/*
// @match https://*.businessinsider.com/*
// @match https://*.usatoday.com/*
// @match https://*.kbb.com/*
// @match https://*.baltimoresun.com/*
// @match https://*.washingtonpost.com/*
// @match https://*.nytimes.com/*
// @match https://*.annistonstar.com/*
// @match https://*.wyomingnews.com/*
// @match https://*.victoriaadvocate.com/*
// @match https://*.heraldpalladium.com/*
// @match https://*.miamiherald.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
addJQuery(main);
function main(loopAmount) {
if (!loopAmount) loopAmount = 0;
loopAmount++;
if (loopAmount > 10) return;
var $ = window.jQ;
var currentHostname = window.location.hostname;
$(document).ready(function() {
// for https://www.forbes.com/
if (currentHostname == 'www.forbes.com' || currentHostname == 'forbes.com') {
$('#view-offer').hide();
$('.tp-modal').hide();
$('.tp-backdrop').hide();
$('body').removeClass('adblock-on');
$('body').removeClass('tp-modal-open');
}
// for https://www.latimes.com/
if (currentHostname == 'www.latimes.com' || currentHostname == 'latimes.com') {
$('.fc-ab-root').remove();
$('.met-flyout').hide();
$('body').css('overflow', 'auto');
$('metering-modal').hide();
}
// for https://www.thewebflash.com/
if (currentHostname == 'www.thewebflash.com' || currentHostname == 'thewebflash.com') {
$('html').removeClass('swal2-shown');
$('body').removeClass('swal2-shown');
$('.swal2-container').remove();
}
// for https://www.charlotteobserver.com/
if (currentHostname == 'www.charlotteobserver.com' || currentHostname == 'charlotteobserver.com') {
$('body').removeClass('paywalled');
$('body').css('overflow', 'auto');
$('.fc-ab-root').remove();
}
// for https://www.businessinsider.com/
if (currentHostname == 'www.businessinsider.com' || currentHostname == 'businessinsider.com') {
$('body').removeClass('tp-modal-slide-up');
$('body').removeClass('tp-modal-open');
$('.tp-modal').remove();
$('.tp-backdrop').remove();
// thanks cmlock for the catch
$('#piano-inline-content-wrapper').show();
}
// for https://www.usatoday.com/
if (currentHostname == 'www.usatoday.com' || currentHostname == 'usatoday.com') {
$('html').css('overflow-y', 'auto');
$('body').css('overflow-y', 'auto');
$("div[class^='sp_veil']").remove();
$("div[class^='sp_message_container']").remove();
}
// for https://www.kbb.com/
if (currentHostname == 'www.kbb.com' || currentHostname == 'kbb.com') {
$(".whitelist-overlay-modal-background").remove();
$('html').removeClass('whitelist-overlay-on');
}
// for https://www.baltimoresun.com/
if (currentHostname == 'www.baltimoresun.com' || currentHostname == 'baltimoresun.com') {
$('html').css('overflow', 'auto');
$('body').css('overflow', 'auto');
$(".meter-modal").remove();
$("#zephr-overlay").remove();
}
// for https://www.washingtonpost.com/
if (currentHostname == 'www.washingtonpost.com' || currentHostname == 'washingtonpost.com') {
$('.paywall-overlay').hide();
$('body').css('overflow', 'auto');
}
// for https://www.nytimes.com/
if (currentHostname == 'www.nytimes.com' || currentHostname == 'nytimes.com') {
$('#gateway-content').hide();
$('.css-1bd8bfl').hide();
$('.css-mcm29f').css('position', 'initial');
}
// for https://www.miamiherald.com/
if (currentHostname == 'www.miamiherald.com' || currentHostname == 'miamiherald.com') {
$('.fc-dialog-overlay').remove();
$('.fc-dialog-container').remove();
$('body').removeClass('paywalled');
$('html').css('overflow', 'auto');
$('body').css('overflow', 'auto');
}
// for any other possible websites with paywalls
// if you find any of these are causing issues, you can comment it out below
// or you can let me know and I can target specific websites instead
if ($('.redacted-overlay').length) {
$('#subscription-modal').remove();
$('.modal-backdrop').remove();
$('body').css('overflow', 'auto');
$('.redacted-overlay').hide();
$('.subscription-required').hide();
$('.subscriber-only').hide();
}
setTimeout(function() { main(loopAmount); }, 1000);
});
}
})();
@joshuapack

This comment has been minimized.

Copy link
Owner Author

@joshuapack joshuapack commented Mar 4, 2021

Use an extension like https://www.tampermonkey.net/

and install (by clicking on RAW above or here) or create a script and copy and paste this in.

Currently only works for the following sites:

  • Forbes
  • LA Times
  • The Web Flash
  • Charlotte Observer
  • Business Insider
  • USA Today
  • Kelly Blue Book
  • Baltimore Sun
  • Washington Post - Thanks vidpro2006
  • NY Times - Thanks vidpro2006
  • Anniston Star - Thanks vidpro2006
  • Wyoming News - Thanks vidpro2006
  • Victoria Advocate - Thanks vidpro2006
  • Herald Palladium - Thanks vidpro2006
  • Miami Herald

Let me know of other websites you'd like me to unblock. However, keep in mind, websites change, and this can stop working. I do not want this to become too popular. also, I do not have a bunch of time to work on it. Which is why this is a just a GIST at this time.

To update, you can use tampermonkey to check for updates automatically. usually set at once a day.

UPDATE: in version 0.1.10 I added a all URL in the include, however, it ran issues in other websites. so, I have removed it and added each website in the include in version 0.1.13.

@vidpro2006

This comment has been minimized.

Copy link

@vidpro2006 vidpro2006 commented Jun 24, 2021

Here are two more:

// for https://www.nytimes.com/
if (currentHostname == 'www.nytimes.com' || currentHostname == 'nytimes.com') {
    $('#gateway-content').hide();
    $('.css-1bd8bfl').hide();
    $('.css-mcm29f').css('position', 'initial');
}
// for https://www.washingtonpost.com/
 if (currentHostname == 'www.washingtonpost.com' || currentHostname == 'washingtonpost.com') {
	$('#paywall-us-620925cfd20').hide();
	$('body').css('overflow', 'auto');
 }
@joshuapack

This comment has been minimized.

Copy link
Owner Author

@joshuapack joshuapack commented Jun 24, 2021

@vidpro2006 Thanks I added washington post! I was unable to see any of the elements on nytimes.com. unsure if they changed, but I also was unable to get any paywall to come up. I did get the bottom thing every once in awhile, but I could just close it manually on screen. The classes you gave me look to be generated as well, which usually means it is different for every person.

@vidpro2006

This comment has been minimized.

Copy link

@vidpro2006 vidpro2006 commented Jun 24, 2021

@joshuapack, the nytimes is not a generated class, not sure why it didn't show but I have been using my own extension with that code for well over a year now and it does still work, google "css-mcm29f" and you will find a greasyfork link that talks about it.
"https://greasyfork.org/en/scripts/395019-the-new-york-times-paywall-bypass/code"

also here is another one that could use some clean up but it works for many local news papers such as annistonstar.com.

var genCheck = document.getElementsByClassName('redacted-overlay')[0]; if(genCheck !=undefined){
  modifyDOMgen();
}

    function modifyDOMgen() {
		document.querySelector('#subscription-modal').remove();
		document.querySelector('.modal-backdrop').remove();
		document.getElementsByTagName('body')[0].style.overflow ='auto';
		
		var x = document.getElementsByClassName('redacted-overlay');
		for (i = 0; i < x.length; i++) 
			{
				x[i].style = "display:none;";
			}
		
		var y = document.getElementsByClassName('subscription-required');
		for (i = 0; i < y.length; i++) 
			{
				y[i].style = "display:none;";
			}
		
		var z = document.getElementsByClassName('subscriber-only');
		for(var i = 0; i < z.length; i++)
			{
				 z[i].classList.remove('hide')
			}
			
		return;
	}


It will remove the nagging modal popup and both the redacted overly as well as un-hiding the article. It works on hundreds of local news paper sites:
annistonstar.com
wyomingnews.com/
victoriaadvocate.com
heraldpalladium
and hundreds more using that same subscription model

@joshuapack

This comment has been minimized.

Copy link
Owner Author

@joshuapack joshuapack commented Jul 6, 2021

also here is another one that could use some clean up but it works for many local news papers such as annistonstar.com.

It will remove the nagging modal popup and both the redacted overly as well as un-hiding the article. It works on hundreds of local news paper sites:
annistonstar.com
wyomingnews.com/
victoriaadvocate.com
heraldpalladium
and hundreds more using that same subscription model

@vidpro2006 I went ahead and added it and added a wild card to all domains, hopefully it don't break anything (having the wild card, lol) 0.0

I ended up removing the wild card on the domains. It was causing more issues on websites I don't want it running on. So, I'm going to limit it to the websites we find, which I have included all we have so far.

@cmlock

This comment has been minimized.

Copy link

@cmlock cmlock commented Jul 24, 2021

Nice script @joshuapack! I too hate paywalls... and it looks like Business Insider updated their site to also hide the original content. Add $('#piano-inline-content-wrapper').show(); as shown below to bring it back:

            // for https://www.businessinsider.com/
            if (currentHostname == 'www.businessinsider.com' || currentHostname == 'businessinsider.com') {
                $('body').removeClass('tp-modal-slide-up');
                $('body').removeClass('tp-modal-open');
                $('.tp-modal').remove();
                $('.tp-backdrop').remove();
                $('#piano-inline-content-wrapper').show();
            }

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment