Skip to content

Instantly share code, notes, and snippets.

@joshuapack
Last active March 29, 2022 15:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuapack/b13eadb53dee68a4ac40984439e8cc9b to your computer and use it in GitHub Desktop.
Save joshuapack/b13eadb53dee68a4ac40984439e8cc9b to your computer and use it in GitHub Desktop.
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.18
// @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/*
// @match https://*.metro.co.uk/*
// @match https://*.telegraph.co.uk/*
// @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() {
let articleBody = '';
// 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 https://metro.co.uk/
if (currentHostname == 'www.metro.co.uk' || currentHostname == 'metro.co.uk') {
$('[class*=overlay-]').remove();
$('[class*=wrapper-]').remove();
$('body').removeClass('mol-fe-ab-dialog');
}
// for https://telegraph.co.uk/
if (currentHostname == 'www.telegraph.co.uk' || currentHostname == 'telegraph.co.uk') {
$('.martech-modal-component-overlay').remove();
$('html').removeClass('martech-overlay-not-visible articleRendererHTML logged-in--false is-subscriber--false app-tmg-subscriber--false');
$('html').attr("style","overflow-y:auto !important");
}
// 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);
});
}
})();
@cmlock
Copy link

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