2006-02-02 10:04:11 -05:00
|
|
|
import re
|
2006-09-02 06:07:29 -04:00
|
|
|
import sys
|
2006-02-02 10:04:11 -05:00
|
|
|
|
2006-01-29 08:58:03 -05:00
|
|
|
dumbprefixes = {
|
|
|
|
"7th" : "http://7thguard.net/",
|
2006-09-02 06:07:29 -04:00
|
|
|
"b" : "http://babelfish.altavista.com/babelfish/tr/",
|
|
|
|
"bz" : "http://bugzilla.elinks.cz/",
|
|
|
|
"bug" : "http://bugzilla.elinks.cz/",
|
|
|
|
"d" : "http://www.dict.org/",
|
2006-01-29 08:58:03 -05:00
|
|
|
"g" : "http://www.google.com/",
|
|
|
|
"gg" : "http://www.google.com/",
|
|
|
|
"go" : "http://www.google.com/",
|
|
|
|
"fm" : "http://www.freshmeat.net/",
|
|
|
|
"sf" : "http://www.sourceforge.net/",
|
|
|
|
"dbug" : "http://bugs.debian.org/",
|
|
|
|
"dpkg" : "http://packages.debian.org/",
|
|
|
|
"pycur" : "http://www.python.org/doc/current/",
|
|
|
|
"pydev" : "http://www.python.org/dev/doc/devel/",
|
|
|
|
"pyhelp" : "http://starship.python.net/crew/theller/pyhelp.cgi",
|
|
|
|
"pyvault" : "http://www.vex.net/parnassus/",
|
|
|
|
"e2" : "http://www.everything2.org/",
|
|
|
|
"sd" : "http://www.slashdot.org/"
|
|
|
|
}
|
|
|
|
|
2006-09-02 06:07:29 -04:00
|
|
|
cygwin = re.compile("cygwin\.com")
|
|
|
|
cygwin_sub1 = re.compile('<body bgcolor="#000000" color="#000000"')
|
2006-09-02 06:18:27 -04:00
|
|
|
cygwin_sub2 = '<body bgcolor="#ffffff" color="#000000"'
|
2006-09-02 06:26:55 -04:00
|
|
|
mbank = re.compile('^https://www\.mbank\.com\.pl/ib_navibar_3\.asp')
|
2006-09-02 06:07:29 -04:00
|
|
|
mbank_sub1 = re.compile('<td valign="top"><img')
|
2006-09-02 06:18:27 -04:00
|
|
|
mbank_sub2 = '<tr><td valign="top"><img'
|
2006-09-02 06:07:29 -04:00
|
|
|
google_redirect = re.compile('^http://www\.google\.com/url\?sa=D&q=(.*)')
|
|
|
|
|
2006-01-29 08:58:03 -05:00
|
|
|
def goto_url_hook(url, current_url):
|
|
|
|
global dumbprefixes
|
|
|
|
|
|
|
|
if dumbprefixes.has_key(url):
|
|
|
|
return dumbprefixes[url];
|
|
|
|
else:
|
|
|
|
return None
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
def follow_url_hook(url):
|
2006-09-02 06:07:29 -04:00
|
|
|
m = google_redirect.search(url)
|
|
|
|
if m:
|
|
|
|
return m.group(1)
|
2005-09-15 09:58:31 -04:00
|
|
|
return None
|
|
|
|
|
|
|
|
def pre_format_html_hook(url, html):
|
2006-09-02 06:07:29 -04:00
|
|
|
if cygwin.search(url):
|
2006-09-02 06:18:27 -04:00
|
|
|
html2 = cygwin_sub1.sub(cygwin_sub2, html)
|
2006-02-02 10:04:11 -05:00
|
|
|
return html2
|
2006-09-02 06:07:29 -04:00
|
|
|
if mbank.search(url):
|
2006-09-02 06:18:27 -04:00
|
|
|
html2 = mbank_sub1.sub(mbank_sub2, html)
|
2006-02-06 10:03:08 -05:00
|
|
|
return html2
|
2005-09-15 09:58:31 -04:00
|
|
|
return None
|
|
|
|
|
|
|
|
def proxy_for_hook(url):
|
|
|
|
return None
|
|
|
|
|
|
|
|
def quit_hook():
|
|
|
|
return None
|