Skip to content

Instantly share code, notes, and snippets.

@ahupowerdns
Created January 19, 2016 15:39
Show Gist options
  • Save ahupowerdns/84e8a8ea525f093f2e2a to your computer and use it in GitHub Desktop.
Save ahupowerdns/84e8a8ea525f093f2e2a to your computer and use it in GitHub Desktop.
(
echo 'return{'
for a in $(jq '.[].trigger["url-filter"]' disconnect-advertising.json |
cut -f3 -d? | sed 's:\\\\.:.:g' | sed s:\"::)
do
echo \"$a\",
done
echo '}'
) > blocklist.lua
@jangrewe
Copy link

A simpler(?) command: jq -r '.[].trigger["url-filter"]' disconnect-advertising.json | sed 's:.*?::; s:\\::g; s:/.*::'
Notice the -r argument for jq, that strips a lot of characters already.
Full script: https://git.faked.org/jan/powerdns-adblock/blob/master/generate_blocklist.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment