Tải bản đầy đủ - 0 (trang)
Hack 36. Add a Feed to My Yahoo! with a Right-Click

Hack 36. Add a Feed to My Yahoo! with a Right-Click

Tải bản đầy đủ - 0trang

2.15.1.TheCode

Muchlikeabookmarklet[Hack#28],anyJavaScriptthatruns

viaacontextmenuentryhasaccesstothepagecurrently

loadedinthebrowser.Thatmeansthatwhenyouclickthe

contextmenuentryyou'veadded,thebrowserexecutesascript

thattakessomeactionusinginformationfromthecurrentpage.

Inthiscase,theactionisgrabbingtheURLlinkedfromthe

currentlyclickedimage,constructingaspecialMyYahoo!URL

thatincludesthefeedURL,andopeningthenewURLinanew

browserwindow.

SavethefollowingcodetoafilecalledAddToMyYahoo.html:









varaddURL=newString("http://add.my.yahoo.com/rss?ur









varw=window.external.menuArguments

varurl=w.event.srcElement.parentElement.href;











window.open(addURL+url,null,



"height=455,width=788,status=yes,scrollbars=





Theexternal.menuArgumentsobjectholdsinformationaboutthe

currentdocument,andtheevent.srcElementisthedocumentitem

theuserclicked.GrabbingtheHRefattributeoftheelement's

parentwillgiveyouthelinkURLthatisaroundtheimagetag.

Savethefileinaspotyou'llremember.Forsimplicityinthis

hack,saveittoadirectorycalledc:\scripts\.

Nowthatthescriptisreadytogo,youjustneedtoaddthe

contextmenuentrytoInternetExplorerandtellittorunthis

particularscriptwhenyouclicktheentry.You'llaccomplishthis



throughtheWindowsRegistry.TheRegistryisasystem

databasethatholdsinformationaboutapplications,including

InternetExplorer.YoucansafelymakeadditionstotheRegistry

via.regfiles.CreateanewtextfilecalledAddYahooContext.reg

andaddthefollowingcode:







WindowsRegistryEditorVersion5.00

[HKEY_CURRENT_USER\Software\Microsoft\InternetExplorer











Yahoo!]

@="c:\\scripts\\AddToMyYahoo.html"

"contexts"=dword:00000002



Backslashes,suchasthoseinfilesystempaths,mustbeescapedas

doubleslashes(\\)inRegistryentryfiles.



Notethatthecontextsentryhereendswith2,whichmeansthe

entrywillappearonlywhentheuserhasclickedanimage.

Othervaluesyoucouldusehereinclude1(foranywhere),20

(fortextlinks),or10(fortextselections).

Savethefile,double-clickit,andconfirmthatyouwanttoadd

thenewRegistryinformation.You'llnowhavearight-click

menuentrycalled"AddtoMyYahoo!"wheneveryouright-click

animage.



2.15.2.RunningtheHack

OncethecodeandRegistrysettingsareinplace,restart



InternetExplorer.BrowsetoasitewithafeedURLlinkandtake

thenewcontextmenuentryforaspin.Whenyouright-clickan

image,youshouldsee"AddtoMyYahoo!,"asshowninFigure

2-41.

Whenyouclickthe"AddtoMyYahoo!"menuentry,awindow

liketheoneshowninFigure2-42shouldappearwiththeMy

Yahoo!feedpreviewpage.

Keepinmindthatthe"AddtoMyYahoo!"contextmenuentry

willbeavailableforeveryimageonawebpage,regardlessof

whetherornotitlinkstoanRSSfeed.Soyou'llhavetouse

yourbestjudgmentaboutwhentousethefeature.Iftheimage

turnsoutnottobelinkedtoanRSSfeed,theYahoo!feed

previewpagewillletyouknowquickly.Ifyoudon'tseepostsin

thepreviewboxontherightsideofthepage,you'llknowthata

feedwon'tbeaddedtoMyYahoo!ifyouclicktheAddbutton.



Figure2-41."AddtoMyYahoo!"contextmenu

entry



Onceyou'refinishedaddingthefeed,youcansimplyclosethe

pop-upwindowandgobacktoreadingthesite.



Hack37.BuildYourOwnNewsCrawler



TheMyYahoo!Tickercanprovideanonstopstreamof

news,weather,andstockquotesinyourWindows

toolbar.

Whenyouwatchanyofthe24-hournewschannelssuchas

CNNorMSNBC,youseetheever-presentcrawlingnewsticker

runningalongthebottomofthescreen.Whilethenewsanchor

readsastoryaboutthelatestcelebritycourtcaseornatural

disaster,youcanreadcompletelyunrelatedinformationinthe

newscrawleraboutotherstoriesthatarebreaking.Onthe

financialnewschannels,thenewscrawleracrossthebottom

givesstockquoteinformationthatletsyoukeepupwithhow

themarketisfaring.



Figure2-42."AddtoMyYahoo!"previewpagein

newwindow



ThankstotheMyYahoo!Ticker(inbetatestingatthetimeof

thiswriting),youcancreateyourownendlesslycrawlingnews

tickerinyourWindowstaskbarthatwillkeepyouuptodate

withheadlines,stockquotes,andweatherwhileyou'reworking.



2.16.1.InstallingtheTicker

Tousetheticker,you'llneedWindows98orhigherandarecent

versionofInternetExplorer.Ifyoumeettheserequirements,

browsetohttp://ticker.yahoo.comandclicktheDownload

button.Followtheinstallationinstructionsandenablethe

toolbarbyclickinganemptyareainyourWindowstaskbarand

choosingToolbars MyYahoo!TickerBeta,asshowninFigure

2-43.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 36. Add a Feed to My Yahoo! with a Right-Click

Tải bản đầy đủ ngay(0 tr)

×