Skip to content

Instantly share code, notes, and snippets.

@hryamzik
Last active August 12, 2019 21:12
Show Gist options
  • Save hryamzik/4499eca657ece8d17da304012936e01f to your computer and use it in GitHub Desktop.
Save hryamzik/4499eca657ece8d17da304012936e01f to your computer and use it in GitHub Desktop.
[Adblock Plus 2.0]
! Last modified: 12 Aug 2019 21:12 UTC
! Version: 201908122112
! Checksum: UsUJJ29xVUmq5NVbdbkbRg
! Title: hryamzik's list
! Expires: 1 days (update frequency)
! Homepage: localhost
! Licence: BSD
livejournal.com##div.b-discoverytimes
livejournal.com##div[class*="-adv"]
livejournal.com##div[class*="banner"]
livejournal.com##DIV[class*="discoverytimes"]
livejournal.com##.sidebar-custom
livejournal.com##div[id*="sidebar_after_widgets"]
360tv.ru##div.page-header
360tv.ru##div.info-toolbar
360tv.ru##div.tgb-vertical
360tv.ru##div.article__share
360tv.ru##div#SVPR-CM87-bcYF-OsXk
360tv.ru##div.page-footer
360tv.ru##div.content-column_left
360tv.ru##div.content-column_right
360tv.ru##div.row.top-public
360tv.ru##div.row.middle-public
habrahabr.ru#div(id^=yandex_rtb_)
habrahabr.ru##div.xyz_wrapper
vk.com#div(id^=ads_)
vk.com##div[class^="ads_"]
###yandex_ad_bottom
habrahabr.ru##.xyz_wrapper
geektimes.ru##.xyz_wrapper
##.ya_partner
##.yandex_ad
habrahabr.ru#div(id*=adriver_banner)
geektimes.ru#div(id*=adriver_banner)
cnet.com##.popOnScroll
yandex.ru##.teaser__content
macappstore.org##.jzrCpsIDefU1-default
###cookies
||habracdn.net/habr/images/1467724399/spacer.png
||rutrk.org/iframe/kadam-240x120-1.html
||awaps.yandex.net/0/c1/tN7JQ6ZIfe9rHzgEnx+pqMm6edrySH0oh2AOQFL0zC6Q92Dvh1wDbJbzlJIal_t0d0KfGrenZDKdDHJIMxr7vQ1aXZFHjGjJHkSug4nKtteVQ9Ntn89uyvlVSgZ_tC9SIv2jbV4bcyf8gm3KMnC-dk0-wU0DNp5kwuyjv0QchjRtWkBsdgYtiBSkq_tWmWSIeGJ6e9p5-dsb-4sI0syReNPiHsomOY1AxHgNel0C4G4gcgPVodmzUcy_tzZMsNGICnZktTetrsVnUsomHZDn7aoQmSykCXrMbyh38w39MXzrltBGGczuj_nXIpRFUAPF066EU4gYymoRuKRSaJUIIGxSreJHHlp02njvQjjhjbY_A_.gif
http://an.yandex.ru/*
googlesyndication.com^
*.yandex.net/get-direct*
||vidtech.cbsinteractive.com^$domain=cnet.com
||players.brightcove.net^$domain=pcworld.com
rutracker.org###mg-informers
4pda.ru##DIV[class="r0wZFz113s"]
192.168.8.254###r50b
businessinsider.com##.tp-iframe-wrapper.tp-active
vesti.ru###widget-unit
vesti.ru##div[class^="directadvert-block"]
vesti.ru##div[class^="adv-list"]
@hryamzik
Copy link
Author

hryamzik commented May 19, 2017

https://raw.githubusercontent.com/ryanberckmans/adblockplus/master/addChecksum.pl
UPD:

#!/usr/bin/perl

#############################################################################
# This is a reference script to add checksums to downloadable               #
# subscriptions. The checksum will be validated by Adblock Plus on download #
# and checksum mismatches (broken downloads) will be rejected.              #
#                                                                           #
# To add a checksum to a subscription file, run the script like this:       #
#                                                                           #
#   perl addChecksum.pl subscription.txt                                    #
#                                                                           #
# Note: your subscription file should be saved in UTF-8 encoding, otherwise #
# the generated checksum might be incorrect.                                #
#                                                                           #
#############################################################################

use strict;
use warnings;
use Digest::MD5 qw(md5_base64);

die "Usage: $^X $0 subscription.txt\n" unless @ARGV;

my $file = $ARGV[0];
my $data = readFile($file);

# Remove already existing checksum
$data =~ s/^.*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n//gmi;

# Calculate new checksum: remove all CR symbols and empty
# lines and get an MD5 checksum of the result (base64-encoded,
# without the trailing = characters).
my $checksumData = $data;
$checksumData =~ s/\r//g;
$checksumData =~ s/\n+/\n/g;

# Calculate new checksum
my $checksum = md5_base64($checksumData);

# Insert checksum into the file
$data =~ s/(\r?\n)/$1! Checksum: $checksum$1/;

# Generate date markers
use POSIX qw(strftime);

my $versionString = strftime "%Y%m%d%H%M", gmtime;
my $lastModifiedString = strftime "%e %b %Y %H:%M UTC", gmtime;

# Remove already time markers
$data =~ s/^.*!\s*version[\s\-:]+([\w\+\/=]+).*\n//gmi;
$data =~ s/^.*!\s*last\s+modified[\s\-:]+([\w\+\/=]+).*\n//gmi;

# Insert dates into the file
$data =~ s/(\r?\n)/$1! Version: $versionString$1/;
$data =~ s/(\r?\n)/$1! Last modified: $lastModifiedString$1/;

writeFile($file, $data);

sub readFile
{
  my $file = shift;

  open(local *FILE, "<", $file) || die "Could not read file '$file'";
  binmode(FILE);
  local $/;
  my $result = <FILE>;
  close(FILE);

  return $result;
}

sub writeFile
{
  my ($file, $contents) = @_;

  open(local *FILE, ">", $file) || die "Could not write file '$file'";
  binmode(FILE);
  print FILE $contents;
  close(FILE);
}

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