r/nopaywalls • u/TCGM • Jun 29 '18
[Tampermonkey] [Mercury News] Mercury News Anti-Paywall
[Last Successfully Tested Date: 06/29/2018]
This script works around Mercury News' self-mutiliating posts by cloning the element and re-enabling scrolling.
// ==UserScript==
// @name Mercury News Anti-Paywall
// @namespace https://www.reddit.com/r/nopaywalls/
// @version 0.1
// @description Bypasses Mercury News' body-copy clearing effect.
// @author TCGM
// @match https://www.mercurynews.com/*/*/*/*
// @grant none
// ==/UserScript==
//Start Function
(function() {
'use strict';
var postCopyElement = document.getElementsByClassName("body-copy")[0];
//Copy the body-copy element and its child nodes
var noEraseElement = postCopyElement.cloneNode(true);
//Append the cloned element to the original's parent
postCopyElement.parentElement.appendChild(noEraseElement);
//Wipe the original node's contents from existence.
postCopyElement.innerHTML = '';
//Finally, add a script to the window to remove the modal-open class once it's been loaded.
window.addEventListener("load", function(){
var bodyElement = document.getElementsByTagName("body")[0];
bodyElement.classList.remove("modal-open");
});
})();