genevera000 / Adblock block/Paywall Remover

// ==UserScript==
// @name        Adblock block/Paywall Remover
// @description Removes the adblock block and paywall from various sites
// @license     MIT
// @include     http://foreignpolicy.com/*
// @include     https://foreignpolicy.com/*
// @include     http://www.businessinsider.com/*
// @include     https://www.wired.com/*
// @include     https://www.kbb.com/*
// @include     https://www.washingtonpost.com/*
// @include     http://www.slate.com/*
// @include     http://www.nytimes.com/*
// @include     https://www.nytimes.com/*
// @include     https://mobile.nytimes.com/*
// @include     http://www.latimes.com/*
// @include     http://www.startribune.com/*
// @include     http://www.allmusic.com/*
// @include     https://www.thedailybeast.com/*
// @include     http://gizmodo.com/*
// @include     http://io9.gizmodo.com/*
// @include     http://kotaku.com/*
// @include     http://deadspin.com/*
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @require     https://gist.github.com/raw/2625891/waitForKeyElements.js
// @version     1
// @grant       none
// ==/UserScript==

var contentPreserve = false;
var url = window.location.href;
if (url.includes('slate.com')) {
    contentPreserve = jQuery('section.content');
    if (contentPreserve.length > 0) {
        contentPreserve = jQuery(contentPreserve[0]).clone();
    }
} else if (url.includes('wired.com')) {
    /*contentPreserve = jQuery('section.post-container');
    if (contentPreserve.length > 0) {
        contentPreserve = jQuery(contentPreserve[0]).clone();
    }*/
} else if (url.includes('nytimes.com')) {
    /*contentPreserve = jQuery('article#story');
    if (contentPreserve.length > 0) {
        contentPreserve = jQuery(contentPreserve[0]).clone();
    }*/
}

jQuery(document).ready(function(e){
    if (url.includes('foreignpolicy.com')) {
        waitForKeyElements ("#TB_overlay, #TB_window, .js-takeover, #paywall_bg, div.paywall_counter", function(element){
            jQuery(element).hide();
            jQuery('html, body').css('overflowY', 'auto');
        });
    } else if (url.includes('businessinsider.com')) {
        waitForKeyElements (".tp-modal, .tp-active", function(element){
             jQuery(element).hide();
             jQuery('html, body').removeClass('tp-modal-open');
        });
    } else if (url.includes('wired.com')) {
        waitForKeyElements ('div.sponsored-stories-component, div.mediavoice-native-ad, div.advertisement__leaderboard:visible, div.cns-ads-stage:visible', function(element) {
            jQuery(element).hide();
        });
        waitForKeyElements ('.paywall-container-component', function(element) {
            jQuery(element).hide();
        });
    } else if (url.includes('kbb.com')) {
        waitForKeyElements ('div#WhitelistOverlayModalBackground:visible', function(element) {
            jQuery(element).hide();
            jQuery('html').removeClass('whitelist-overlay-on');
        });
    } else if (url.includes('washingtonpost.com')) {
        waitForKeyElements ('div.wp_signin', function(element) {        
            jQuery(element).hide();
            jQuery('#wp_Signin').hide();
            jQuery('html, body').css('overflowY', 'auto');
        });
        waitForKeyElements ('img.unprocessed.placeholder', function(element) {
            var img = jQuery(element);
            img.attr('src', img.attr('data-raw-src'));
            img.removeClass('unprocessed placeholder');
        });
    } else if (url.includes('slate.com')) {
        waitForKeyElements ('div#roadblock:visible', function(element) {        
            jQuery(element).hide();
            //jQuery('section.content').css('height', 'auto');
            jQuery('section.content').replaceWith(contentPreserve);
            jQuery('body').removeClass('roadblock');
        });
    } else if (url.includes('nytimes.com')) {
        jQuery(element).hide();
        var el = document.getElementById('gateway-content').previousElementSibling.children[2].removeAttribute("class");
        document.getElementById('site-content').parentElement.parentElement.removeAttribute("class");
    } else if (url.includes('latimes.com')) {
        waitForKeyElements ('div#reg-overlay', function(element) {        
            jQuery(element).remove();
            jQuery('html').removeAttr('data-dss-meterup');
            jQuery('html').removeAttr('data-ssor-modalup');
            jQuery('div.trb_allContentWrapper').removeClass('trb_allContentWrapper');//.css('overflowY', 'auto');
            //jQuery('.trb_allContentWrapper').removeClass('trb_allContentWrapper');
            //jQUery('.trb_allContentWrapper').css('overflowY', 'auto');
            //jQuery(element).hide();
            //jQuery('div.cointent_modal_dark').hide();
            //jQuery('body').removeClass('cointent_modal_dark_open');
        });
    } else if (url.includes('startribune.com')) {
        waitForKeyElements ('aside.o-modal-wrapper', function(element) {        
            jQuery(element).remove();
            jQuery('html, body').css('overflowY', 'auto');
        });
        waitForKeyElements ('#fly-in', function(element) {        
            jQuery(element).remove();
            jQuery('html, body').css('overflowY', 'auto');
        });
        
        waitForKeyElements ('div.o-overlay:visible', function(element) {        
            jQuery(element).remove();
            jQuery('html, body').css('overflowY', 'auto');
        });
    } else if (url.includes('allmusic.com')) {
        waitForKeyElements ('body.locked', function(element) {        
            jQuery(element).removeClass('locked');
        });
        waitForKeyElements ('div:contains("Continue After Disabling Ad Blocker"):visible', function(element) {        
            jQuery(element).parent().hide();
            //jQuery('html, body').css('overflowY', 'auto');
        });
    } else if (url.includes('thedailybeast.com')) {
        //jQuery('h4.Rubric--sponsored').closest('div.ArticleSidebarWrapper').hide()
        waitForKeyElements ('h4.Rubric--sponsored', function(element) {        
            jQuery(element).closest('div.ArticleSidebarWrapper').hide();
        });
        waitForKeyElements ('a.ReadThisListItem--sponsored', function(element) {        
            jQuery(element).hide();
        });
        jQuery('li.CheatSheetItem--sponsored').hide();
        waitForKeyElements ('li.CheatSheetItem--sponsored', function(element) {
            jQuery(element).hide();
        });
        jQuery('h4.CheatsheetListItem__presented-by').closest('li').hide();
        waitForKeyElements ('h4.CheatsheetListItem__presented-by', function(element) {
            jQuery(element).closest('li').hide();
        });
    } else if (url.includes('gizmodo.com') || url.includes('kotaku.com') || url.includes('deadspin.com')) {
        
        waitForKeyElements ('div.mezzanine:visible', function(element) {        
            jQuery(element).hide();
        });
        waitForKeyElements ('div#taboola-promotion-sidebar-abp, div.taboola-instream-wrapper, section.js_taboola-region', function(element) {        
            jQuery(element).hide();
        });
    } 
});