generated
[privoxy.git] / doc / webserver / user-manual / filter-file.html
1 <HTML
2 ><HEAD
3 ><TITLE
4 >The Filter File</TITLE
5 ><META
6 NAME="GENERATOR"
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64
8 "><LINK
9 REL="HOME"
10 TITLE="Privoxy User Manual"
11 HREF="index.html"><LINK
12 REL="PREVIOUS"
13 TITLE="Actions Files"
14 HREF="actions-file.html"><LINK
15 REL="NEXT"
16 TITLE="Templates"
17 HREF="templates.html"><LINK
18 REL="STYLESHEET"
19 TYPE="text/css"
20 HREF="../p_doc.css"></HEAD
21 ><BODY
22 CLASS="SECT1"
23 BGCOLOR="#EEEEEE"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 WIDTH="100%"
32 BORDER="0"
33 CELLPADDING="0"
34 CELLSPACING="0"
35 ><TR
36 ><TH
37 COLSPAN="3"
38 ALIGN="center"
39 >Privoxy User Manual</TH
40 ></TR
41 ><TR
42 ><TD
43 WIDTH="10%"
44 ALIGN="left"
45 VALIGN="bottom"
46 ><A
47 HREF="actions-file.html"
48 >Prev</A
49 ></TD
50 ><TD
51 WIDTH="80%"
52 ALIGN="center"
53 VALIGN="bottom"
54 ></TD
55 ><TD
56 WIDTH="10%"
57 ALIGN="right"
58 VALIGN="bottom"
59 ><A
60 HREF="templates.html"
61 >Next</A
62 ></TD
63 ></TR
64 ></TABLE
65 ><HR
66 ALIGN="LEFT"
67 WIDTH="100%"></DIV
68 ><DIV
69 CLASS="SECT1"
70 ><H1
71 CLASS="SECT1"
72 ><A
73 NAME="FILTER-FILE"
74 >10. The Filter File</A
75 ></H1
76 ><P
77 > Any web page can be dynamically modified with the filter file. This
78  modification can be removal, or re-writing, of any web page content,
79  including tags and non-visible content. The default filter file is
80  oddly enough <TT
81 CLASS="FILENAME"
82 >default.filter</TT
83 >, located in the config
84  directory. </P
85 ><P
86 > This is potentially a very powerful feature, and requires knowledge of both 
87  <SPAN
88 CLASS="QUOTE"
89 >"regular expression"</SPAN
90 > and HTML in order create custom 
91  filters. But, there are a number of useful filters included with 
92  <SPAN
93 CLASS="APPLICATION"
94 >Privoxy</SPAN
95 > for many common situations.</P
96 ><P
97 > The included example file is divided into sections. Each section begins 
98  with the <TT
99 CLASS="LITERAL"
100 >FILTER</TT
101 > keyword, followed by the identifier 
102  for that section, e.g. <SPAN
103 CLASS="QUOTE"
104 >"FILTER: webbugs"</SPAN
105 >. Each section performs
106  a similar type of filtering, such as <SPAN
107 CLASS="QUOTE"
108 >"html-annoyances"</SPAN
109 >.</P
110 ><P
111 > This file uses regular expressions to alter or remove any string in the
112  target page. The expressions can only operate on one line at a time. Some
113  examples from the included default <TT
114 CLASS="FILENAME"
115 >default.filter</TT
116 >:</P
117 ><P
118 > Stop web pages from displaying annoying messages in the status bar by
119  deleting such references:</P
120 ><P
121 > <TT
122 CLASS="LITERAL"
123 >  <P
124 CLASS="LITERALLAYOUT"
125 >&nbsp;FILTER:&nbsp;html-annoyances<br>
126 <br>
127 &nbsp;#&nbsp;New&nbsp;browser&nbsp;windows&nbsp;should&nbsp;be&nbsp;resizeable&nbsp;and&nbsp;have&nbsp;a&nbsp;location&nbsp;and&nbsp;status<br>
128 &nbsp;#&nbsp;bar.&nbsp;Make&nbsp;it&nbsp;so.<br>
129 &nbsp;#<br>
130 &nbsp;s/resizable="?(no|0)"?/resizable=1/ig&nbsp;s/noresize/yesresize/ig<br>
131 &nbsp;s/location="?(no|0)"?/location=1/ig&nbsp;s/status="?(no|0)"?/status=1/ig<br>
132 &nbsp;s/scrolling="?(no|0|Auto)"?/scrolling=1/ig<br>
133 &nbsp;s/menubar="?(no|0)"?/menubar=1/ig&nbsp;<br>
134 <br>
135 &nbsp;#&nbsp;The&nbsp;&#60;BLINK&#62;&nbsp;tag&nbsp;was&nbsp;a&nbsp;crime!<br>
136 &nbsp;#<br>
137 &nbsp;s*&#60;blink&#62;|&#60;/blink&#62;**ig<br>
138 <br>
139 &nbsp;#&nbsp;Is&nbsp;this&nbsp;evil?&nbsp;<br>
140 &nbsp;#<br>
141 &nbsp;#s/framespacing="?(no|0)"?//ig<br>
142 &nbsp;#s/margin(height|width)=[0-9]*//gi<br>
143 &nbsp;&nbsp;&nbsp;</P
144
145  </TT
146 ></P
147 ><P
148 > Just for kicks, replace any occurrence of <SPAN
149 CLASS="QUOTE"
150 >"Microsoft"</SPAN
151 > with
152  <SPAN
153 CLASS="QUOTE"
154 >"MicroSuck"</SPAN
155 >, and have a little fun with topical buzzwords: </P
156 ><P
157 > <TT
158 CLASS="LITERAL"
159 >  <P
160 CLASS="LITERALLAYOUT"
161 >&nbsp;FILTER:&nbsp;fun<br>
162 <br>
163 &nbsp;s/microsoft(?!.com)/MicroSuck/ig<br>
164 <br>
165 &nbsp;#&nbsp;Buzzword&nbsp;Bingo:<br>
166 &nbsp;#<br>
167 &nbsp;s/industry-leading|cutting-edge|award-winning/&#60;font&nbsp;color=red&#62;&#60;b&#62;BINGO!&#60;/b&#62;&#60;/font&#62;/ig<br>
168 &nbsp;&nbsp;&nbsp;</P
169
170  </TT
171 ></P
172 ><P
173 > Kill those pesky little web-bugs:</P
174 ><P
175 > <TT
176 CLASS="LITERAL"
177 >  <P
178 CLASS="LITERALLAYOUT"
179 >&nbsp;#&nbsp;webbugs:&nbsp;Squish&nbsp;WebBugs&nbsp;(1x1&nbsp;invisible&nbsp;GIFs&nbsp;used&nbsp;for&nbsp;user&nbsp;tracking)<br>
180 &nbsp;FILTER:&nbsp;webbugs<br>
181 <br>
182 &nbsp;s/&#60;img\s+[^&#62;]*?(width|height)\s*=\s*['"]?1\D[^&#62;]*?(width|height)\s*=\s*['"]?1(\D[^&#62;]*?)?&#62;/&#60;!--&nbsp;Squished&nbsp;WebBug&nbsp;--&#62;/sig<br>
183 &nbsp;&nbsp;&nbsp;</P
184
185  </TT
186 ></P
187 ><DIV
188 CLASS="SECT2"
189 ><H2
190 CLASS="SECT2"
191 ><A
192 NAME="AEN2339"
193 >10.1. The <I
194 CLASS="EMPHASIS"
195 >+filter</I
196 > Action</A
197 ></H2
198 ><P
199 > Filters are enabled with the <A
200 HREF="actions-file.html#FILTER"
201 TARGET="_top"
202 ><SPAN
203 CLASS="QUOTE"
204 >"+filter"</SPAN
205 ></A
206 > action from within 
207  one of the actions files. <SPAN
208 CLASS="QUOTE"
209 >"+filter"</SPAN
210 > requires one parameter, which 
211  should match one of the section identifiers in the filter file itself. Example:</P
212 ><TABLE
213 BORDER="0"
214 BGCOLOR="#E0E0E0"
215 WIDTH="100%"
216 ><TR
217 ><TD
218 ><PRE
219 CLASS="SCREEN"
220 >  +filter{html-annoyances}</PRE
221 ></TD
222 ></TR
223 ></TABLE
224 ><P
225 > This would activate that particular filter. Similarly, <SPAN
226 CLASS="QUOTE"
227 >"+filter"</SPAN
228 >
229  can be turned off for selected sites as:
230  <SPAN
231 CLASS="QUOTE"
232 >"-filter{html-annoyances}"</SPAN
233 >. Remember too, all actions are off by
234  default, unless they are explicity enabled in one of the actions files.</P
235 ></DIV
236 ></DIV
237 ><DIV
238 CLASS="NAVFOOTER"
239 ><HR
240 ALIGN="LEFT"
241 WIDTH="100%"><TABLE
242 WIDTH="100%"
243 BORDER="0"
244 CELLPADDING="0"
245 CELLSPACING="0"
246 ><TR
247 ><TD
248 WIDTH="33%"
249 ALIGN="left"
250 VALIGN="top"
251 ><A
252 HREF="actions-file.html"
253 >Prev</A
254 ></TD
255 ><TD
256 WIDTH="34%"
257 ALIGN="center"
258 VALIGN="top"
259 ><A
260 HREF="index.html"
261 >Home</A
262 ></TD
263 ><TD
264 WIDTH="33%"
265 ALIGN="right"
266 VALIGN="top"
267 ><A
268 HREF="templates.html"
269 >Next</A
270 ></TD
271 ></TR
272 ><TR
273 ><TD
274 WIDTH="33%"
275 ALIGN="left"
276 VALIGN="top"
277 >Actions Files</TD
278 ><TD
279 WIDTH="34%"
280 ALIGN="center"
281 VALIGN="top"
282 >&nbsp;</TD
283 ><TD
284 WIDTH="33%"
285 ALIGN="right"
286 VALIGN="top"
287 >Templates</TD
288 ></TR
289 ></TABLE
290 ></DIV
291 ></BODY
292 ></HTML
293 >