working settings

This commit is contained in:
tobimori 2020-04-03 22:35:03 +02:00
parent 542045518a
commit f435e5544e
14 changed files with 184 additions and 85 deletions

View File

@ -11,6 +11,7 @@
// block all celeraone tracking scripts by dumont
extapi.webRequest.onBeforeRequest.addListener(
function(details) {
if(isSiteEnabled(details.url))
return {cancel: true};
}, {
urls: [

View File

@ -8,8 +8,14 @@
// github.com/tobimori/paywallr
//
if (d.getElementsByClassName("content-behind-wall hide-paid-content")[0]) {
removeElements(d.getElementsByClassName("ssoTemplate pay wall"), d.getElementsByClassName("logo title backToLandingPage"));
d.getElementById('c1-template-platzhalter').remove();
d.getElementsByClassName("content-behind-wall hide-paid-content")[0].classList.remove("hide-paid-content")
};
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
if (isSiteEnabled(window.location.href) && d.getElementsByClassName("content-behind-wall hide-paid-content")[0]) {
removeElements(d.getElementsByClassName("ssoTemplate pay wall"), d.getElementsByClassName("logo title backToLandingPage"));
d.getElementById('c1-template-platzhalter').remove();
d.getElementsByClassName("content-behind-wall hide-paid-content")[0].classList.remove("hide-paid-content")
};
}
);

View File

@ -8,37 +8,43 @@
// github.com/tobimori/paywallr
//
let isPaidContent; // check if article is paid content
[...d.getElementsByTagName("script")].forEach(e => {
if(e.innerText == "\n (window.isPaidContent = true);\n") isPaidContent = true
});
if (isPaidContent) {
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
const mReq = new XMLHttpRequest();
const oUrl = new URL(window.location.href);
const mUrl = new URL(oUrl.pathname, "https://m.faz.net/");
const downloadDone = (e) => {
d.getElementsByClassName("atc-ReadTime_Text")[0].innerText = "unlocked by paywallr";
d.getElementsByClassName("atc-TextParagraph")[0].innerText = JSON.parse(mReq.response.getElementById("schemaOrgJson").innerHTML).ArticleBody;
console.log(window.isPaidContent);
};
mReq.addEventListener("load", downloadDone);
mReq.open("GET", mUrl.href);
mReq.responseType = "document";
mReq.send();
removeElements(
d.getElementsByClassName("js-atc-ContainerPaywall atc-ContainerPaywall"), // Paywall ad
d.getElementsByClassName("atc-ContainerInfo js-atc-ContainerInfo"), // Author information
d.getElementsByClassName("o-Icon atc-ReadTime_Icon"), // Reading time icon
d.getElementsByClassName("atc-TextParagraph") // paragraphs
);
d.getElementsByClassName("atc-Text js-atc-Text")[0].innerHTML = '<p class="atc-TextParagraph">Unlocking...</p>'
d.getElementsByClassName("atc-ReadTime_Text")[0].innerText = "Unlocking..."
};
let isPaidContent; // check if article is paid content
[...d.getElementsByTagName("script")].forEach(e => {
if (e.innerText == "\n (window.isPaidContent = true);\n") isPaidContent = true
});
if (isSiteEnabled(window.location.href) && isPaidContent) {
const mReq = new XMLHttpRequest();
const oUrl = new URL(window.location.href);
const mUrl = new URL(oUrl.pathname, "https://m.faz.net/");
const downloadDone = (e) => {
d.getElementsByClassName("atc-ReadTime_Text")[0].innerText = "unlocked by paywallr";
d.getElementsByClassName("atc-TextParagraph")[0].innerText = JSON.parse(mReq.response.getElementById("schemaOrgJson").innerHTML).ArticleBody;
console.log(window.isPaidContent);
};
mReq.addEventListener("load", downloadDone);
mReq.open("GET", mUrl.href);
mReq.responseType = "document";
mReq.send();
removeElements(
d.getElementsByClassName("js-atc-ContainerPaywall atc-ContainerPaywall"), // Paywall ad
d.getElementsByClassName("atc-ContainerInfo js-atc-ContainerInfo"), // Author information
d.getElementsByClassName("o-Icon atc-ReadTime_Icon"), // Reading time icon
d.getElementsByClassName("atc-TextParagraph") // paragraphs
);
d.getElementsByClassName("atc-Text js-atc-Text")[0].innerHTML = '<p class="atc-TextParagraph">Unlocking...</p>'
d.getElementsByClassName("atc-ReadTime_Text")[0].innerText = "Unlocking..."
};
}
);

View File

@ -8,7 +8,13 @@
// github.com/tobimori/paywallr
//
if(d.getElementById("paywall-form-container-outer")) {
d.getElementById("paywall-form-container-outer").remove();
d.getElementsByClassName("article_text paywall")[0].innerHTML = '<p class="First">' + JSON.parse(d.getElementById("schemaOrgJson").innerHTML).ArticleBody + '</p>'
};
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
if (isSiteEnabled(window.location.href) && d.getElementById("paywall-form-container-outer")) {
d.getElementById("paywall-form-container-outer").remove();
d.getElementsByClassName("article_text paywall")[0].innerHTML = '<p class="First">' + JSON.parse(d.getElementById("schemaOrgJson").innerHTML).ArticleBody + '</p>'
};
}
);

View File

@ -14,6 +14,12 @@ const deobfuscateLaterpay = (s) => {
"ABCDEFGHIJKLMNOPQRSTUVWXYZÅÝÀ[abcdefghijklmnopqrstuvwxyzåý÷à{-/.;=?0)*".indexOf(c)]);
};
[...d.getElementsByClassName("obfuscated")].forEach(a =>
a.innerText = deobfuscateLaterpay(a.innerText)
);
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
isSiteEnabled(window.location.href) && [...d.getElementsByClassName("obfuscated")].forEach(a =>
a.innerText = deobfuscateLaterpay(a.innerText)
);
}
);

View File

@ -16,9 +16,14 @@ const observer = new MutationObserver(function (mutations, me) {
[...d.getElementsByTagName("meta")].map(n => n.getAttribute("property") == "laterpay:connector:config_token" && n.remove());
});
// check if article is locked, then start the observer
d.getElementsByClassName("vrm-premium") &&
observer.observe(d, {
childList: true,
subtree: true
});
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
isSiteEnabled(window.location.href) && d.getElementsByClassName("vrm-premium") &&
observer.observe(d, {
childList: true,
subtree: true
});
}
);

View File

@ -12,4 +12,13 @@
//
// removes blur from content
d.getElementById("BaseText").classList.contains("PianoContent") && d.getElementById("BaseText").classList.remove("PianoContent");
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
if (isSiteEnabled(window.location.href) && d.getElementsByClassName("pdb-article-paidcontent-registration")) {
d.getElementById("BaseText").classList.contains("PianoContent") && d.getElementById("BaseText").classList.remove("PianoContent");
};
}
);

View File

@ -8,15 +8,21 @@
// github.com/tobimori/paywallr
//
if (isSiteEnabled(window.location.href) && d.getElementsByClassName("pdb-article-paidcontent-registration")) {
d.getElementsByClassName("pdb-article-body-paidcontentintro")[0].classList.remove("pdb-article-body-paidcontentintro")
// throws an error in chrome, but important and works.
d.getElementsByClassName("pdb-richtext-field")[1].innerHTML = "<p>" + JSON.parse(d.getElementsByClassName("pdb-article")[0].getElementsByTagName("script")[0].innerHTML).articleBody + "</p>";
removeElements(d.getElementsByClassName("pdb-article-paidcontent-registration"));
[...d.getElementsByClassName("pdb-parts-paidcontent-freeuntilbadge pdb-parts-paidcontent-freeuntilbadge_article pdb-parts-paidcontent-freeuntilbadge_close")].
map(n =>
n.classList.remove("pdb-parts-paidcontent-freeuntilbadge_close") +
n.classList.add("pdb-parts-paidcontent-freeuntilbadge_open") +
n.appendChild(d.createTextNode("- unlocked by paywallr"))
);
};
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
if (isSiteEnabled(window.location.href) && d.getElementsByClassName("pdb-article-paidcontent-registration")) {
d.getElementsByClassName("pdb-article-body-paidcontentintro")[0].classList.remove("pdb-article-body-paidcontentintro")
// throws an error in chrome, but important and works.
d.getElementsByClassName("pdb-richtext-field")[1].innerHTML = "<p>" + JSON.parse(d.getElementsByClassName("pdb-article")[0].getElementsByTagName("script")[0].innerHTML).articleBody + "</p>";
removeElements(d.getElementsByClassName("pdb-article-paidcontent-registration"));
[...d.getElementsByClassName("pdb-parts-paidcontent-freeuntilbadge pdb-parts-paidcontent-freeuntilbadge_article pdb-parts-paidcontent-freeuntilbadge_close")].
map(n =>
n.classList.remove("pdb-parts-paidcontent-freeuntilbadge_close") +
n.classList.add("pdb-parts-paidcontent-freeuntilbadge_open") +
n.appendChild(d.createTextNode("- unlocked by paywallr"))
);
};
}
);

View File

@ -8,4 +8,12 @@
// github.com/tobimori/paywallr
//
d.getElementById("park-webtrekk-paywall-hook").remove();
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
if (isSiteEnabled(window.location.href)) {
d.getElementById("park-webtrekk-paywall-hook").remove();
};
}
);

View File

@ -9,4 +9,12 @@
// github.com/tobimori/paywallr
//
removeElements(d.getElementsByClassName("cleanslate"));
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
if (isSiteEnabled(window.location.href)) {
removeElements(d.getElementsByClassName("cleanslate"));
};
}
);

View File

@ -11,8 +11,16 @@
// can't be replaced !!!
//
removeElements(d.getElementsByClassName("steady-overlay"));
d.getElementsByClassName("ph-article-flag-description")[0].innerText = "unlocked by paywallr";
const s = d.createElement('style')
s.innerHTML = ".ph-article-full {max-height: 100% !important;}";
d.body.appendChild(s);
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON LOAD - DISABLED SITES: " + disabledSites);
if (isSiteEnabled(window.location.href)) {
removeElements(d.getElementsByClassName("steady-overlay"));
d.getElementsByClassName("ph-article-flag-description")[0].innerText = "unlocked by paywallr";
const s = d.createElement('style')
s.innerHTML = ".ph-article-full {max-height: 100% !important;}";
d.body.appendChild(s);
};
}
);

View File

@ -74,7 +74,7 @@
"*://*.ostsee-zeitung.de/*",
"*://*.paz-online.de/*",
"*://*.sn-online.de/*"],
"js": ["sites.js", "settingslib.js", "lib.js", "components/madsack.js"],
"js": ["lib.js", "sites.js", "settingslib.js", "components/madsack.js"],
"run_at": "document_end"
}, {
"matches": [

View File

@ -8,7 +8,21 @@
// github.com/tobimori/paywallr
//
extapi.storage.sync.get({ sitesDisabled: [] },
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON START - DISABLED SITES: " + disabledSites);
}
);
extapi.storage.onChanged.addListener(() => {
extapi.storage.sync.get({sitesDisabled: []},
(stor) => {
disabledSites = Array.from(stor["sitesDisabled"]);
console.log("ON CHANGE - DISABLED SITES: " + disabledSites);
}
);
});
extapi.tabs.onUpdated.addListener(() => {
extapi.tabs.query({
@ -28,40 +42,59 @@ extapi.tabs.onUpdated.addListener(() => {
)
});
extapi.tabs.onActivated.addListener(console.log("gay"));
extapi.tabs.onActivated.addListener(() => {
extapi.tabs.query({
active: true,
currentWindow: true
}, (tab) => {
extapi.browserAction.setBadgeBackgroundColor({ "color": "black" });
!isSite(tab[0].url) && extapi.browserAction.disable(tab[0].id);
isSite(tab[0].url) && isSiteEnabled(tab[0].url) ?
extapi.browserAction.setBadgeText({
"text": "ON", "tabId": tab[0].id
}) :
extapi.browserAction.setBadgeText({
"text": "OFF", "tabId": tab[0].id
});
}
)
});
extapi.browserAction.onClicked.addListener((tab) => {
isEnabled = isSiteEnabled(tab.url);
console.log(isEnabled);
if (isSite(tab.url) && isEnabled) {
if(isSite(tab.url)) isEnabled = isSiteEnabled(tab.url);
isEnabled ?
extapi.storage.sync.get("sitesDisabled",
(stored) => {
if (!stored["sitesDisabled"]) stored["sitesDisabled"] = [];
let sites = Array.from(stored["sitesDisabled"]);
console.log(sites);
sites.push(shortUrl(tab.url));
console.log(sites);
extapi.storage.sync.set({
sitesDisabled: sites
});
disabledSites = sites;
extapi.browserAction.setBadgeText({
"text": "OFF", "tabId": tab.id
});
console.log("Disabled site: " + tab.url);
extapi.tabs.reload(tab.id);
}
);
} else if (isSite(tab.url) && !isEnabled) {
)
:
extapi.storage.sync.get("sitesDisabled",
(stored) => {
if (!stored["sitesDisabled"]) stored["sitesDisabled"] = [];
let sites = Array.from(stored["sitesDisabled"]);
sites.splice(shortUrl(tab.url));
extapi.storage.sync.set({
sitesDisabled: sites
});
disabledSites = sites;
extapi.browserAction.setBadgeText({
"text": "ON", "tabId": tab.id
});
console.log("Enabled site: " + tab.url);
extapi.tabs.reload(tab.id);
}
);
};
;
});

View File

@ -8,19 +8,16 @@
// github.com/tobimori/paywallr
//
let disabledSites = [];
const isSite = (fullUrl) => {
if (!fullUrl) return false;
return sites.includes(shortUrl(fullUrl));
};
const isSiteEnabled = (fullUrl) => {
return true;
if (!fullUrl) return false;
extapi.storage.sync.get({sitesDisabled: []},
(stor) => {
let arr = Array.from(stor["sitesDisabled"]);
return !arr.includes(shortUrl(fullUrl));
}
);
console.log(disabledSites);
return !disabledSites.includes(shortUrl(fullUrl));
};