开发者

firefox addon checking sqlite database on event

开发者 https://www.devze.com 2023-02-15 20:23 出处:网络
I\'m doing firefox addon that has it\'s sqlite database mydb.sqlite. It\'s a database of my selected links and I hav开发者_如何学Ce a load event for gBrowser.

I'm doing firefox addon that has it's sqlite database mydb.sqlite. It's a database of my selected links and I hav开发者_如何学Ce a load event for gBrowser. Now I would like to write a code that will check the content.document.location on each load event and will notify me if the currently open link is in the database or if it is not in the database (e.g. with some icon on the status bar).

Do you know how to do it efficiently? So it won't slow down firefox much?

thank you


  1. Be sure you're listening for the DOMContentLoaded event, which fires on every page load

  2. You can get the loaded page's URL from within your DOMContentLoaded handler using e.target.defaultView.location.href (where e should be whatever you've named the first parameter in your callback).

  3. Now compare this URL to what's in the DB. Consider using asynchronous statement execution (Firefox 3.5 and newer only), so that you don't block the main thread unnecessarily.

  4. This excellent tutorial will show you how to update the status bar.

0

精彩评论

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