Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 42 additions & 40 deletions src/burlesco.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Burlesco
// @namespace https://burles.co/
// @version 14.1
// @version 14.2
// @description Leia notícias sem ser assinante, burle o paywall
// @author rodorgas & AugustoResende
// @supportURL https://burles.co
Expand Down Expand Up @@ -150,6 +150,39 @@ else if (/correiodopovo\.com\.br/.test(document.location.host)) {
cleanPaywall();
}

else if (/folha\.uol\.com\.br/.test(document.location.host)) {
// Injetado em document_start para o fetch já estar interceptado quando o
// wall.js pedir o wall.json.
injectPageCode(`
const originalFetch = window.fetch;
window.fetch = function(resource, init) {
const url = typeof resource === 'string' ? resource : (resource && resource.url) || String(resource);
if (url.includes('paywall.folha.uol.com.br/wall.json')) {
console.log('[FolhaPaywall] Interceptando paywall.json');
// Retorna uma resposta fake que zera o paywall
return Promise.resolve(new Response(JSON.stringify({ paywall: 'off', status: 'ok' }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
}));
}
return originalFetch.apply(this, arguments);
};
`);
}

else if (/estadao\.com\.br/.test(document.location.host)) {
// Injetado em document_start, antes do pwz.js carregar.
injectPageCode(`
Object.defineProperty(window, 'pwz', {
configurable: true,
writable: false,
value: function () {
console.log('paywall bloqueado');
}
});
`);
}

// run_at: document_idle
document.addEventListener('DOMContentLoaded', function() {
var code = null;
Expand Down Expand Up @@ -250,41 +283,6 @@ document.addEventListener('DOMContentLoaded', function() {
`;
}

else if (/folha\.uol\.com\.br/.test(document.location.host)) {
code = `
window.addEventListener('DOMContentLoaded', () => {
const originalFetch = window.fetch;
window.fetch = function(resource, init) {
// Verifica se a URL contém o endpoint do paywall JSON
if (typeof resource === 'string' && resource.includes('paywall.folha.uol.com.br/wall.json')) {
console.log('[FolhaPaywall] Interceptando paywall.json');
// Retorna uma resposta fake que zera o paywall
const fakeResponse = new Response(JSON.stringify({ paywall: "off", status: "ok" }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
return Promise.resolve(fakeResponse);
}
return originalFetch.apply(this, arguments);
};
});
`;
}

else if (/estadao\.com\.br/.test(document.location.host)) {
code = `
window.addEventListener('DOMContentLoaded', () => {
Object.defineProperty(window, 'pwz', {
configurable: true,
writable: false,
value: function () {
console.log('paywall bloqueado');
}
});
});
`;
}

else if (/abril\.com\.br/.test(document.location.host))
code = `
window.setTimeout(function() {
Expand Down Expand Up @@ -478,13 +476,17 @@ document.addEventListener('DOMContentLoaded', function() {
}

if (code !== null) {
var script = document.createElement('script');
script.textContent = code;
(document.head||document.documentElement).appendChild(script);
script.parentNode.removeChild(script);
injectPageCode(code);
}
});

function injectPageCode(code) {
var script = document.createElement('script');
script.textContent = code;
(document.head||document.documentElement).appendChild(script);
script.parentNode.removeChild(script);
}

function eraseAllCookies() {
var cookieList = document.cookie.split (/;\s*/);
for (var J = cookieList.length - 1; J >= 0; --J) {
Expand Down
Loading