mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-18 09:28:15 +00:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
|
//"use strict";
|
||
|
|
||
|
if (matchDomain('nationalgeographic.com')) {
|
||
|
function natgeo_func(node) {
|
||
|
removeDOMElement(node);
|
||
|
let body = document.querySelector('body[class]');
|
||
|
if (body) {
|
||
|
body.removeAttribute('class');
|
||
|
body.removeAttribute('style');
|
||
|
}
|
||
|
}
|
||
|
waitDOMElement('div[id^="fittPortal"]', 'DIV', natgeo_func, false);
|
||
|
}
|
||
|
|
||
|
function matchDomain(domains, hostname) {
|
||
|
var matched_domain = false;
|
||
|
if (!hostname)
|
||
|
hostname = window.location.hostname;
|
||
|
if (typeof domains === 'string')
|
||
|
domains = [domains];
|
||
|
domains.some(domain => (hostname === domain || hostname.endsWith('.' + domain)) && (matched_domain = domain));
|
||
|
return matched_domain;
|
||
|
}
|
||
|
|
||
|
function removeDOMElement(...elements) {
|
||
|
for (let element of elements) {
|
||
|
if (element)
|
||
|
element.remove();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function waitDOMElement(selector, tagName = '', callback, multiple = false) {
|
||
|
new window.MutationObserver(function (mutations) {
|
||
|
for (let mutation of mutations) {
|
||
|
for (let node of mutation.addedNodes) {
|
||
|
if (!tagName || (node.tagName === tagName)) {
|
||
|
if (node.matches(selector)) {
|
||
|
callback(node);
|
||
|
if (!multiple)
|
||
|
this.disconnect();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}).observe(document, {
|
||
|
subtree: true,
|
||
|
childList: true
|
||
|
});
|
||
|
}
|