From 8f2149e3a5b29bfac9f2675e28f39e86658bf2c0 Mon Sep 17 00:00:00 2001 From: Paul Butler Date: Mon, 14 Aug 2017 19:08:41 -0400 Subject: [PATCH] generate extension from master list --- Makefile | 9 ++++-- extension/barbblock.js | 44 +++++++++++++------------- extension/manifest.json | 4 +-- src/generate_blacklist.py | 4 +++ templates/domain-list.txt.tmpl | 4 +-- templates/extension-barbblock.js.tmpl | 10 ++++++ templates/extension-manifest.json.tmpl | 22 +++++++++++++ 7 files changed, 68 insertions(+), 29 deletions(-) create mode 100644 templates/extension-barbblock.js.tmpl create mode 100644 templates/extension-manifest.json.tmpl diff --git a/Makefile b/Makefile index d4b77ec..6b5732c 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ -all : all_blacklists BarbBlock.txt +all : all_blacklists BarbBlock.txt package -blacklists/% : src/generate_blacklist.py blacklist.yaml templates/%.tmpl +blacklists/%.txt : src/generate_blacklist.py blacklist.yaml templates/%.txt.tmpl python $^ $@ -package : +extension/% : src/generate_blacklist.py blacklist.yaml templates/extension-%.tmpl + python $^ $@ + +package : extension/manifest.json extension/barbblock.js cd extension; zip barbblock.zip -r ./ -x *.git* mv extension/barbblock.zip ./ diff --git a/extension/barbblock.js b/extension/barbblock.js index a3e7839..88130a6 100644 --- a/extension/barbblock.js +++ b/extension/barbblock.js @@ -1,22 +1,33 @@ var urls = [ - '*://functionalclam.com/*', // Issue #1 + '*://functionalclam.com/*', + '*://2znp09oa.com/*', + '*://4jnzhl0d0.com/*', + '*://6ldu6qa.com/*', + '*://82o9v830.com/*', '*://abandonedclover.com/*', '*://abruptroad.com/*', '*://actuallysheep.com/*', + '*://ak0gsh40.com/*', '*://ambitiousagreement.com/*', '*://anxiousapples.com/*', + '*://argyresthia.com/*', + '*://awzbijw.com/*', + '*://balloontexture.com/*', '*://baskettexture.com/*', '*://bawdybeast.com/*', '*://beamincrease.com/*', '*://beamkite.com/*', '*://boilingbeetle.com/*', + '*://boredcrown.com/*', '*://brassrule.com/*', '*://broadboundary.com/*', + '*://broadcastbed.com/*', '*://calmfoot.com/*', '*://cherrythread.com/*', '*://chiefcurrent.com/*', '*://chinchickens.com/*', + '*://comfortablecheese.com/*', '*://commandwalk.com/*', '*://concernrain.com/*', '*://consciouscabbage.com/*', @@ -47,12 +58,16 @@ var urls = [ '*://giddycoat.com/*', '*://gorgeousground.com/*', '*://greetzebra.com/*', + '*://greyinstrument.com/*', '*://guardedgovernor.com/*', '*://guitarbelieve.com/*', + '*://h78xb.pw/*', + '*://hfc195b.com/*', '*://hilariouszinc.com/*', '*://illustriousoatmeal.com/*', '*://incrediblesugar.com/*', '*://ivykiosk.com/*', + '*://j93557g.com/*', '*://jewelcheese.com/*', '*://karisimbi.net/*', '*://limpingline.com/*', @@ -62,6 +77,7 @@ var urls = [ '*://lp3tdqle.com/*', '*://lumpyleaf.com/*', '*://matchcows.com/*', + '*://messagenovice.com/*', '*://mixedreading.com/*', '*://mowfruit.com/*', '*://ovalpigs.com/*', @@ -76,7 +92,9 @@ var urls = [ '*://quaintcan.com/*', '*://quicksandear.com/*', '*://readgoldfish.com/*', + '*://rebelsubway.com/*', '*://receptiveink.com/*', + '*://resolutekey.com/*', '*://rulerabbit.com/*', '*://saysidewalk.com/*', '*://scarcestream.com/*', @@ -113,36 +131,18 @@ var urls = [ '*://tracedesire.com/*', '*://trickycelery.com/*', '*://tritetongue.com/*', + '*://truckstomatoes.com/*', '*://unknowntray.com/*', '*://unusualtitle.com/*', '*://voicevegetable.com/*', - '*://h78xb.pw/*', - '*://2znp09oa.com/*', - '*://4jnzhl0d0.com/*', - '*://6ldu6qa.com/*', - '*://82o9v830.com/*', - '*://ak0gsh40.com/*', - '*://argyresthia.com/*', - '*://awzbijw.com/*', - '*://balloontexture.com/*', - '*://boredcrown.com/*', - '*://broadcastbed.com/*', - '*://comfortablecheese.com/*', - '*://greyinstrument.com/*', - '*://hfc195b.com/*', - '*://j93557g.com/*', - '*://messagenovice.com/*', - '*://rebelsubway.com/*', - '*://resolutekey.com/*', - '*://truckstomatoes.com/*', '*://wateryvan.com/*', '*://wirecomic.com/*', '*://xovq5nemr.com/*', - '*://zbwp6ghm.com/*', + '*://zbwp6ghm.com/*' ]; chrome.webRequest.onBeforeRequest.addListener( (details) => ({cancel: true}), {urls: urls}, ["blocking"] -); +); \ No newline at end of file diff --git a/extension/manifest.json b/extension/manifest.json index 199da56..cd8058e 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,8 +1,8 @@ { "manifest_version": 2, "name": "BarbBlock", - "description": "Blocks requests to sites which have used DMCA takedowns to force removal from other blacklists.", - "version": "1.0", + "description": "Blocks requests to sites which have used legal threats to remove themselves from other blacklists.", + "version": "1.1", "icons": { "16": "icon/icon16.png", "32": "icon/icon32.png", diff --git a/src/generate_blacklist.py b/src/generate_blacklist.py index ad38e90..b03aa14 100644 --- a/src/generate_blacklist.py +++ b/src/generate_blacklist.py @@ -2,6 +2,7 @@ import argparse import os import yaml + import jinja2 @@ -10,6 +11,9 @@ def run_template_engine(blacklist_file, template_file, output_file): with open(blacklist_file) as bf: context = yaml.load(bf) + + context['domains'] = [d for blockset in context['blacklist'] + for d in blockset['domains']] result = jinja2.Environment( loader=jinja2.FileSystemLoader(template_path or './') diff --git a/templates/domain-list.txt.tmpl b/templates/domain-list.txt.tmpl index 8b9965f..3bbae3a 100644 --- a/templates/domain-list.txt.tmpl +++ b/templates/domain-list.txt.tmpl @@ -1,2 +1,2 @@ -{% for blockset in blacklist %}{% for domain in blockset.domains %}{{ domain }} -{% endfor %}{% endfor %} +{% for domain in domains %}{{ domain }} +{% endfor %} diff --git a/templates/extension-barbblock.js.tmpl b/templates/extension-barbblock.js.tmpl new file mode 100644 index 0000000..0d0a7dd --- /dev/null +++ b/templates/extension-barbblock.js.tmpl @@ -0,0 +1,10 @@ + +var urls = [ +{% for domain in domains %} '*://{{ domain }}/*'{% if not loop.last %},{% endif %} +{% endfor %}]; + +chrome.webRequest.onBeforeRequest.addListener( + (details) => ({cancel: true}), + {urls: urls}, + ["blocking"] +); diff --git a/templates/extension-manifest.json.tmpl b/templates/extension-manifest.json.tmpl new file mode 100644 index 0000000..c096234 --- /dev/null +++ b/templates/extension-manifest.json.tmpl @@ -0,0 +1,22 @@ +{ + "manifest_version": 2, + "name": "{{ name }}", + "description": "{{ description }}", + "version": "{{ version }}", + "icons": { + "16": "icon/icon16.png", + "32": "icon/icon32.png", + "48": "icon/icon48.png", + "128": "icon/icon128.png" + }, + "background": { + "scripts": [ + "barbblock.js" + ] + }, + "permissions": [ + "webRequest", + "webRequestBlocking", + "" + ] +} \ No newline at end of file