Merge branch 'master' into fix/folha

master
CaioWzy 2017-11-30 22:35:33 -03:00 committed by GitHub
commit a7b20aad1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 160 additions and 80 deletions

19
.eslintrc.yml Normal file
View File

@ -0,0 +1,19 @@
env:
browser: true
es6: true
webextensions: true
greasemonkey: true
extends: 'eslint:recommended'
rules:
indent:
- error
- 2
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
dist/
burlesco-rsa-key.pem
.DS_Store

30
.travis.yml Normal file
View File

@ -0,0 +1,30 @@
language: bash
install:
- npm install -g eslint
script:
- make lint
before_deploy:
- openssl aes-256-cbc -K $encrypted_351cc0f0ed5f_key -iv $encrypted_351cc0f0ed5f_iv
-in burlesco-rsa-key.pem.enc -out burlesco-rsa-key.pem -d
- make pre-build
- make build
deploy:
- provider: releases
skip_cleanup: true
api_key:
secure: KI+ygLjvGfAJaZsPw20gB35iDH+q1AAIK5OJ1khIc52GSW6P+d6ORU/nTRdysFjmaB4cfDpkjO1rCdwa6Ge4eOCXMY9E3/mS7ZxRY94PT9hELVoNnqiEK/Z4UnrNdrJgBTt7By7R3o5O4hrihGHSbfAqHmbKSg53Xs5BaEW+fOVr36vQYsx3WhK1RhfCh369WWnR0cHqGsaYSfwwkeSLBU6nzmuzivsUwOjxVoX21f8U25c2/rDJzcQ7yjc5STBjYwrnm4Kj/vJyleMP8J78k0Bt3k05O4NOBHwuGSSyC7iSX4SAisjO+dA8a6LfOgKFZXPfjfqI+xOKMdY96Ytlj3hPNe/y1vgWR+FDSV59sdV5XNzlm9MnXKlcTZGzs1bPl1l0oLil6B5cxGnnG3IxsAlEW2QPL8BXzkc+BGqWkoUa1DpPpA0i6H++bHSvFzHtwyS5JzxME8kOI/Go6Ly9ODA9+7F4tgfOQuhtsYbxZG/B6rIhAfiAcqU3MmwaRYcvX64+BosJ0e/gwDF6H5cd6LtTKz+BA3E/9vrtRyBqaxNVJJOpOBMy+GqpORO6i3wO3h1KDvpqqBo8BrXnbotJA6n9DEzKp7GXSzik5lKDLn1iK5sAHzgK2BZf23vsS/0odHboAHvMsV64jLxmQZvMtDgKqe0dzkbrIKdWROIpo6c=
file:
- dist/chrome/burlesco-chrome.zip
- dist/chromium/burlesco-chromium.crx
- dist/firefox/burlesco-firefox.xpi
- dist/opera/burlesco-opera.zip
- userscript/burlesco.user.js
on:
branch: master
tags: true
- provider: script
skip_cleanup: true
script: build/deploy.sh
on:
branch: master
tags: true

55
Makefile Normal file
View File

@ -0,0 +1,55 @@
SHELL:=/bin/bash
BROWSERS=firefox opera chrome chromium
DIST_DIR=dist
RSA_KEY=burlesco-rsa-key.pem
.PHONY: all clean lint pre-build build
all: clean lint pre-build build
clean:
rm -rf "$(DIST_DIR)"
lint:
find . -name '*.json' -exec python -c 'import json; json.load(open("{}"))' \;
eslint webext userscript
pre-build:
set -e ; \
for i in $(BROWSERS) ; do \
SRC_DIR="$(DIST_DIR)/$$i/src" ; \
mkdir -p "$$SRC_DIR" ; \
cp -r webext/* "$$SRC_DIR" ; \
if [ $$i != "firefox" ]; then \
perl -0pe 's/,\s+"applications": \{(.*?\}){2}//s' \
webext/manifest.json > "$$SRC_DIR/manifest.json" ; \
fi ; \
done
build:
set -e ; \
mkdir -p "$(DIST_DIR)" ; \
for i in $(BROWSERS) ; do \
echo $$i; \
DIR="$(DIST_DIR)/$$i" ; \
FILE=burlesco-$$i.zip ; \
if [ $$i = "chromium" ]; then \
if [ ! -f "$(RSA_KEY)" ]; then \
openssl genrsa -out "$(RSA_KEY)" 2048 2>/dev/null ;\
fi ; \
zip -jr9X "$$DIR/burlesco-chromium.zip" $$DIR/src/* ; \
openssl sha1 -sha1 -binary -sign "$(RSA_KEY)" < "$$DIR/burlesco-chromium.zip" > "$$DIR/burlesco-chromium.sig" ; \
openssl rsa -pubout -outform DER < "$(RSA_KEY)" > "$$DIR/burlesco-chromium.pub" 2>/dev/null ; \
byte_swap () { \
echo "$${1:6:2}$${1:4:2}$${1:2:2}$${1:0:2}" ; \
} ; \
crmagic_hex="4372 3234" ; \
version_hex="0200 0000" ; \
pub_len_hex=$$(byte_swap $$(printf '%08x\n' $$(ls -l "$$DIR/burlesco-chromium.pub" | awk '{print $$5}'))) ; \
sig_len_hex=$$(byte_swap $$(printf '%08x\n' $$(ls -l "$$DIR/burlesco-chromium.sig" | awk '{print $$5}'))) ; \
( \
echo "$$crmagic_hex $$version_hex $$pub_len_hex $$sig_len_hex" | xxd -r -p ; \
cat "$$DIR/burlesco-chromium.pub" "$$DIR/burlesco-chromium.sig" "$$DIR/burlesco-chromium.zip" ; \
) > "$$DIR/burlesco-chromium.crx" ; \
fi ; \
if [ $$i = "firefox" ]; then \
FILE="burlesco-$$i.xpi" ; \
fi ; \
if [ $$i != "chromium" ]; then \
zip -j "$$DIR/$$FILE" $$DIR/src/* ; \
fi ; \
done

View File

@ -1,27 +0,0 @@
#!/bin/bash
DIST="dist"
BROWSERS=("firefox" "opera" "chrome")
for i in "${BROWSERS[@]}"
do
DIR=$DIST/$i
mkdir -p $DIR/src
rm -rf "$DIR/*"
echo $DIR/webext
cp -r webext/* $DIR/src
file="burlesco-$i.zip"
if [ $i == "firefox" ]; then
file="burlesco-$i.xpi"
else
perl -0pe 's/,\s+"applications": \{(.*?\}){2}//s'\
$DIR/src/manifest.json > $DIR/src/_manifest.json
rm $DIR/src/manifest.json
mv $DIR/src/_manifest.json $DIR/src/manifest.json
fi
zip -j $DIR/$file $DIR/src/*
done

5
build/deploy.sh Executable file
View File

@ -0,0 +1,5 @@
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$cloudflare_zone/pagerules/$cloudflare_pagerule" \
-H "X-Auth-Email: $cloudflare_email" \
-H "X-Auth-Key: $cloudflare_token" \
-H "Content-Type: application/json" \
--data '{"targets":[{"target":"url","constraint":{"operator":"matches","value":"burles.co\/userscript\/burlesco.user.js*"}}],"actions":[{"id":"forwarding_url","value":{"url":"https:\/\/github.com\/rodorgas\/burlesco\/releases\/download\/'"$TRAVIS_TAG"'\/burlesco.user.js","status_code":302}}],"priority":1,"status":"active"}'

BIN
burlesco-rsa-key.pem.enc Normal file

Binary file not shown.

View File

@ -45,19 +45,19 @@
// GauchaZH
if (/gauchazh.clicrbs.com.br/.test(document.location.host)) {
document.addEventListener("DOMContentLoaded", function(event) {
document.addEventListener('DOMContentLoaded', function() {
function patchJs(jsurl) {
GM_xmlhttpRequest({
method: "GET",
method: 'GET',
url: jsurl,
onload: function(response) {
var injectme = this.responseText;
var injectme = response.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 script = document.createElement('script');
script.type = 'text/javascript';
var textNode = document.createTextNode(injectme);
script.appendChild(textNode);
document.head.appendChild(script);
@ -66,11 +66,11 @@ if (/gauchazh.clicrbs.com.br/.test(document.location.host)) {
});
}
var scripts = Array.from(document.getElementsByTagName('script'));
var script = scripts.find((el) => { return el.src.includes('static/main') });
var script = scripts.find((el) => { return el.src.includes('static/main'); });
if (script)
patchJs(script.src);
});
window.onload = function(event) {
window.onload = function() {
function check(){
if(document.getElementsByClassName('wrapper-paid-content')[0]){
document.getElementsByClassName('wrapper-paid-content')[0].innerHTML = '<p>Por favor aperte Ctrl-F5 para carregar o restante da notícia!</p>';
@ -83,13 +83,13 @@ if (/gauchazh.clicrbs.com.br/.test(document.location.host)) {
// JOTA
else if (/jota.info/.test(document.location.host)) {
document.cookie = "articles=null;path=/";
document.cookie = 'articles=null;path=/';
}
// run_at: document_idle
document.addEventListener("DOMContentLoaded", function(event) {
document.addEventListener('DOMContentLoaded', function() {
var codeld = null;
if (/([^\/].)?oglobo\.globo\.com/.test(document.location.host))
if (/oglobo\.globo\.com/.test(document.location.host))
codeld = 'paywallAtivo = false;';
else if (/www\.economist\.com/.test(document.location.host))
@ -142,7 +142,7 @@ document.addEventListener("DOMContentLoaded", function(event) {
anonymous: true,
onload: function(response) {
var parser = new DOMParser();
var htmlDoc = parser.parseFromString(this.responseText,'text/html');
var htmlDoc = parser.parseFromString(response.responseText,'text/html');
var injectme = htmlDoc.getElementsByTagName('html')[0].innerHTML;
if (document.getElementsByClassName('trial-subs__heading-pretext')[0]) {
document.write(injectme);

View File

@ -1,60 +1,59 @@
// Script blocking
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
function() {
return {cancel: true};
},
{
urls: [
// O Estado de S. Paulo
"*://*.estadao.com.br/paywall/*",
'*://*.estadao.com.br/paywall/*',
// Folha de S.Paulo
"*://paywall.folha.uol.com.br/*",
"*://static.folha.uol.com.br/paywall/*",
'*://paywall.folha.uol.com.br/*',
'*://static.folha.uol.com.br/paywall/*',
// O Globo
"*://ogjs.infoglobo.com.br/*/js/controla-acesso-aux.js",
'*://ogjs.infoglobo.com.br/*/js/controla-acesso-aux.js',
// Gazeta do Povo
"*://*.gazetadopovo.com.br/loader/v1/logan_full_toolbar.js*",
'*://*.gazetadopovo.com.br/loader/v1/logan_full_toolbar.js*',
// Correio Popular
"*://correio.rac.com.br/includes/js/novo_cp/fivewall.js*",
'*://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",
'*://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/*",
'*://*.jornalnh.com.br/includes/js/paywall.js*',
'*://blockv2.fivewall.com.br/*',
// Diário de Santa Maria
"*://www.rbsonline.com.br/cdn/scripts/SLoader.js",
'*://www.rbsonline.com.br/cdn/scripts/SLoader.js',
// New York Times
"*://*.nyt.com/js/mtr.js",
'*://*.nyt.com/js/mtr.js',
// Washington Post
"*://*.washingtonpost.com/*pwapi/*.js*",
"*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*",
'*://*.washingtonpost.com/*pwapi/*.js*',
'*://*.washingtonpost.com/*drawbridge/drawbridge.js?_*',
// O Globo, Exame, Super Interessante, Veja, The Economist
"*://cdn.tinypass.com/api/tinypass.min.js",
'*://cdn.tinypass.com/api/tinypass.min.js',
// UOL
"*://tm.jsuol.com.br/modules/content-gate.js",
'*://tm.jsuol.com.br/modules/content-gate.js',
// GauchaZH
"*://gauchazh.clicrbs.com.br/static/main*"
'*://gauchazh.clicrbs.com.br/static/main*'
],
types: ["script"]
types: ['script']
},
["blocking"]
['blocking']
);
// XHR blocking
WHITELIST = [
var WHITELIST = [
'http://paywall.folha.uol.com.br/status.php',
'https://paywall.folha.uol.com.br/status.php'
];
@ -68,23 +67,23 @@ chrome.webRequest.onBeforeRequest.addListener(
{
urls: [
// Folha de S.Paulo
"*://paywall.folha.uol.com.br/*",
"*://static.folha.uol.com.br/paywall/*",
'*://paywall.folha.uol.com.br/*',
'*://static.folha.uol.com.br/paywall/*',
// Diário Catarinense
"http://dc.clicrbs.com.br/jornal-2015/jsp/paywall.jspx*",
'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"]
types: ['xmlhttprequest']
},
["blocking"]
['blocking']
);
// Cookie blocking
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
function() {
chrome.cookies.remove({
'url': 'http://jota.info/*',
'name': 'articles'
@ -93,28 +92,27 @@ chrome.webRequest.onBeforeRequest.addListener(
{
urls: [
// JOTA
"http://jota.info/*"
'http://jota.info/*'
],
types: ["main_frame"]
types: ['main_frame']
}
);
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
console.log(details);
function() {
removeCookies('https://www.ft.com');
},
{
urls: [
// Financial Times
"*://*.ft.com/*"
'*://*.ft.com/*'
]
}
);
function removeCookies(url) {
chrome.cookies.getAll({}, function(cookies) {
cookies.forEach(function(cookie, index, array) {
cookies.forEach(function(cookie) {
chrome.cookies.remove({
'url': url,
'name': cookie.name
@ -127,7 +125,7 @@ chrome.webRequest.onHeadersReceived.addListener(
// Block cookies from being set
function (details) {
details.responseHeaders.forEach(function(responseHeader) {
if (responseHeader.name.toLowerCase() == "set-cookie") {
if (responseHeader.name.toLowerCase() == 'set-cookie') {
responseHeader.value = '';
}
});
@ -138,7 +136,7 @@ chrome.webRequest.onHeadersReceived.addListener(
{
urls: [
// Financial Times
"*://*.ft.com/*"
'*://*.ft.com/*'
]
},
['blocking', 'responseHeaders']
@ -173,11 +171,11 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
{
urls: [
// Financial Times
"*://www.ft.com/*"
'*://www.ft.com/*'
],
types: ["xmlhttprequest", "main_frame"]
types: ['xmlhttprequest', 'main_frame']
},
["blocking", "requestHeaders"]
['blocking', 'requestHeaders']
);
function injectHeader(name, value, requestHeaders) {

View File

@ -1,6 +1,6 @@
// run_at: document_idle
var code = null;
if (/([^\/].)?oglobo\.globo\.com/.test(document.location.host))
if (/oglobo\.globo\.com/.test(document.location.host))
code = 'paywallAtivo = false;';
else if (/www\.economist\.com/.test(document.location.host))