:pserver:anonymous@cvs.middle-man.sourceforge.net:/cvsroot/middle-man middleman
[middleman.git] / scripts / filter.pl
1 #!/usr/bin/perl
2 # This perl script provides filtering for undesireable garbage in HTML files
3 # It is intended to be used as an external parser for MiddleMan
4
5 while ( <STDIN> ) {
6    chomp;
7    $PAGE .= $_;
8    $PAGE .= "\n";
9 }
10
11 # Remove popups
12 # Note: alot of sites won't load with these enabled
13 # $PAGE =~ s/window\.open\s*\(/concat(/ig;
14 # $PAGE =~ s/([ =;])open\s*\(/$1concat(/ig;
15 # $PAGE =~ s/target=['"]?(_blank|_new)['"]?/notarget/ig;
16
17 # HTML Cookies
18 $PAGE =~ s/<meta\s+http-equiv=['"]?set-cookie['"]?\s+content=[^>].*>//ig;
19
20 # Don't let sites change status bar
21 $PAGE =~ s/window\.status\s*=/uselessness =/ig;
22
23 # Make sure popup's are resizeable and have scroll bar's
24 $PAGE =~ s/(<a\s+href[^>]+)resizable=['"]?(no|0|false)['"]?(.*>)/$1resizable="1"$3/ig;
25 $PAGE =~ s/(<a\s+href[^>]+)location=['"]?(no|0)['"]?(.*>)/$1location="1"$3/ig;
26 $PAGE =~ s/(<a\s+href[^>]+)status=['"]?(no|0)['"]?(.*>)/$1status="1"$3/ig;
27 $PAGE =~ s/(<a\s+href[^>]+)scrolling=['"]?(no|0|auto)['"]?(.*>)/$1scrolling="no"$3/ig;
28 $PAGE =~ s/(<a\s+href[^>]+)menubar=['"]?(no|0)['"]?(.*>)/$1menubar="1"$3/ig;
29
30 print $PAGE;