I am trying to build a firefox extension which listens to events when a cookie is changed by any domain from any page and handle it accordingly. Is there an easy way to do this in javascript?
Usually yes, depends on the browser. Anyway you must always ask for permissions to the user in some ways that are specific for the browser. For example, as your tags, Chrome extension allows through chrome. cookies (Developer Chrome) the access to cookies of a given set of origins.
To use the Cookies API you need to request both the "cookies" permission and host permissions for the protocols, domains, or websites you want to access or use "<all_urls>" to access any protocol and domain.
The onload and onunload events can be used to deal with cookies.
You can listen to the cookie-changed topic with the observer service.
http://jsfiddle.net/ArondeParon/5RsTm/4/
try changing the cookie, it will pop up an alert.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With