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:
|
semi:
|
||||||
- error
|
- error
|
||||||
- always
|
- 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:
|
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
|
- Correio Popular
|
||||||
- Gazeta do Povo
|
|
||||||
- Diário Catarinense
|
- Diário Catarinense
|
||||||
- Jornal de Santa Catarina
|
|
||||||
- Diário de Santa Maria
|
- Diário de Santa Maria
|
||||||
- Nexo
|
|
||||||
- JOTA
|
|
||||||
- O Estado do Maranhão
|
|
||||||
- Jornal NH
|
|
||||||
- UOL
|
|
||||||
- Veja
|
|
||||||
- Exame
|
- Exame
|
||||||
- Superinteressante
|
|
||||||
- Quatro Rodas
|
|
||||||
- The Economist
|
|
||||||
- Foreign Policy
|
|
||||||
- Financial Times
|
- 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 New York Times
|
||||||
- The Wall Street Journal
|
- The Wall Street Journal
|
||||||
- The Washington Post
|
- The Washington Post
|
||||||
|
- UOL
|
||||||
|
- Veja
|
||||||
|
|
|
@ -1,226 +1,330 @@
|
||||||
// Script blocking
|
const WHITELIST = {
|
||||||
chrome.webRequest.onBeforeRequest.addListener(
|
folhadespaulo: {
|
||||||
function() {
|
xhrBlocking: [
|
||||||
return {cancel: true};
|
'http://paywall.folha.uol.com.br/status.php',
|
||||||
},
|
'https://paywall.folha.uol.com.br/status.php'
|
||||||
{
|
]
|
||||||
urls: [
|
}
|
||||||
// O Estado de S. Paulo
|
};
|
||||||
'*://*.estadao.com.br/paywall/*',
|
|
||||||
|
|
||||||
// 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/*',
|
'*://paywall.folha.uol.com.br/*',
|
||||||
'*://static.folha.uol.com.br/paywall/*',
|
'*://static.folha.uol.com.br/paywall/*',
|
||||||
|
],
|
||||||
// O Globo
|
xhrBlocking: [
|
||||||
'*://ogjs.infoglobo.com.br/*/js/controla-acesso-aux.js',
|
'*://paywall.folha.uol.com.br/*',
|
||||||
|
'*://static.folha.uol.com.br/paywall/*',
|
||||||
// Gazeta do Povo
|
]
|
||||||
|
},
|
||||||
|
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/*',
|
'*://www.netdeal.com.br/*',
|
||||||
|
]
|
||||||
// Correio Popular
|
},
|
||||||
'*://correio.rac.com.br/includes/js/novo_cp/fivewall.js*',
|
gauchazh: {
|
||||||
|
scriptBlocking: [
|
||||||
// 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.clicrbs.com.br/static/main*',
|
'*://gauchazh.clicrbs.com.br/static/main*',
|
||||||
'*://www.rbsonline.com.br/cdn/scripts/special-paywall.min.js*',
|
'*://www.rbsonline.com.br/cdn/scripts/special-paywall.min.js*',
|
||||||
'*://www.rbsonline.com.br/cdn/scripts/paywall.min.js*',
|
'*://www.rbsonline.com.br/cdn/scripts/paywall.min.js*',
|
||||||
|
]
|
||||||
// Gramophone
|
},
|
||||||
|
gramophone: {
|
||||||
|
scriptBlocking: [
|
||||||
'*://api.tinypass.com/tpl/*',
|
'*://api.tinypass.com/tpl/*',
|
||||||
|
]
|
||||||
// Folha de Londrina
|
|
||||||
'*://www.folhadelondrina.com.br/*/fivewall.js*'
|
|
||||||
],
|
|
||||||
types: ['script']
|
|
||||||
},
|
},
|
||||||
['blocking']
|
jornaldesantacatarina: {
|
||||||
);
|
scriptBlocking: [
|
||||||
|
|
||||||
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
|
|
||||||
'http://jornaldesantacatarina.clicrbs.com.br/jornal/jsp/paywall*'
|
'http://jornaldesantacatarina.clicrbs.com.br/jornal/jsp/paywall*'
|
||||||
],
|
]
|
||||||
types: ['xmlhttprequest']
|
|
||||||
},
|
},
|
||||||
['blocking']
|
jornalnh: {
|
||||||
);
|
scriptBlocking: [
|
||||||
|
'*://*.jornalnh.com.br/includes/js/paywall.js*',
|
||||||
// Cookie blocking
|
'*://blockv2.fivewall.com.br/*',
|
||||||
chrome.webRequest.onBeforeRequest.addListener(
|
]
|
||||||
function() {
|
|
||||||
chrome.cookies.remove({
|
|
||||||
'url': 'http://jota.info/*',
|
|
||||||
'name': 'articles'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
{
|
jota: {
|
||||||
urls: [
|
cookieBlocking: {
|
||||||
// JOTA
|
urlFilter: 'http://jota.info/*',
|
||||||
'http://jota.info/*'
|
cookie: {
|
||||||
],
|
url: 'http://jota.info/*',
|
||||||
types: ['main_frame']
|
name: 'articles'
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
chrome.webRequest.onBeforeRequest.addListener(
|
|
||||||
function() {
|
|
||||||
removeCookies('https://www.ft.com');
|
|
||||||
},
|
},
|
||||||
{
|
nexo: {
|
||||||
urls: [
|
cookieBlocking: {
|
||||||
// Financial Times
|
urlFilter: '*://api.nexojornal.com.br/*',
|
||||||
'*://*.ft.com/*'
|
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 onBeforeRequestScript() {
|
||||||
function() {
|
return {cancel: true};
|
||||||
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
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.webRequest.onHeadersReceived.addListener(
|
function setScriptBlocking(enabledSites) {
|
||||||
// Block cookies from being set
|
let urlFilters = [];
|
||||||
function (details) {
|
|
||||||
details.responseHeaders.forEach(function(responseHeader) {
|
|
||||||
if (responseHeader.name.toLowerCase() == 'set-cookie') {
|
|
||||||
responseHeader.value = '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
responseHeaders: details.responseHeaders
|
|
||||||
};
|
|
||||||
},
|
|
||||||
{
|
|
||||||
urls: [
|
|
||||||
// Financial Times
|
|
||||||
'*://*.ft.com/*',
|
|
||||||
|
|
||||||
// The Wall Street Journal
|
for (let item in BLOCKLIST) {
|
||||||
'*://*.wsj.com/'
|
let script = BLOCKLIST[item].scriptBlocking;
|
||||||
]
|
if (enabledSites && enabledSites[item] == false)
|
||||||
},
|
continue;
|
||||||
['blocking', 'responseHeaders']
|
if (script == undefined)
|
||||||
);
|
continue;
|
||||||
|
urlFilters = urlFilters.concat(script);
|
||||||
|
}
|
||||||
|
|
||||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
chrome.webRequest.onBeforeRequest.addListener(
|
||||||
function(details) {
|
onBeforeRequestScript,
|
||||||
injectHeader('Cookie', '', details.requestHeaders);
|
{
|
||||||
return {requestHeaders: details.requestHeaders};
|
urls: urlFilters,
|
||||||
},
|
types: ['script']
|
||||||
{
|
},
|
||||||
urls: [
|
['blocking']
|
||||||
// Jornal Nexo
|
);
|
||||||
'*://api.nexojornal.com.br/*'
|
}
|
||||||
],
|
|
||||||
types: ['xmlhttprequest']
|
|
||||||
},
|
|
||||||
['blocking', 'requestHeaders']
|
|
||||||
);
|
|
||||||
|
|
||||||
// Referer injection
|
let whitelist = [];
|
||||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
function onBeforeRequestXml(details) {
|
||||||
function(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(
|
injectHeader(
|
||||||
'Referer',
|
name,
|
||||||
'https://www.google.com.br/',
|
value,
|
||||||
details.requestHeaders
|
details.requestHeaders
|
||||||
);
|
);
|
||||||
|
|
||||||
return {requestHeaders: details.requestHeaders};
|
return {requestHeaders: details.requestHeaders};
|
||||||
},
|
};
|
||||||
{
|
}
|
||||||
urls: [
|
let callbacksOnBeforeSendHeadersInjection = [];
|
||||||
// Financial Times
|
|
||||||
'*://www.ft.com/*'
|
|
||||||
],
|
|
||||||
types: ['xmlhttprequest', 'main_frame']
|
|
||||||
},
|
|
||||||
['blocking', 'requestHeaders']
|
|
||||||
);
|
|
||||||
|
|
||||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
function setHeaderInjection(enabledSites) {
|
||||||
function(details) {
|
for (let item in BLOCKLIST) {
|
||||||
injectHeader(
|
let header = BLOCKLIST[item].headerInjection;
|
||||||
'Referer',
|
if (header == undefined)
|
||||||
'https://www.facebook.com/',
|
continue;
|
||||||
details.requestHeaders
|
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) {
|
function injectHeader(name, value, requestHeaders) {
|
||||||
/**
|
/**
|
||||||
|
@ -240,3 +344,34 @@ function injectHeader(name, value, requestHeaders) {
|
||||||
else
|
else
|
||||||
requestHeaders[headerIndex] = newHeader;
|
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
|
// 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))
|
if (INJECTION[site].url.test(document.location.host)) {
|
||||||
code = `
|
var script = document.createElement('script');
|
||||||
function patchJs(jsurl) {
|
script.textContent = INJECTION[site].code;
|
||||||
var xhttp = new XMLHttpRequest();
|
(document.head||document.documentElement).appendChild(script);
|
||||||
xhttp.onreadystatechange = function() {
|
script.parentNode.removeChild(script);
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
break;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
const INJECTION = {
|
||||||
var scripts = Array.from(document.getElementsByTagName('script'));
|
gauchazh: {
|
||||||
var script = scripts.find((el) => { return el.src.includes('static/main') });
|
url : /gauchazh.clicrbs.com.br/,
|
||||||
if (script)
|
code: `
|
||||||
patchJs(script.src);
|
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) {
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
var script = document.createElement('script');
|
var scripts = Array.from(document.getElementsByTagName('script'));
|
||||||
script.textContent = code;
|
var script = scripts.find((el) => {
|
||||||
(document.head||document.documentElement).appendChild(script);
|
return el.src.includes('static/main')
|
||||||
script.parentNode.removeChild(script);
|
});
|
||||||
}
|
if (script)
|
||||||
|
patchJs(script.src);
|
||||||
|
});
|
||||||
|
`
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -1,45 +1,66 @@
|
||||||
// run_at: document_idle
|
// run_at: document_idle
|
||||||
var code = null;
|
const INJECTION = {
|
||||||
if (/oglobo\.globo\.com/.test(document.location.host))
|
oglobo: {
|
||||||
code = 'paywallAtivo = false;';
|
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))
|
chrome.storage.local.get('sites', function(result) {
|
||||||
code = 'document.cookie = "ec_limit=allow";';
|
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)) {
|
if (INJECTION[site].url.test(document.location.host)) {
|
||||||
code = '\
|
var script = document.createElement('script');
|
||||||
document.getElementById("paywall_bg").remove();\
|
script.textContent = INJECTION[site].code;
|
||||||
document.body.classList.remove("overlay-no-scroll");\
|
(document.head||document.documentElement).appendChild(script);
|
||||||
document.body.style.overflow = "visible";\
|
script.parentNode.removeChild(script);
|
||||||
document.documentElement.classList.remove("overlay-no-scroll");\
|
break;
|
||||||
';
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
"cookies",
|
"cookies",
|
||||||
|
"storage",
|
||||||
|
|
||||||
"*://correio.rac.com.br/*",
|
"*://correio.rac.com.br/*",
|
||||||
"*://dc.clicrbs.com.br/*",
|
"*://dc.clicrbs.com.br/*",
|
||||||
|
@ -85,5 +86,9 @@
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "burlesco@burlesco.com"
|
"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