#!/usr/bin/perl
#
# Scope:
# Perl script automating blocking on [[Meta:WikiProject on open proxies]].
# Opens all pages with IP's to block so that the administrator is only
# required to click the "block" button.
# Simplifies work of administrators of non-English language projects
# (can change links from en.wikibooks to de.wikibooks and so on).
#
# Usage:
# 1. Open [[Meta:WikiProject on open proxies/Reviewed]] in your browser and
# select "View source" option.
# 2. Save HTML source to "blockinput.html" file in the directory where you
# store this script (you save only part of the table,
# this need not to be a valid HTML file). You may divide the list into parts,
# save only one part and repeat the procedure, because your browser may
# die if you choose too many IP's.
# 3. Set $out_domain here to project you want to block on (eg. "en.wiktionary.org")
# 4. Run this script ("./block-extract-pl" or "perl block-extract.pl")
# 5. Open "openToBlockAll.html" file in your browser. It will open many windows
# and autmatically click the "block" button. Page first opened in browser
# will be closed.
#
# Note:
# You will need JavaScript for the script to be able to run. If no windows/tabs
# with block form are opened, try disabling pop-up blocker in your browser.
#
# Author:
# [[User:Derbeth]]
#
# License:
# 2-clause BSD, http://www.opensource.org/licenses/bsd-license.php
#
# Version:
# 0.5
my $in_domain = "en.wikipedia.org";
my $out_domain = "pl.wikipedia.org";
open IN, "blockInput.html";
open OUT, ">openToBlockAll.html";
print OUT <<HTML;
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>blockpage</title>
<script type="text/javascript">
function openAllBlockPages() {
var pages=new Array(
HTML
while (<IN>) {
if( m|"(http://$in_domain/w/index.php\?title=Special:Blockip&wpBlockAddress=[^"]+)"| ) { #"{
$_ = $1;
s/$in_domain/$out_domain/;
s/&/&/g;
s/wpAnonOnly=1/wpAnonOnly=0/; # do we really need sockpuppets creation from anon proxies?
print OUT "'$_',\n";
}
}
print OUT <<HTML;
'');
for (x in pages) {
if( pages[x] != '' ) window.open(pages[x]);
}
window.close();
}
</script></head>
<body onload="openAllBlockPages();">
</body>
</html>
HTML