mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-09-30 09:06:56 +13:00
this fixes #489
This commit is contained in:
parent
0031a47721
commit
65924d1be8
3 changed files with 52 additions and 5 deletions
|
@ -840,13 +840,24 @@ vAPI.cookies = {};
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.cookies.start = function() {
|
vAPI.cookies.start = function() {
|
||||||
|
var reallyRemoved = {
|
||||||
|
'evicted': true,
|
||||||
|
'expired': true,
|
||||||
|
'explicit': true
|
||||||
|
};
|
||||||
|
|
||||||
var onChanged = function(changeInfo) {
|
var onChanged = function(changeInfo) {
|
||||||
var handler = changeInfo.removed ? this.onRemoved : this.onChanged;
|
if ( changeInfo.removed ) {
|
||||||
if ( typeof handler !== 'function' ) {
|
if ( reallyRemoved[changeInfo.cause] && typeof this.onRemoved === 'function' ) {
|
||||||
|
this.onRemoved(changeInfo.cookie);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handler(changeInfo.cookie);
|
if ( typeof this.onChanged === 'function' ) {
|
||||||
|
this.onChanged(changeInfo.cookie);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.cookies.onChanged.addListener(onChanged.bind(this));
|
chrome.cookies.onChanged.addListener(onChanged.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3294,7 +3294,21 @@ vAPI.cookies.observe = function(subject, topic, reason) {
|
||||||
//if ( topic !== 'cookie-changed' && topic !== 'private-cookie-changed' ) {
|
//if ( topic !== 'cookie-changed' && topic !== 'private-cookie-changed' ) {
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
if ( reason === 'deleted' || subject instanceof Ci.nsICookie2 === false ) {
|
//
|
||||||
|
if ( reason === 'cleared' && typeof this.onAllRemoved === 'function' ) {
|
||||||
|
this.onAllRemoved();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( subject === null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( subject instanceof Ci.nsICookie2 === false ) {
|
||||||
|
subject = subject.QueryInterface(Ci.nsICookie2);
|
||||||
|
}
|
||||||
|
if ( reason === 'deleted' ) {
|
||||||
|
if ( typeof this.onRemoved === 'function' ) {
|
||||||
|
this.onRemoved(new this.CookieEntry(subject));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( typeof this.onChanged === 'function' ) {
|
if ( typeof this.onChanged === 'function' ) {
|
||||||
|
|
|
@ -119,7 +119,6 @@ var removeCookieFromDict = function(cookieKey) {
|
||||||
if ( cookieEntryJunkyard.length < 25 ) {
|
if ( cookieEntryJunkyard.length < 25 ) {
|
||||||
cookieEntryJunkyard.push(cookieEntry.unset());
|
cookieEntryJunkyard.push(cookieEntry.unset());
|
||||||
}
|
}
|
||||||
// console.log('cookies.js/removeCookieFromDict()> removed cookie key "%s"', cookieKey);
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -530,6 +529,29 @@ vAPI.cookies.onChanged = function(cookie) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// Listen to any change in cookieland, we will update page stats accordingly.
|
||||||
|
|
||||||
|
vAPI.cookies.onRemoved = function(cookie) {
|
||||||
|
var cookieKey = cookieKeyFromCookie(cookie);
|
||||||
|
if ( removeCookieFromDict(cookieKey) ) {
|
||||||
|
µm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// Listen to any change in cookieland, we will update page stats accordingly.
|
||||||
|
|
||||||
|
vAPI.cookies.onAllRemoved = function() {
|
||||||
|
for ( var cookieKey in cookieDict ) {
|
||||||
|
if ( cookieDict.hasOwnProperty(cookieKey) && removeCookieFromDict(cookieKey) ) {
|
||||||
|
µm.logger.writeOne('', 'info', 'cookie', i18nCookieDeleteSuccess.replace('{{value}}', cookieKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.cookies.getAll(addCookiesToDict);
|
vAPI.cookies.getAll(addCookiesToDict);
|
||||||
vAPI.cookies.start();
|
vAPI.cookies.start();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue