2017-02-13 18:40:59 -08:00
|
|
|
// Script blocking
|
2016-04-24 21:06:35 -07:00
|
|
|
chrome.webRequest.onBeforeRequest.addListener(
|
2017-11-27 13:59:58 -08:00
|
|
|
function() {
|
2017-03-17 21:25:04 -07:00
|
|
|
return {cancel: true};
|
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
|
|
|
// O Estado de S. Paulo
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://*.estadao.com.br/paywall/*',
|
2017-03-17 21:25:04 -07:00
|
|
|
|
|
|
|
// Folha de S.Paulo
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://paywall.folha.uol.com.br/*',
|
|
|
|
'*://static.folha.uol.com.br/paywall/*',
|
2017-03-17 21:25:04 -07:00
|
|
|
|
|
|
|
// O Globo
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://ogjs.infoglobo.com.br/*/js/controla-acesso-aux.js',
|
2017-03-17 21:25:04 -07:00
|
|
|
|
|
|
|
// Gazeta do Povo
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://*.gazetadopovo.com.br/loader/v1/logan_full_toolbar.js*',
|
2017-03-17 21:25:04 -07:00
|
|
|
|
|
|
|
// Correio Popular
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://correio.rac.com.br/includes/js/novo_cp/fivewall.js*',
|
2017-03-17 21:25:04 -07:00
|
|
|
|
|
|
|
// O Estado do Maranhão
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://dashboard.tinypass.com/xbuilder/experience/load*',
|
|
|
|
'http://assets.imirante.com/2.0/oestadoma/js/jquery.login.min.js',
|
2017-03-17 21:25:04 -07:00
|
|
|
|
|
|
|
// Jornal de Novo Hamburgo
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://*.jornalnh.com.br/includes/js/paywall.js*',
|
|
|
|
'*://blockv2.fivewall.com.br/*',
|
2017-05-15 15:15:54 -07:00
|
|
|
|
|
|
|
// Diário de Santa Maria
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://www.rbsonline.com.br/cdn/scripts/SLoader.js',
|
2017-10-19 08:25:08 -07:00
|
|
|
|
|
|
|
// New York Times
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://*.nyt.com/js/mtr.js',
|
2017-10-19 08:34:47 -07:00
|
|
|
|
|
|
|
// Washington Post
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://*.washingtonpost.com/*pwapi/*.js*',
|
|
|
|
'*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*',
|
2017-10-31 09:22:42 -07:00
|
|
|
|
2018-01-16 15:54:33 -08:00
|
|
|
// O Globo, Exame, Super Interessante, Veja, The Economist, Quatro Rodas
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://cdn.tinypass.com/api/tinypass.min.js',
|
2017-10-30 14:50:50 -07:00
|
|
|
|
|
|
|
// UOL
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://tm.jsuol.com.br/modules/content-gate.js',
|
2017-11-07 05:45:39 -08:00
|
|
|
|
2017-12-20 12:33:56 -08:00
|
|
|
// GaúchaZH
|
2017-12-20 12:10:10 -08:00
|
|
|
'*://gauchazh.clicrbs.com.br/static/main*',
|
2017-12-20 12:33:56 -08:00
|
|
|
'*://www.rbsonline.com.br/cdn/scripts/special-paywall.min.js*',
|
|
|
|
'*://www.rbsonline.com.br/cdn/scripts/paywall.min.js*'
|
2017-03-17 21:25:04 -07:00
|
|
|
],
|
2017-11-27 13:59:58 -08:00
|
|
|
types: ['script']
|
2017-03-17 21:25:04 -07:00
|
|
|
},
|
2017-11-27 13:59:58 -08:00
|
|
|
['blocking']
|
2016-04-24 21:06:35 -07:00
|
|
|
);
|
2016-05-21 15:05:04 -07:00
|
|
|
|
2017-11-27 13:59:58 -08:00
|
|
|
var WHITELIST = [
|
2017-11-28 10:07:49 -08:00
|
|
|
'http://paywall.folha.uol.com.br/status.php',
|
|
|
|
'https://paywall.folha.uol.com.br/status.php'
|
2017-08-28 17:02:20 -07:00
|
|
|
];
|
2016-05-21 15:05:04 -07:00
|
|
|
chrome.webRequest.onBeforeRequest.addListener(
|
2017-03-17 21:25:04 -07:00
|
|
|
function(details) {
|
2017-08-28 17:02:20 -07:00
|
|
|
if (WHITELIST.indexOf(details.url) !== -1)
|
|
|
|
return {cancel: false};
|
|
|
|
else
|
|
|
|
return {cancel: true};
|
2017-03-17 21:25:04 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
2017-08-15 18:33:07 -07:00
|
|
|
// Folha de S.Paulo
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://paywall.folha.uol.com.br/*',
|
|
|
|
'*://static.folha.uol.com.br/paywall/*',
|
2017-08-15 18:33:07 -07:00
|
|
|
|
2017-03-17 21:25:04 -07:00
|
|
|
// Diário Catarinense
|
2017-11-27 13:59:58 -08:00
|
|
|
'http://dc.clicrbs.com.br/jornal-2015/jsp/paywall.jspx*',
|
2017-03-17 21:25:04 -07:00
|
|
|
|
|
|
|
// Jornal de Santa Catarina
|
2017-11-27 13:59:58 -08:00
|
|
|
'http://jornaldesantacatarina.clicrbs.com.br/jornal/jsp/paywall*'
|
2017-03-17 21:25:04 -07:00
|
|
|
],
|
2017-11-27 13:59:58 -08:00
|
|
|
types: ['xmlhttprequest']
|
2017-03-17 21:25:04 -07:00
|
|
|
},
|
2017-11-27 13:59:58 -08:00
|
|
|
['blocking']
|
2016-05-21 15:05:04 -07:00
|
|
|
);
|
2016-12-20 00:25:30 -08:00
|
|
|
|
2017-09-23 18:36:15 -07:00
|
|
|
// Cookie blocking
|
2016-12-20 00:25:30 -08:00
|
|
|
chrome.webRequest.onBeforeRequest.addListener(
|
2017-11-27 13:59:58 -08:00
|
|
|
function() {
|
2017-03-17 21:25:04 -07:00
|
|
|
chrome.cookies.remove({
|
|
|
|
'url': 'http://jota.info/*',
|
|
|
|
'name': 'articles'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
|
|
|
// JOTA
|
2017-11-27 13:59:58 -08:00
|
|
|
'http://jota.info/*'
|
2017-03-17 21:25:04 -07:00
|
|
|
],
|
2017-11-27 13:59:58 -08:00
|
|
|
types: ['main_frame']
|
2017-03-17 21:25:04 -07:00
|
|
|
}
|
2017-02-13 18:40:59 -08:00
|
|
|
);
|
2017-03-17 21:17:41 -07:00
|
|
|
|
2017-10-01 15:10:20 -07:00
|
|
|
chrome.webRequest.onBeforeRequest.addListener(
|
2017-11-27 13:59:58 -08:00
|
|
|
function() {
|
2017-10-01 15:10:20 -07:00
|
|
|
removeCookies('https://www.ft.com');
|
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
|
|
|
// Financial Times
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://*.ft.com/*'
|
2017-11-02 14:57:19 -07:00
|
|
|
]
|
2017-10-01 15:10:20 -07:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
function removeCookies(url) {
|
|
|
|
chrome.cookies.getAll({}, function(cookies) {
|
2017-11-27 13:59:58 -08:00
|
|
|
cookies.forEach(function(cookie) {
|
2017-10-01 15:10:20 -07:00
|
|
|
chrome.cookies.remove({
|
|
|
|
'url': url,
|
|
|
|
'name': cookie.name
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-23 18:36:15 -07:00
|
|
|
chrome.webRequest.onHeadersReceived.addListener(
|
2017-10-01 15:10:20 -07:00
|
|
|
// Block cookies from being set
|
2017-09-23 18:36:15 -07:00
|
|
|
function (details) {
|
|
|
|
details.responseHeaders.forEach(function(responseHeader) {
|
2017-11-27 13:59:58 -08:00
|
|
|
if (responseHeader.name.toLowerCase() == 'set-cookie') {
|
2017-09-23 18:36:15 -07:00
|
|
|
responseHeader.value = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
responseHeaders: details.responseHeaders
|
|
|
|
};
|
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
|
|
|
// Financial Times
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://*.ft.com/*'
|
2017-11-02 14:57:19 -07:00
|
|
|
]
|
2017-09-23 18:36:15 -07:00
|
|
|
},
|
2017-10-19 13:25:52 -07:00
|
|
|
['blocking', 'responseHeaders']
|
2017-09-23 18:36:15 -07:00
|
|
|
);
|
2017-03-17 21:17:41 -07:00
|
|
|
|
2017-10-19 13:25:52 -07:00
|
|
|
chrome.webRequest.onBeforeSendHeaders.addListener(
|
|
|
|
function(details) {
|
|
|
|
injectHeader('Cookie', '', details.requestHeaders);
|
|
|
|
return {requestHeaders: details.requestHeaders};
|
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
|
|
|
// Jornal Nexo
|
2017-10-31 09:22:42 -07:00
|
|
|
'*://api.nexojornal.com.br/*'
|
2017-10-19 14:37:49 -07:00
|
|
|
],
|
|
|
|
types: ['xmlhttprequest']
|
2017-10-19 13:25:52 -07:00
|
|
|
},
|
|
|
|
['blocking', 'requestHeaders']
|
|
|
|
);
|
2017-10-01 15:10:20 -07:00
|
|
|
|
2017-09-23 18:36:15 -07:00
|
|
|
// Referer injection
|
2017-03-17 21:17:41 -07:00
|
|
|
chrome.webRequest.onBeforeSendHeaders.addListener(
|
2017-03-17 21:25:04 -07:00
|
|
|
function(details) {
|
2017-10-19 13:25:52 -07:00
|
|
|
injectHeader(
|
|
|
|
'Referer',
|
|
|
|
'https://www.google.com.br/',
|
|
|
|
details.requestHeaders
|
2017-03-17 21:25:04 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
return {requestHeaders: details.requestHeaders};
|
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: [
|
|
|
|
// Financial Times
|
2017-11-27 13:59:58 -08:00
|
|
|
'*://www.ft.com/*'
|
2017-03-17 21:25:04 -07:00
|
|
|
],
|
2017-11-27 13:59:58 -08:00
|
|
|
types: ['xmlhttprequest', 'main_frame']
|
2017-03-17 21:25:04 -07:00
|
|
|
},
|
2017-11-27 13:59:58 -08:00
|
|
|
['blocking', 'requestHeaders']
|
2017-03-17 21:17:41 -07:00
|
|
|
);
|
2017-09-23 18:36:15 -07:00
|
|
|
|
2017-10-19 13:25:52 -07:00
|
|
|
function injectHeader(name, value, requestHeaders) {
|
2017-09-23 18:36:15 -07:00
|
|
|
/**
|
|
|
|
* @param {string} name - Name of the header to be inserted
|
|
|
|
* @param {string} value - Value of the header to be inserted
|
|
|
|
* @param {Object[]} requestHeaders - Provided by webRequest
|
|
|
|
* listeners in callback arg `details.requestHeader`
|
|
|
|
* @param {string} requestHeaders[].name
|
|
|
|
* @param {string} requestHeaders[].value
|
|
|
|
*/
|
2017-10-19 13:25:52 -07:00
|
|
|
var headerIndex = requestHeaders.findIndex(
|
|
|
|
x => x.name.toLowerCase() == name.toLowerCase());
|
2017-09-23 18:36:15 -07:00
|
|
|
|
|
|
|
var newHeader = {name: name, value: value};
|
|
|
|
if (headerIndex == -1)
|
|
|
|
requestHeaders.push(newHeader);
|
|
|
|
else
|
|
|
|
requestHeaders[headerIndex] = newHeader;
|
|
|
|
}
|