Permitir a desativação por site na webextension (#100)
* Inclui options.html para desativação por site (#92) * Alguns sites estavam fora da lista, deixa em ordem alfabética * Modifica background.js para respeitar prefrências * Content script respeita opções, autoreload background Recarrega os listeners do background script ao mudar opções. * Remove código para debugging * Padroniza nome de variável * Bugfix: content não funcionava com opções nulamaster
parent
8154f9b1fc
commit
972d8f0faa
|
@ -17,3 +17,6 @@ rules:
|
|||
semi:
|
||||
- error
|
||||
- always
|
||||
max-len:
|
||||
- 1
|
||||
- code: 80
|
||||
|
|
34
README.md
34
README.md
|
@ -44,27 +44,29 @@ Se você tiver alguma dúvida ou ideia para burlar um site novo, abra uma issue
|
|||
|
||||
O Burlesco funciona com os seguintes sites de notícia:
|
||||
|
||||
- Folha de S.Paulo
|
||||
- O Globo
|
||||
- O Estado de S. Paulo
|
||||
- GaúchaZH
|
||||
- Correio Popular
|
||||
- Gazeta do Povo
|
||||
- Diário Catarinense
|
||||
- Jornal de Santa Catarina
|
||||
- Diário de Santa Maria
|
||||
- Nexo
|
||||
- JOTA
|
||||
- O Estado do Maranhão
|
||||
- Jornal NH
|
||||
- UOL
|
||||
- Veja
|
||||
- Exame
|
||||
- Superinteressante
|
||||
- Quatro Rodas
|
||||
- The Economist
|
||||
- Foreign Policy
|
||||
- Financial Times
|
||||
- Folha de Londrina
|
||||
- Folha de S.Paulo
|
||||
- Foreign Policy
|
||||
- Gazeta do Povo
|
||||
- GaúchaZH
|
||||
- Gramophone
|
||||
- JOTA
|
||||
- Jornal NH
|
||||
- Jornal de Santa Catarina
|
||||
- Nexo
|
||||
- O Estado de S. Paulo
|
||||
- O Estado do Maranhão
|
||||
- O Globo
|
||||
- Quatro Rodas
|
||||
- Superinteressante
|
||||
- The Economist
|
||||
- The New York Times
|
||||
- The Wall Street Journal
|
||||
- The Washington Post
|
||||
- UOL
|
||||
- Veja
|
||||
|
|
|
@ -1,226 +1,330 @@
|
|||
// Script blocking
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function() {
|
||||
return {cancel: true};
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// O Estado de S. Paulo
|
||||
'*://*.estadao.com.br/paywall/*',
|
||||
const WHITELIST = {
|
||||
folhadespaulo: {
|
||||
xhrBlocking: [
|
||||
'http://paywall.folha.uol.com.br/status.php',
|
||||
'https://paywall.folha.uol.com.br/status.php'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// Folha de S.Paulo
|
||||
const BLOCKLIST = {
|
||||
correiopopular: {
|
||||
scriptBlocking: [
|
||||
'*://correio.rac.com.br/includes/js/novo_cp/fivewall.js*',
|
||||
]
|
||||
},
|
||||
diariocatarinense: {
|
||||
xhrBlocking: [
|
||||
'http://dc.clicrbs.com.br/jornal-2015/jsp/paywall.jspx*',
|
||||
]
|
||||
},
|
||||
diariodesantamaria: {
|
||||
scriptBlocking: [
|
||||
'*://www.rbsonline.com.br/cdn/scripts/SLoader.js',
|
||||
]
|
||||
},
|
||||
exame: {
|
||||
scriptBlocking: [
|
||||
'*://cdn.tinypass.com/api/tinypass.min.js',
|
||||
]
|
||||
},
|
||||
folhadespaulo: {
|
||||
scriptBlocking: [
|
||||
'*://paywall.folha.uol.com.br/*',
|
||||
'*://static.folha.uol.com.br/paywall/*',
|
||||
|
||||
// O Globo
|
||||
'*://ogjs.infoglobo.com.br/*/js/controla-acesso-aux.js',
|
||||
|
||||
// Gazeta do Povo
|
||||
],
|
||||
xhrBlocking: [
|
||||
'*://paywall.folha.uol.com.br/*',
|
||||
'*://static.folha.uol.com.br/paywall/*',
|
||||
]
|
||||
},
|
||||
financialtimes: {
|
||||
cookieBlocking: {
|
||||
urlFilter: '*://*.ft.com/*',
|
||||
blockAll: true
|
||||
},
|
||||
headerInjection: {
|
||||
name: 'Referer',
|
||||
value: 'https://www.google.com.br/',
|
||||
urlFilter: '*://www.ft.com/*'
|
||||
}
|
||||
},
|
||||
gazetadopovo: {
|
||||
scriptBlocking: [
|
||||
'*://www.netdeal.com.br/*',
|
||||
|
||||
// Correio Popular
|
||||
'*://correio.rac.com.br/includes/js/novo_cp/fivewall.js*',
|
||||
|
||||
// O Estado do Maranhão
|
||||
'*://dashboard.tinypass.com/xbuilder/experience/load*',
|
||||
'http://assets.imirante.com/2.0/oestadoma/js/jquery.login.min.js',
|
||||
|
||||
// Jornal de Novo Hamburgo
|
||||
'*://*.jornalnh.com.br/includes/js/paywall.js*',
|
||||
'*://blockv2.fivewall.com.br/*',
|
||||
|
||||
// Diário de Santa Maria
|
||||
'*://www.rbsonline.com.br/cdn/scripts/SLoader.js',
|
||||
|
||||
// New York Times
|
||||
'*://*.nytimes.com/js/mtr.js',
|
||||
'*://*.nyt.com/js/mtr.js',
|
||||
|
||||
// Washington Post
|
||||
'*://*.washingtonpost.com/*pwapi/*.js*',
|
||||
'*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*',
|
||||
|
||||
// O Globo, Exame, Super Interessante, Veja, The Economist, Quatro Rodas
|
||||
'*://cdn.tinypass.com/api/tinypass.min.js',
|
||||
|
||||
// UOL
|
||||
'*://tm.jsuol.com.br/modules/content-gate.js',
|
||||
|
||||
// GaúchaZH
|
||||
]
|
||||
},
|
||||
gauchazh: {
|
||||
scriptBlocking: [
|
||||
'*://gauchazh.clicrbs.com.br/static/main*',
|
||||
'*://www.rbsonline.com.br/cdn/scripts/special-paywall.min.js*',
|
||||
'*://www.rbsonline.com.br/cdn/scripts/paywall.min.js*',
|
||||
|
||||
// Gramophone
|
||||
]
|
||||
},
|
||||
gramophone: {
|
||||
scriptBlocking: [
|
||||
'*://api.tinypass.com/tpl/*',
|
||||
|
||||
// Folha de Londrina
|
||||
'*://www.folhadelondrina.com.br/*/fivewall.js*'
|
||||
],
|
||||
types: ['script']
|
||||
]
|
||||
},
|
||||
['blocking']
|
||||
);
|
||||
|
||||
var WHITELIST = [
|
||||
'http://paywall.folha.uol.com.br/status.php',
|
||||
'https://paywall.folha.uol.com.br/status.php'
|
||||
];
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
if (WHITELIST.indexOf(details.url) !== -1)
|
||||
return {cancel: false};
|
||||
else
|
||||
return {cancel: true};
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// Folha de S.Paulo
|
||||
'*://paywall.folha.uol.com.br/*',
|
||||
'*://static.folha.uol.com.br/paywall/*',
|
||||
|
||||
// Diário Catarinense
|
||||
'http://dc.clicrbs.com.br/jornal-2015/jsp/paywall.jspx*',
|
||||
|
||||
// Jornal de Santa Catarina
|
||||
jornaldesantacatarina: {
|
||||
scriptBlocking: [
|
||||
'http://jornaldesantacatarina.clicrbs.com.br/jornal/jsp/paywall*'
|
||||
],
|
||||
types: ['xmlhttprequest']
|
||||
]
|
||||
},
|
||||
['blocking']
|
||||
);
|
||||
|
||||
// Cookie blocking
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function() {
|
||||
chrome.cookies.remove({
|
||||
'url': 'http://jota.info/*',
|
||||
'name': 'articles'
|
||||
});
|
||||
jornalnh: {
|
||||
scriptBlocking: [
|
||||
'*://*.jornalnh.com.br/includes/js/paywall.js*',
|
||||
'*://blockv2.fivewall.com.br/*',
|
||||
]
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// JOTA
|
||||
'http://jota.info/*'
|
||||
],
|
||||
types: ['main_frame']
|
||||
}
|
||||
);
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function() {
|
||||
removeCookies('https://www.ft.com');
|
||||
jota: {
|
||||
cookieBlocking: {
|
||||
urlFilter: 'http://jota.info/*',
|
||||
cookie: {
|
||||
url: 'http://jota.info/*',
|
||||
name: 'articles'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// Financial Times
|
||||
'*://*.ft.com/*'
|
||||
nexo: {
|
||||
cookieBlocking: {
|
||||
urlFilter: '*://api.nexojornal.com.br/*',
|
||||
blockAll: true
|
||||
}
|
||||
},
|
||||
oestadodespaulo: {
|
||||
xhrBlocking: [
|
||||
'*://*.estadao.com.br/paywall/*',
|
||||
]
|
||||
},
|
||||
oestadodomaranhao: {
|
||||
xhrBlocking: [
|
||||
'*://dashboard.tinypass.com/xbuilder/experience/load*',
|
||||
'http://assets.imirante.com/2.0/oestadoma/js/jquery.login.min.js',
|
||||
]
|
||||
},
|
||||
oglobo: {
|
||||
scriptBlocking: [
|
||||
'*://ogjs.infoglobo.com.br/*/js/controla-acesso-aux.js',
|
||||
]
|
||||
},
|
||||
quatrorodas: {
|
||||
scriptBlocking: [
|
||||
'*://cdn.tinypass.com/api/tinypass.min.js',
|
||||
]
|
||||
},
|
||||
superinteressante: {
|
||||
scriptBlocking: [
|
||||
'*://cdn.tinypass.com/api/tinypass.min.js',
|
||||
]
|
||||
},
|
||||
theeconomist: {
|
||||
scriptBlocking: [
|
||||
'*://cdn.tinypass.com/api/tinypass.min.js',
|
||||
]
|
||||
},
|
||||
thenewyorktimes: {
|
||||
scriptBlocking: [
|
||||
'*://*.nytimes.com/js/mtr.js',
|
||||
'*://*.nyt.com/js/mtr.js',
|
||||
]
|
||||
},
|
||||
thewashingtonpost: {
|
||||
scriptBlocking: [
|
||||
'*://*.washingtonpost.com/*pwapi/*.js*',
|
||||
'*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*',
|
||||
]
|
||||
},
|
||||
thewallstreetjournal: {
|
||||
cookieBlocking: {
|
||||
urlFilter: '*://*.wsj.com/*',
|
||||
blockAll: true
|
||||
},
|
||||
headerInjection: {
|
||||
name: 'Referer',
|
||||
value: 'https://www.facebook.com/',
|
||||
urlFilter: '*://*.wsj.com/*'
|
||||
}
|
||||
},
|
||||
uol: {
|
||||
scriptBlocking: [
|
||||
'*://tm.jsuol.com.br/modules/content-gate.js',
|
||||
]
|
||||
},
|
||||
veja: {
|
||||
scriptBlocking: [
|
||||
'*://cdn.tinypass.com/api/tinypass.min.js',
|
||||
]
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function() {
|
||||
removeCookies('https://www.wsj.com');
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// The Wall Street Journal
|
||||
'*://*.wsj.com/*'
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
function removeCookies(url) {
|
||||
chrome.cookies.getAll({}, function(cookies) {
|
||||
cookies.forEach(function(cookie) {
|
||||
chrome.cookies.remove({
|
||||
'url': url,
|
||||
'name': cookie.name
|
||||
});
|
||||
});
|
||||
});
|
||||
function onBeforeRequestScript() {
|
||||
return {cancel: true};
|
||||
}
|
||||
|
||||
chrome.webRequest.onHeadersReceived.addListener(
|
||||
// Block cookies from being set
|
||||
function (details) {
|
||||
details.responseHeaders.forEach(function(responseHeader) {
|
||||
if (responseHeader.name.toLowerCase() == 'set-cookie') {
|
||||
responseHeader.value = '';
|
||||
}
|
||||
});
|
||||
return {
|
||||
responseHeaders: details.responseHeaders
|
||||
};
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// Financial Times
|
||||
'*://*.ft.com/*',
|
||||
function setScriptBlocking(enabledSites) {
|
||||
let urlFilters = [];
|
||||
|
||||
// The Wall Street Journal
|
||||
'*://*.wsj.com/'
|
||||
]
|
||||
},
|
||||
['blocking', 'responseHeaders']
|
||||
);
|
||||
for (let item in BLOCKLIST) {
|
||||
let script = BLOCKLIST[item].scriptBlocking;
|
||||
if (enabledSites && enabledSites[item] == false)
|
||||
continue;
|
||||
if (script == undefined)
|
||||
continue;
|
||||
urlFilters = urlFilters.concat(script);
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
function(details) {
|
||||
injectHeader('Cookie', '', details.requestHeaders);
|
||||
return {requestHeaders: details.requestHeaders};
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// Jornal Nexo
|
||||
'*://api.nexojornal.com.br/*'
|
||||
],
|
||||
types: ['xmlhttprequest']
|
||||
},
|
||||
['blocking', 'requestHeaders']
|
||||
);
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
onBeforeRequestScript,
|
||||
{
|
||||
urls: urlFilters,
|
||||
types: ['script']
|
||||
},
|
||||
['blocking']
|
||||
);
|
||||
}
|
||||
|
||||
// Referer injection
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
function(details) {
|
||||
let whitelist = [];
|
||||
function onBeforeRequestXml(details) {
|
||||
if (whitelist.indexOf(details.url) !== -1)
|
||||
return {cancel: false};
|
||||
else
|
||||
return {cancel: true};
|
||||
}
|
||||
function setXhrBlocking(enabledSites) {
|
||||
let blocklist = [];
|
||||
|
||||
for (let item in BLOCKLIST) {
|
||||
let xhr = BLOCKLIST[item].xhrBlocking;
|
||||
if (xhr == undefined)
|
||||
continue;
|
||||
if (enabledSites && enabledSites[item] == false)
|
||||
continue;
|
||||
blocklist = blocklist.concat(xhr);
|
||||
}
|
||||
|
||||
for (let item in WHITELIST) {
|
||||
if (enabledSites && enabledSites[item] == false)
|
||||
continue;
|
||||
let xhr = BLOCKLIST[item].xhrBlocking;
|
||||
if (xhr == undefined)
|
||||
continue;
|
||||
whitelist = whitelist.concat(xhr);
|
||||
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
onBeforeRequestXml,
|
||||
{
|
||||
urls: blocklist,
|
||||
types: ['xmlhttprequest']
|
||||
},
|
||||
['blocking']
|
||||
);
|
||||
}
|
||||
|
||||
function onHeadersReceivedCookie(details) {
|
||||
details.responseHeaders.forEach(function(responseHeader) {
|
||||
if (responseHeader.name.toLowerCase() == 'set-cookie') {
|
||||
responseHeader.value = '';
|
||||
}
|
||||
});
|
||||
return {
|
||||
responseHeaders: details.responseHeaders
|
||||
};
|
||||
}
|
||||
function onBeforeSendHeadersCookie(details) {
|
||||
injectHeader('Cookie', '', details.requestHeaders);
|
||||
return {requestHeaders: details.requestHeaders};
|
||||
}
|
||||
|
||||
function makeCookieRemove(cookie) {
|
||||
return function() {
|
||||
chrome.cookies.remove(cookie);
|
||||
};
|
||||
}
|
||||
let callbacksOnBeforeRequestCookie = [];
|
||||
|
||||
|
||||
function setCookieBlocking(enabledSites) {
|
||||
let urlFilters = [];
|
||||
|
||||
for (let item in BLOCKLIST) {
|
||||
let cookie = BLOCKLIST[item].cookieBlocking;
|
||||
if (cookie == undefined)
|
||||
continue;
|
||||
if (enabledSites && enabledSites[item] == false)
|
||||
continue;
|
||||
|
||||
if (cookie.blockAll) {
|
||||
urlFilters.push(cookie.urlFilter);
|
||||
}
|
||||
else {
|
||||
let callback = makeCookieRemove(cookie.cookie);
|
||||
callbacksOnBeforeRequestCookie.push(callback);
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
callback,
|
||||
{
|
||||
urls: [cookie.urlFilter],
|
||||
types: ['xmlhttprequest', 'script', 'main_frame']
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
chrome.webRequest.onHeadersReceived.addListener(
|
||||
onHeadersReceivedCookie,
|
||||
{
|
||||
urls: urlFilters,
|
||||
types: ['xmlhttprequest', 'script', 'main_frame']
|
||||
},
|
||||
['blocking', 'responseHeaders']
|
||||
);
|
||||
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
onBeforeSendHeadersCookie,
|
||||
{
|
||||
urls: urlFilters,
|
||||
types: ['xmlhttprequest', 'script', 'main_frame']
|
||||
},
|
||||
['blocking', 'requestHeaders']
|
||||
);
|
||||
}
|
||||
function makeInjectHeader(name, value) {
|
||||
return function(details) {
|
||||
injectHeader(
|
||||
'Referer',
|
||||
'https://www.google.com.br/',
|
||||
name,
|
||||
value,
|
||||
details.requestHeaders
|
||||
);
|
||||
|
||||
return {requestHeaders: details.requestHeaders};
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// Financial Times
|
||||
'*://www.ft.com/*'
|
||||
],
|
||||
types: ['xmlhttprequest', 'main_frame']
|
||||
},
|
||||
['blocking', 'requestHeaders']
|
||||
);
|
||||
};
|
||||
}
|
||||
let callbacksOnBeforeSendHeadersInjection = [];
|
||||
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
function(details) {
|
||||
injectHeader(
|
||||
'Referer',
|
||||
'https://www.facebook.com/',
|
||||
details.requestHeaders
|
||||
function setHeaderInjection(enabledSites) {
|
||||
for (let item in BLOCKLIST) {
|
||||
let header = BLOCKLIST[item].headerInjection;
|
||||
if (header == undefined)
|
||||
continue;
|
||||
if (enabledSites && enabledSites[item] == false)
|
||||
continue;
|
||||
|
||||
let callback = makeInjectHeader(header.name, header.value);
|
||||
callbacksOnBeforeSendHeadersInjection.push(callback);
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
callback,
|
||||
{
|
||||
urls: [
|
||||
header.urlFilter
|
||||
],
|
||||
types: ['xmlhttprequest', 'main_frame']
|
||||
},
|
||||
['blocking', 'requestHeaders']
|
||||
);
|
||||
|
||||
return {requestHeaders: details.requestHeaders};
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
// The Wall Street Journal
|
||||
'*://*.wsj.com/*'
|
||||
],
|
||||
types: ['xmlhttprequest', 'main_frame']
|
||||
},
|
||||
['blocking', 'requestHeaders']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function injectHeader(name, value, requestHeaders) {
|
||||
/**
|
||||
|
@ -240,3 +344,34 @@ function injectHeader(name, value, requestHeaders) {
|
|||
else
|
||||
requestHeaders[headerIndex] = newHeader;
|
||||
}
|
||||
|
||||
function apply() {
|
||||
chrome.storage.local.get('sites', function(result) {
|
||||
let enabledSites = result.sites;
|
||||
|
||||
setScriptBlocking(enabledSites);
|
||||
setXhrBlocking(enabledSites);
|
||||
setCookieBlocking(enabledSites);
|
||||
setHeaderInjection(enabledSites);
|
||||
});
|
||||
}
|
||||
|
||||
function removeListeners() {
|
||||
chrome.webRequest.onBeforeRequest.removeListener(onBeforeRequestScript);
|
||||
chrome.webRequest.onBeforeRequest.removeListener(onBeforeRequestXml);
|
||||
chrome.webRequest.onHeadersReceived.removeListener(onHeadersReceivedCookie);
|
||||
chrome.webRequest.onBeforeSendHeaders.removeListener(
|
||||
onBeforeSendHeadersCookie);
|
||||
for (let item of callbacksOnBeforeRequestCookie)
|
||||
chrome.webRequest.onBeforeRequest.removeListener(item);
|
||||
for (let item of callbacksOnBeforeSendHeadersInjection)
|
||||
chrome.webRequest.onBeforeSendHeaders.removeListener(item);
|
||||
}
|
||||
|
||||
apply();
|
||||
chrome.runtime.onMessage.addListener(function(message) {
|
||||
if (message == 'update') {
|
||||
removeListeners();
|
||||
apply();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,39 +1,55 @@
|
|||
// run_at: document_start
|
||||
var code = null;
|
||||
chrome.storage.local.get('sites', function(result) {
|
||||
for (let site in result.sites) {
|
||||
let enabledSites = result.sites;
|
||||
if (enabledSites[site] == false)
|
||||
continue;
|
||||
if (INJECTION[site] == undefined)
|
||||
continue;
|
||||
|
||||
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('e.showLoginPaywall,','false,');
|
||||
injectme = injectme.replace('e.showPaywall,','false,');
|
||||
injectme = injectme.replace('e.requestCPF||!1,','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();
|
||||
if (INJECTION[site].url.test(document.location.host)) {
|
||||
var script = document.createElement('script');
|
||||
script.textContent = INJECTION[site].code;
|
||||
(document.head||document.documentElement).appendChild(script);
|
||||
script.parentNode.removeChild(script);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var scripts = Array.from(document.getElementsByTagName('script'));
|
||||
var script = scripts.find((el) => { return el.src.includes('static/main') });
|
||||
if (script)
|
||||
patchJs(script.src);
|
||||
});
|
||||
`;
|
||||
const INJECTION = {
|
||||
gauchazh: {
|
||||
url : /gauchazh.clicrbs.com.br/,
|
||||
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('e.showLoginPaywall,','false,');
|
||||
injectme = injectme.replace('e.showPaywall,','false,');
|
||||
injectme = injectme.replace('e.requestCPF||!1,','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();
|
||||
}
|
||||
|
||||
if (code !== null) {
|
||||
var script = document.createElement('script');
|
||||
script.textContent = code;
|
||||
(document.head||document.documentElement).appendChild(script);
|
||||
script.parentNode.removeChild(script);
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var scripts = Array.from(document.getElementsByTagName('script'));
|
||||
var script = scripts.find((el) => {
|
||||
return el.src.includes('static/main')
|
||||
});
|
||||
if (script)
|
||||
patchJs(script.src);
|
||||
});
|
||||
`
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,45 +1,66 @@
|
|||
// run_at: document_idle
|
||||
var code = null;
|
||||
if (/oglobo\.globo\.com/.test(document.location.host))
|
||||
code = 'paywallAtivo = false;';
|
||||
const INJECTION = {
|
||||
oglobo: {
|
||||
url: /oglobo\.globo\.com/,
|
||||
code: 'paywallAtivo = false;'
|
||||
},
|
||||
theeconomist: {
|
||||
url : /www\.economist\.com/,
|
||||
code: 'document.cookie = "ec_limit=allow";'
|
||||
},
|
||||
foreignpolicy: {
|
||||
url: /foreignpolicy\.com/,
|
||||
code: `
|
||||
document.getElementById("paywall_bg").remove();
|
||||
document.body.classList.remove("overlay-no-scroll");
|
||||
document.body.style.overflow = "visible";
|
||||
document.documentElement.classList.remove("overlay-no-scroll");
|
||||
`
|
||||
},
|
||||
folhadespaulo: {
|
||||
url: /folha.uol.com.br/,
|
||||
code: `
|
||||
omtrClickUOL = function(){};function showText() {
|
||||
$("#bt-read-more-content").next().show();
|
||||
$("#bt-read-more-content").next().show().prev().remove();
|
||||
}
|
||||
setTimeout(showText, 100);
|
||||
`
|
||||
},
|
||||
financialtimes: {
|
||||
url: /ft.com/,
|
||||
code: `
|
||||
document.cookie = "";
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
indexedDB.deleteDatabase("next-flags");
|
||||
indexedDB.deleteDatabase("next:ads");'
|
||||
`
|
||||
},
|
||||
veja: {
|
||||
url: /veja.abril.com.br/,
|
||||
code: `
|
||||
document.querySelector('.content-blocked').classList
|
||||
.remove('content-blocked');
|
||||
document.querySelector('.callpaywall').remove();
|
||||
`
|
||||
}
|
||||
};
|
||||
|
||||
else if (/www\.economist\.com/.test(document.location.host))
|
||||
code = 'document.cookie = "ec_limit=allow";';
|
||||
chrome.storage.local.get('sites', function(result) {
|
||||
for (let site in INJECTION) {
|
||||
let enabledSites = result.sites;
|
||||
if (enabledSites && enabledSites[site] == false)
|
||||
continue;
|
||||
if (INJECTION[site] == undefined)
|
||||
continue;
|
||||
|
||||
else if (/foreignpolicy\.com/.test(document.location.host)) {
|
||||
code = '\
|
||||
document.getElementById("paywall_bg").remove();\
|
||||
document.body.classList.remove("overlay-no-scroll");\
|
||||
document.body.style.overflow = "visible";\
|
||||
document.documentElement.classList.remove("overlay-no-scroll");\
|
||||
';
|
||||
}
|
||||
|
||||
else if (/folha.uol.com.br/.test(document.location.host)) {
|
||||
code = 'omtrClickUOL = function(){};function showText() {\
|
||||
$("#bt-read-more-content").next().show();\
|
||||
$("#bt-read-more-content").next().show().prev().remove();\
|
||||
} \
|
||||
setTimeout(showText, 100);';
|
||||
}
|
||||
|
||||
else if (/ft.com/.test(document.location.host)) {
|
||||
code = 'document.cookie = "";\
|
||||
localStorage.clear();\
|
||||
sessionStorage.clear();\
|
||||
indexedDB.deleteDatabase("next-flags");\
|
||||
indexedDB.deleteDatabase("next:ads");';
|
||||
}
|
||||
|
||||
else if (/veja.abril.com.br/.test(document.location.host))
|
||||
code = `
|
||||
document.querySelector('.content-blocked').classList.remove('content-blocked');
|
||||
document.querySelector('.callpaywall').remove();
|
||||
`;
|
||||
|
||||
if (code !== null) {
|
||||
var script = document.createElement('script');
|
||||
script.textContent = code;
|
||||
(document.head||document.documentElement).appendChild(script);
|
||||
script.parentNode.removeChild(script);
|
||||
}
|
||||
if (INJECTION[site].url.test(document.location.host)) {
|
||||
var script = document.createElement('script');
|
||||
script.textContent = INJECTION[site].code;
|
||||
(document.head||document.documentElement).appendChild(script);
|
||||
script.parentNode.removeChild(script);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"cookies",
|
||||
"storage",
|
||||
|
||||
"*://correio.rac.com.br/*",
|
||||
"*://dc.clicrbs.com.br/*",
|
||||
|
@ -85,5 +86,9 @@
|
|||
"gecko": {
|
||||
"id": "burlesco@burlesco.com"
|
||||
}
|
||||
},
|
||||
|
||||
"options_ui": {
|
||||
"page": "options.html"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,191 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Burlesco - Opções</title>
|
||||
<meta charset="UTF-8" />
|
||||
<style>
|
||||
.submit {
|
||||
margin-top: 10px;
|
||||
}
|
||||
input[type=checkbox] + span{
|
||||
text-decoration: line-through;
|
||||
}
|
||||
input[type=checkbox]:checked + span{
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Ativar o Burlesco nos sites:</h3>
|
||||
<form>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="correiopopular" checked>
|
||||
<span>Correio Popular</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="diariocatarinense" checked>
|
||||
<span>Diário Catarinense</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="diariodesantamaria" checked>
|
||||
<span>Diário de Santa Maria</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="exame" checked>
|
||||
<span>Exame</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="financialtimes" checked>
|
||||
<span>Financial Times</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="folhadelondrina" checked>
|
||||
<span>Folha de Londrina</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="folhadespaulo" checked>
|
||||
<span>Folha de S.Paulo</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="foreignpolicy" checked>
|
||||
<span>Foreign Policy</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="gazetadopovo" checked>
|
||||
<span>Gazeta do Povo</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="gauchazh" checked>
|
||||
<span>GaúchaZH</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="gramophone" checked>
|
||||
<span>Gramophone</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="jornaldesantacatarina" checked>
|
||||
<span>Jornal de Santa Catarina</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="jornalnh" checked>
|
||||
<span>Jornal NH</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="jota" checked>
|
||||
<span>JOTA</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="nexo" checked>
|
||||
<span>Nexo</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="oestadodespaulo" checked>
|
||||
<span>O Estado de S. Paulo</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="oestadodomaranhao" checked>
|
||||
<span>O Estado do Maranhão</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="oglobo" checked>
|
||||
<span>O Globo</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="quatrorodas" checked>
|
||||
<span>Quatro Rodas</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="superinteressante" checked>
|
||||
<span>Superinteressante</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="theeconomist" checked>
|
||||
<span>The Economist</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="thenewyorktimes" checked>
|
||||
<span>The New York Times</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="thewallstreetjournal" checked>
|
||||
<span>The Wall Street Journal</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="thewashingtonpost" checked>
|
||||
<span>The Washington Post</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="uol" checked>
|
||||
<span>UOL</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" id="veja" checked>
|
||||
<span>Veja</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<button type="button" id="all">Marcar todos</button>
|
||||
<button type="button" id="none">Desmarcar todos</button>
|
||||
</div>
|
||||
<div class="submit">
|
||||
<button type="submit">Salvar</button>
|
||||
<span style="color: #108c39; display: none" id="save-success">Salvo com sucesso!</span>
|
||||
</div>
|
||||
</form>
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,76 @@
|
|||
const SITES = [
|
||||
'correiopopular',
|
||||
'diariocatarinense',
|
||||
'diariodesantamaria',
|
||||
'exame',
|
||||
'financialtimes',
|
||||
'folhadespaulo',
|
||||
'foreignpolicy',
|
||||
'gazetadopovo',
|
||||
'gauchazh',
|
||||
'gramophone',
|
||||
'jornaldesantacatarina',
|
||||
'jornalnh',
|
||||
'jota',
|
||||
'nexo',
|
||||
'oestadodespaulo',
|
||||
'oestadodomaranhao',
|
||||
'oglobo',
|
||||
'quatrorodas',
|
||||
'superinteressante',
|
||||
'theeconomist',
|
||||
'thenewyorktimes',
|
||||
'thewallstreetjournal',
|
||||
'thewashingtonpost',
|
||||
'uol',
|
||||
'veja'
|
||||
];
|
||||
|
||||
function saveOptions(e) {
|
||||
function showUpdateSucess() {
|
||||
document.querySelector('#save-success').style.display = 'inline-block';
|
||||
setTimeout(function() {
|
||||
document.querySelector('#save-success').style.display = 'none';
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
let siteStatus = {};
|
||||
for (let site of SITES)
|
||||
siteStatus[site] = document.querySelector('#' + site).checked;
|
||||
|
||||
chrome.storage.local.set({sites: siteStatus});
|
||||
chrome.runtime.sendMessage('update');
|
||||
|
||||
showUpdateSucess();
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
function setCurrentSite(site, status) {
|
||||
document.querySelector('#' + site).checked = status;
|
||||
}
|
||||
|
||||
chrome.storage.local.get('sites', function(result) {
|
||||
for (let site in result.sites)
|
||||
setCurrentSite(site, result.sites[site]);
|
||||
});
|
||||
}
|
||||
|
||||
function changeAll(check) {
|
||||
let inputs = document.querySelectorAll('input[type="checkbox"]');
|
||||
for (let input of inputs) {
|
||||
input.checked = check;
|
||||
}
|
||||
}
|
||||
function checkNone() {
|
||||
changeAll(false);
|
||||
}
|
||||
function checkAll() {
|
||||
changeAll(true);
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', restoreOptions);
|
||||
document.querySelector('form').addEventListener('submit', saveOptions);
|
||||
document.querySelector('#all').addEventListener('click', checkAll);
|
||||
document.querySelector('#none').addEventListener('click', checkNone);
|
Loading…
Reference in New Issue