Atualiza GauchaZH

master
Augusto Resende 2017-11-07 10:45:39 -03:00
parent a08c3baa8c
commit a95e0bef50
4 changed files with 49 additions and 60 deletions

View File

@ -43,7 +43,10 @@ chrome.webRequest.onBeforeRequest.addListener(
"*://cdn.tinypass.com/api/tinypass.min.js",
// UOL
"*://tm.jsuol.com.br/modules/content-gate.js"
"*://tm.jsuol.com.br/modules/content-gate.js",
// GauchaZH
"*://gauchazh.clicrbs.com.br/static/main*"
],
types: ["script"]
},
@ -101,16 +104,12 @@ chrome.webRequest.onBeforeRequest.addListener(
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
console.log(details);
removeCookies('https://gauchazh.clicrbs.com.br');
removeCookies('https://www.ft.com');
},
{
urls: [
// Financial Times
"*://*.ft.com/*",
// Zero Hora
"*://*.clicrbs.com.br/*"
"*://*.ft.com/*"
]
}
);
@ -141,10 +140,7 @@ chrome.webRequest.onHeadersReceived.addListener(
{
urls: [
// Financial Times
"*://*.ft.com/*",
// Zero Hora
"*://*.clicrbs.com.br/*"
"*://*.ft.com/*"
]
},
['blocking', 'responseHeaders']

37
src/content-start.js Normal file
View File

@ -0,0 +1,37 @@
// run_at: document_start
var code = null;
if (/gauchazh.clicrbs.com.br/.test(document.location.host)) {
code = `
function patchJs(jsurl) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var injectme = this.responseText;
injectme = injectme.replace('showSignwall:e.showLoginPaywall','showSignwall:false');
injectme = injectme.replace('showPaywall:e.showPaywall','showPaywall:false');
injectme = injectme.replace('requestCPF:e.requestCPF || !1','requestCPF:false');
injectme = injectme.replace('!e.showLoginPaywall&&!e.showPaywall||!1','true');
var script = document.createElement("script");
script.type = "text/javascript";
var textNode = document.createTextNode(injectme);
script.appendChild(textNode);
document.head.appendChild(script);
}
};
xhttp.open("GET", jsurl, true);
xhttp.send();
}
document.addEventListener("DOMContentLoaded", function(event) {
patchJs(document.getElementsByTagName('script')[1].src);
});
`;
}
if (code !== null) {
var script = document.createElement('script');
script.textContent = code;
(document.head||document.documentElement).appendChild(script);
script.parentNode.removeChild(script);
}

View File

@ -31,53 +31,6 @@ else if (/ft.com/.test(document.location.host)) {
indexedDB.deleteDatabase("next:ads");';
}
else if (/gauchazh.clicrbs.com.br/.test(document.location.host)) {
code = `
function loadArticle() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var parser = new DOMParser();
var htmlDoc = parser.parseFromString(this.responseText,'text/html');
var injectme = htmlDoc.getElementsByClassName('paid-content-apply')[0].innerHTML;
document.getElementsByClassName('paid-content-apply')[0].innerHTML = injectme;
}
};
xhttp.open('GET', window.location.href, true);
xhttp.send();
}
function checkPaywall() {
setInterval(function() {
var paywall = document.getElementsByClassName('wrapper-paid-content')[0];
if (paywall) {
localStorage.clear();
loadArticle();
}
}, 1000);
}
function deleteAllCookies() {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
}
}
function clearPersistentData() {
localStorage.clear();
sessionStorage.clear();
deleteAllCookies();
}
checkPaywall();
document.getElementsByTagName('html')[0].onclick = clearPersistentData();
`;
}
if (code !== null) {
var script = document.createElement('script');
script.textContent = code;

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "burlesco",
"version": "5.3",
"version": "5.4",
"description": "Leia notícias sem ser assinante, burle o paywall",
"homepage_url": "http://burles.co",
"author": "rodorgas",
@ -23,9 +23,12 @@
"*://foreignpolicy.com/*",
"*://*.folha.uol.com.br/*",
"*://*.folha.com.br/*",
"*://*.ft.com/*",
"*://gauchazh.clicrbs.com.br/*"
"*://*.ft.com/*"
]
},{
"js": ["content-start.js"],
"run_at": "document_start",
"matches": ["*://gauchazh.clicrbs.com.br/*"]
}],
"permissions": [