Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to listen to event when a cookie is changed in a Firefox Extension

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?

like image 924
ivanceras Avatar asked Nov 09 '10 10:11

ivanceras


People also ask

Can browser extensions read cookies?

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.

Can I use cookies API?

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.

Which of the following events can be used to deal with cookies?

The onload and onunload events can be used to deal with cookies.


2 Answers

You can listen to the cookie-changed topic with the observer service.

like image 198
sdwilsh Avatar answered Oct 08 '22 03:10

sdwilsh


http://jsfiddle.net/ArondeParon/5RsTm/4/

try changing the cookie, it will pop up an alert.

like image 30
Hitesh Joshi Avatar answered Oct 08 '22 03:10

Hitesh Joshi