开发者

Chrome Extension Development - need help getting started

I'd like to try my hand at some Chrome Extension Development. The most I have done with extensions is writing some small Greasemonkey开发者_JS百科 scripts in the past.

I would like to use localStorage to store some data and then reveal the data on a extension button click later on. (Its seems like this would be done with a popup page)

How do I run a script everytime a page from lets say http://www.facebook.com/* is loaded? How do I get access to the page? I think based off my localStorage requirement I would have to go down the background_page route (correct?) Can the background page and popup page communicate across the localStorage?

UPDATE:

I'm actually looking to learn the "Chrome way". I'm not really looking to run an existing Greasemonkey script


Google actually has some pretty good documentation on creating extensions. I recommend thoroughly reading the following two articles if you haven't already done so:

  • http://code.google.com/chrome/extensions/getstarted.html
  • http://code.google.com/chrome/extensions/overview.html

If you want to give your extension access when the user browses to Facebook, you'll need to declare that in the extension's manifest.

Unless you're wanting to save data beyond the life of the browser process, you probably don't need to use local storage. In-memory data can just be stored as part of the background page.

Content scripts (which run when you load a page) and background pages (which exist for the duration of the browser process) can communicate via message passing, which is described here:

  • http://code.google.com/chrome/extensions/messaging.html

Overall, I'd suggest spending some time browsing the Developer's Guide and becoming familiar with the concepts and examples.


Chrome has a feature to automatically convert greasemonkey scripts to extensions!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜