?? hooks.pl
字號(hào):
# Example hooks.pl file, put in ~/.elinks/ as hooks.pl.# $Id: hooks.pl,v 1.2.2.4 2005/05/01 21:22:02 jonas Exp $## This file is (c) Russ Rowan and Petr Baudis and GPL'd.## To get the complete user documentation for this file in a user-friendly# manner, do either# pod2html hooks.pl > hooks.html && elinks hooks.html# or# perldoc hooks.pl=head1 NAMEhooks.pl -- Perl hooks for the ELinks text WWW browser=head1 DESCRIPTIONThis file contains the Perl hooks for the ELinks text WWW browser.These hooks can alter the browser's behaviour in various ways; probably themost popular is processing the user input in the Goto URL dialog and rewritingit in various ways (like the builtin URL prefix capability, but much morepowerful and flexible).Another popular capability of the hooks is to rewrite the HTML source of the pagebefore it is rendered, usually to get rid of ads and/or make the web pagemore ELinks-friendly. The hooks also allow you to fine-tune the proxying rules,can show a fortune when ELinks exits, and more!=cutuse strict;use warnings;use diagnostics;use Carp;=head1 CONFIGURATION FILEThe hooks file reads its configuration from I<~/.elinks/config.pl>.Note that the following is only an example,and does not contain the default values: bork: yep # BORKify Google? collapse: okay # Collapse all XBEL bookmark folders on exit? email: # Set to show one's own bugs with the "bug" prefix. fortune: elinks # *fortune*, *elinks* tip, or *none* on quit? googlebeta: hell no # I miss DejaNews... gotosearch: not yet # Don't use this yet. It's broken. ipv6: sure # IPV4 or 6 address blocks with "ip" prefix? language: english # "bf nl en" still works, but now "bf nl" does too news: msnbc # Agency to use for "news" and "n" prefixes search: elgoog # Engine for (search|find|www|web|s|f|go) prefixes usenet: google # *google* or *standard* view for news:// URLs weather: cnn # Server for "weather" and "w" prefixes # news: bbc, msnbc, cnn, fox, google, yahoo, reuters, eff, wired, # slashdot, newsforge, usnews, newsci, discover, sciam # search: elgoog, google, yahoo, ask jeeves, a9, altavista, msn, dmoz, # dogpile, mamma, webcrawler, netscape, lycos, hotbot, excite # weather: weather underground, google, yahoo, cnn, accuweather, # ask jeevesI<Developer's usage>: The function I<loadrc()> takes a preference name as itssingle argument and returns either an empty string if it is not specified,I<yes> for a true value (even if specified like I<sure> or I<why not>),I<no> for a false value (even if like I<nah>, I<off> or I<0>),or the lowercased preference value (like I<cnn> for C<weather: CNN>).=cutsub loadrc($){ my ($preference) = @_; my $configperl = $ENV{'HOME'} . '/.elinks/config.pl'; my $answer = ''; open RC, "<$configperl" or return $answer; while (<RC>) { s/\s*#.*$//; next unless (m/(.*):\s*(.*)/); my $setting = $1; my $switch = $2; next unless ($setting eq $preference); if ($switch =~ /^(yes|1|on|yea|yep|sure|ok|okay|yeah|why.*not)$/) { $answer = "yes"; } elsif ($switch =~ /^(no|0|off|nay|nope|nah|hell.*no)$/) { $answer = "no"; } else { $answer = lc($switch); } } close RC; return $answer;}#Don't call the prefixes "dumb", they hate that! Rather, "interactivity#challenged". (Such politically correct names always appeared to me to be#so much more insulting... --pasky ;-)=head1 GOTO URL REWRITESHere you can find summary of all the available rewrites of what you type intothe Goto URL box. They are similar in spirit to the builtin URI rewrites, butmore flexible and immensely more powerful.I<Developer's usage>: The function I<goto_url_hook> is called when the hookis triggered, taking the target URI and current URI as its two arguments. Itreturns the final target URI.These are the default rewrite rules:=head2 Miscellaneous shortcutsB<bugmenot>, B<bored>, B<random>, B<bofh>, B<xyzzy>, B<jack> or B<handey>=over 4=item Google GroupsB<deja>, B<gg>, B<groups>, B<gr>, B<nntp>, B<usenet>, B<nn>=item AltaVista BabelfishB<babelfish>, B<babel>, B<bf>, B<translate>, B<trans>, or B<b>=item MirrorDotB<md> or B<mirrordot>=item Coral cacheB<cc>, B<coral>, or B<nyud> (requires URL)=item W3C page validatorsB<vhtml> or B<vcss> (current url or specified)=item The DialectizerB<dia> <dialect> (current url or specified)Dialects can be:I<redneck>, I<jive>, I<cockney>, I<fudd>, I<bork>, I<moron>, I<piglatin>, or I<hacker>=back=head2 Web search=cut#######################################################################my %search_prefixes;=over 4=item Default engineB<search>, B<find>, B<www>, B<web>, B<s>, B<f>, B<go>,and anything in quotes with no prefix.=item GoogleB<g> or B<google>=cut$search_prefixes{'^(g|google)(| .*)$'} = 'google';=item YahooB<y> or B<yahoo>=cut$search_prefixes{'^(y|yahoo)(| .*)$'} = 'yahoo';=item Ask JeevesB<ask> or B<jeeves>=cut$search_prefixes{'^(ask|jeeves)(| .*)$'} = 'ask jeeves';=item Amazon/A9B<a9>=cut$search_prefixes{'^a9(| .*)$'} = 'a9';=item AltavistaB<av> or B<altavista>=cut$search_prefixes{'^(av|altavista)(| .*)$'} = 'altavista';=item MicrosoftB<msn> or B<microsoft>=cut$search_prefixes{'^(msn|microsoft)(| .*)$'} = 'msn';=item dmozB<dmoz>, B<odp>, B<mozilla>=cut$search_prefixes{'^(dmoz|odp|mozilla)(| .*)$'} = 'dmoz';=item DogpileB<dp> or B<dogpile>=cut$search_prefixes{'^(dp|dogpile)(| .*)$'} = 'dogpile';=item MammaB<ma> or B<mamma>=cut$search_prefixes{'^(ma|mamma)(| .*)$'} = 'mamma';=item WebcrawlerB<wc> or B<webcrawler>=cut$search_prefixes{'^(wc|webcrawler)(| .*)$'} = 'webcrawler';=item NetscapeB<ns> or B<netscape>=cut$search_prefixes{'^(ns|netscape)(| .*)$'} = 'netscape';=item LycosB<ly> or B<lycos>=cut$search_prefixes{'^(ly|lycos)(| .*)$'} = 'lycos';=item HotbotB<hb> or B<hotbot>=cut$search_prefixes{'^(hb|hotbot)(| .*)$'} = 'hotbot';=item ExciteB<ex> or B<excite>=cut$search_prefixes{'^(ex|excite)(| .*)$'} = 'excite';=item ElgoogB<eg>, B<elgoog>, B<hcraes>, B<dnif>, B<bew>, B<og>=cut$search_prefixes{'^(eg|elgoog|hcraes|dnif|bew|og)(| .*)$'} = 'elgoog';#######################################################################=back=head2 News agencies=cutmy %news_prefixes;=over 4=item Default agencyB<n>, B<news>=item British Broadcasting CorporationB<bbc>=cut$news_prefixes{'^bbc(| .*)$'} = 'bbc';=item MSNBCB<msnbc>=cut$news_prefixes{'^msnbc(| .*)$'} = 'msnbc';=item Cable News NetworkB<cnn>=cut$news_prefixes{'^cnn(| .*)$'} = 'cnn';=item FOXNewsB<fox>=cut$news_prefixes{'^fox(| .*)$'} = 'fox';=item Google NewsB<gn>=cut$news_prefixes{'^gn(| .*)$'} = 'google';=item Yahoo NewsB<yn>=cut$news_prefixes{'^yn(| .*)$'} = 'yahoo';=item ReutersB<rs> or B<reuters>=cut$news_prefixes{'^(reuters|rs)(| .*)$'} = 'reuters';=item Electronic Frontier FoundationB<eff>=cut$news_prefixes{'^eff(| .*)$'} = 'eff';=item WiredB<wd> or B<wired>=cut$news_prefixes{'^(wired|wd)(| .*)$'} = 'wired';=item SlashdotB</.> or B<sd> or B<slashdot>=cut$news_prefixes{'^(\/\.|slashdot|sd)(| .*)$'} = 'slashdot';=item NewsForgeB<nf> or B<newsforge>=cut$news_prefixes{'^(newsforge|nf)(| .*)$'} = 'newsforge';=item U.S.News & World ReportB<us> or B<usnews>=cut$news_prefixes{'^(us|usnews)(| .*)$'} = 'usnews';=item New ScientistB<newsci> or B<nsci>=cut$news_prefixes{'^(nsci|newsci)(| .*)$'} = 'newsci';=item Discover MagazineB<dm>=cut$news_prefixes{'^dm(| .*)$'} = 'discover';=item Scientific AmericanB<sa> or B<sciam>=cut$news_prefixes{'^(sa|sciam)(| .*)$'} = 'sciam';#######################################################################=back=head2 Locators=cut# Some of those are handled specially and not in this hash.my %locator_prefixes;=over 4=item Internet Movie DatabaseB<imdb>, B<movie>, or B<flick>=cut$locator_prefixes{'^(imdb|movie|flick)(| .*)$'} = 'imdb';=item US zip code searchB<zip> or B<usps> (# or address)=cut=item IP address locator / address spaceB<ip>=cut=item WHOIS / TLD listB<whois> (current url or specified)=cut=item Request for CommentsB<rfc> (# or search)=cut=item WeatherB<w> or B<weather>=cut=item Yahoo! Finance / NASD RegulationB<stock>, B<ticker>, or B<quote>=cut$locator_prefixes{'^(stock|ticker|quote)(| .*)$'} = 'stock';=item SnopesB<ul>, B<urban>, or B<legend>=cut$locator_prefixes{'^(urban|legend|ul)(| .*)$'} = 'bs';=item Torrent search / ISOHuntB<bt>, B<torrent>, or B<bittorrent>=cut$locator_prefixes{'^(bittorrent|torrent|bt)(| .*)$'} = 'torrent';=item Wayback MachineB<ia>, B<ar>, B<arc>, or B<archive> (current url or specified)=cut$locator_prefixes{'^(archive|arc|ar|ia)(| .*)$'} = 'archive';=item FreshmeatB<fm> or B<freshmeat>=cut$locator_prefixes{'^(freshmeat|fm)(| .*)$'} = 'freshmeat';=item SourceForge
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -