Melhora método de bypass no Nexo

master
Rodrigo Orem 2017-10-19 18:25:52 -02:00
parent 1f8dc14343
commit e864a42350
2 changed files with 21 additions and 28 deletions

View File

@ -37,7 +37,6 @@ chrome.webRequest.onBeforeRequest.addListener(
"*://*.nyt.com/js/mtr.js", "*://*.nyt.com/js/mtr.js",
// Washington Post // Washington Post
"*://*.washingtonpost.com/*pwapi/*.js*", "*://*.washingtonpost.com/*pwapi/*.js*",
"*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*" "*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*"
], ],
@ -144,21 +143,30 @@ chrome.webRequest.onHeadersReceived.addListener(
"*://gauchazh.clicrbs.com.br/*" "*://gauchazh.clicrbs.com.br/*"
] ]
}, },
['blocking','responseHeaders'] ['blocking', 'responseHeaders']
); );
chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) {
injectHeader('Cookie', '', details.requestHeaders);
return {requestHeaders: details.requestHeaders};
},
{
urls: [
// Jornal Nexo
'*://api.nexojornal.com.br/*'
]
},
['blocking', 'requestHeaders']
);
// Referer injection // Referer injection
chrome.webRequest.onBeforeSendHeaders.addListener( chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) { function(details) {
var headers = ['Referer']; injectHeader(
'Referer',
headers.forEach(header => 'https://www.google.com.br/',
insertHeader( details.requestHeaders
header,
'https://www.google.com.br/',
details.requestHeaders
)
); );
return {requestHeaders: details.requestHeaders}; return {requestHeaders: details.requestHeaders};
@ -173,7 +181,7 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
["blocking", "requestHeaders"] ["blocking", "requestHeaders"]
); );
function insertHeader(name, value, requestHeaders) { function injectHeader(name, value, requestHeaders) {
/** /**
* @param {string} name - Name of the header to be inserted * @param {string} name - Name of the header to be inserted
* @param {string} value - Value of the header to be inserted * @param {string} value - Value of the header to be inserted
@ -182,7 +190,8 @@ function insertHeader(name, value, requestHeaders) {
* @param {string} requestHeaders[].name * @param {string} requestHeaders[].name
* @param {string} requestHeaders[].value * @param {string} requestHeaders[].value
*/ */
var headerIndex = requestHeaders.findIndex(x => x.name == name); var headerIndex = requestHeaders.findIndex(
x => x.name.toLowerCase() == name.toLowerCase());
var newHeader = {name: name, value: value}; var newHeader = {name: name, value: value};
if (headerIndex == -1) if (headerIndex == -1)

View File

@ -37,22 +37,6 @@ else if (/gauchazh.clicrbs.com.br/.test(document.location.host)) {
sessionStorage.clear();'; sessionStorage.clear();';
} }
else if (/www.nexojornal.com.br/.test(document.location.host)) {
code = "paywallContainer = document.getElementsByClassName('new-paywall-container')[0];\
paywallContent = paywallContainer.getAttribute('data-paywall-content');\
nexoApiURL = paywallContainer.getAttribute('data-paywall-check');\
xmlhttp = new XMLHttpRequest();\
xmlhttp.onreadystatechange = function() {\
if (this.readyState == 4 && (this.status == 200 || this.status == 201 || this.status == 401)) {\
access_token = JSON.parse(this.responseText)['access_token'];\
paywallContainer.className = 'wf-placeholder';\
paywallContainer.setAttribute('data-loadURL', paywallContent.replace('{access_token}', access_token));\
paywallContainer.setAttribute('data-skip-profiles', '');\
WFLazyLoader.loadFragment()}};\
xmlhttp.open('GET', nexoApiURL, true);\
xmlhttp.send();";
}
if (code !== null) { if (code !== null) {
var script = document.createElement('script'); var script = document.createElement('script');
script.textContent = code; script.textContent = code;