NYTimes fix (#1040)

This commit is contained in:
Calvin Wu 2020-11-30 20:39:23 -05:00 committed by GitHub
parent e6addf4ee1
commit c23d1ea34c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,19 +262,15 @@ if (matchDomain('elmercurio.com')) {
} else if (matchDomain('nytimes.com')) {
const previewButton = document.querySelector('.css-3s1ce0');
if (previewButton) { previewButton.click(); }
// Prevent bottom dock from appearing
new window.MutationObserver(function (mutations) {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node instanceof window.HTMLElement) {
if (node.matches('.css-3fbowa')) {
removeDOMElement(node);
this.disconnect();
}
}
}
blockElement('.css-3fbowa'); // Prevent bottom dock from appearing
blockElement('#gateway-content'); // Remove paywall
blockElement('.css-1bd8bfl'); // Remove filter
// Restore scrolling
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
document.querySelector('.css-mcm29f').setAttribute('style', 'position:relative');
}
}).observe(document, { subtree: true, childList: true });
};
} else if (matchDomain('technologyreview.com')) {
window.setTimeout(function () {
const bodyObscured = document.querySelector('body[class*="body__obscureContent"]');
@ -514,6 +510,22 @@ function pageContains (selector, text) {
});
}
// Prevent element from being added to the DOM
function blockElement (selector) {
new window.MutationObserver(function (mutations) {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node instanceof window.HTMLElement) {
if (node.matches(selector)) {
removeDOMElement(node);
this.disconnect(); // Stop watching for element being added after one removal
}
}
}
}
}).observe(document, { subtree: true, childList: true });
}
function NZHerald () {
const video = document.querySelector('.video-js');
if (video) {