firefox addon checking sqlite database on event
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
Be sure you're listening for the
DOMContentLoaded
event, which fires on every page loadYou can get the loaded page's URL from within your
DOMContentLoaded
handler usinge.target.defaultView.location.href
(wheree
should be whatever you've named the first parameter in your callback).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.
This excellent tutorial will show you how to update the status bar.
精彩评论