diff --git a/cookies.css b/cookies.css index e7dc9e0..f4e4f89 100755 --- a/cookies.css +++ b/cookies.css @@ -192,6 +192,10 @@ li:hover .secure-cookie { color: #ff7000; } +li.unremoved-secure-cookie { + border: 1px solid #e00; +} + .cookieKey, .cookieValue, .secure-cookie { transition-property: color; transition-duration: 150ms; diff --git a/cookies.js b/cookies.js index 5f1147b..f462556 100755 --- a/cookies.js +++ b/cookies.js @@ -255,6 +255,7 @@ function handleMessage (request, sender, sendResponse) { if (domainData[key]['isRoot'] !== undefined) { rootDomain = domainData[key].u cookieDataDomain[rootDomain] = [] + if (cookieData[rootDomain][request.storeId] === undefined) continue for (let cookieInfo of cookieData[rootDomain][request.storeId]) { cookieDataDomain[rootDomain].push(cookieInfo) } @@ -271,7 +272,9 @@ function handleMessage (request, sender, sendResponse) { if (domainData[key]['isRoot'] !== undefined) continue let domainName = domainData[key].u if (cookieDataDomain[domainName] === undefined) cookieDataDomain[domainName] = [] + if (cookieData[domainName][request.storeId] === undefined) continue for (let cookieInfo of cookieData[domainName][request.storeId]) { + if (cookieData[domainName][request.storeId] === undefined) continue let isFound = false for (let cookieExistingInfo of cookieDataDomain[domainName]) { @@ -325,6 +328,7 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, let index = 0 for (let cookieEntry of cookieData[domainURL][activeCookieStore]) { + if (cookieEntry === undefined) continue if (cookieEntry.name === cookie.name) { cookie['fgRemoved'] = false cookie['fgAllowed'] = true @@ -359,6 +363,8 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, if (data['flagCookies_logged'] === undefined || data['flagCookies_logged'][contextName] === undefined || data['flagCookies_logged'][contextName][domainURL] === undefined || Object.keys(data['flagCookies_logged'][contextName][domainURL]).length === 0) protectDomainCookies = true } + let cookieIndex = 0 + if (data['flagCookies_autoFlag'] && data['flagCookies_autoFlag'][contextName] && data['flagCookies_autoFlag'][contextName][domainURL]) { for (let cookie of cookieData[domainURL][activeCookieStore]) { let cookieDomain = cookie.domain.charAt(0) === '.' ? cookie.domain.substr(1, cookie.domain.length - 1) : cookie.domain @@ -403,11 +409,15 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, } cookie['fgRemoved'] = true - } else { - let msg = "Cookie not present '" + action + "', cookie: '" + cookie.name + "' for '" + domainURL + "'" - addToLogData(currentTab, msg) } + if (!cookie['fgRemoved'] && !cookie.secure) { + delete cookieData[domainURL][activeCookieStore][cookieIndex] + continue + } + + ++cookieIndex + continue } @@ -434,6 +444,13 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, cookie['fgRemoved'] = true } + + if (!cookie['fgRemoved'] && !cookie.secure) { + delete cookieData[domainURL][activeCookieStore][cookieIndex] + continue + } + + ++cookieIndex } } else if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'][contextName] !== undefined && data['flagCookies_flagGlobal'][contextName] === true) { for (let cookie of cookieData[domainURL][activeCookieStore]) { @@ -479,11 +496,15 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, } cookie['fgRemoved'] = true - } else { - let msg = "Cookie not present '" + action + "', cookie: '" + cookie.name + "' for '" + domainURL + "'" - addToLogData(currentTab, msg) } + if (!cookie['fgRemoved'] && !cookie.secure) { + delete cookieData[domainURL][activeCookieStore][cookieIndex] + continue + } + + ++cookieIndex + continue } @@ -510,6 +531,13 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, cookie['fgRemoved'] = true } + + if (!cookie['fgRemoved'] && !cookie.secure) { + delete cookieData[domainURL][activeCookieStore][cookieIndex] + continue + } + + ++cookieIndex } } else { if (data[contextName] === undefined || data[contextName][domainURL] === undefined || Object.keys(data[contextName][domainURL]) === 0) { @@ -555,6 +583,13 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, cookie['fgRemoved'] = true } + if (!cookie['fgRemoved'] && !cookie.secure) { + delete cookieData[domainURL][activeCookieStore][cookieIndex] + continue + } + + ++cookieIndex + continue } @@ -569,6 +604,13 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab, addToLogData(currentTab, msg) cookie['fgRemoved'] = true } + + if (!cookie['fgRemoved'] && !cookie.secure) { + delete cookieData[domainURL][activeCookieStore][cookieIndex] + continue + } + + ++cookieIndex } } diff --git a/flagCookies.js b/flagCookies.js index 5703964..245724f 100644 --- a/flagCookies.js +++ b/flagCookies.js @@ -182,36 +182,9 @@ function updateUIData (data, cookies, activeCookieStoreName, tab) { } for (let cookie of cookies.cookies[cookieKey]) { + if (cookie === undefined) continue let li = document.createElement('li') - if (cookie['fgHandled'] && !cookie['fgAllowed'] && !cookie['fgRemoved']) { - let p = document.createElement('p') - - let pCookieKeyElm = document.createElement('span') - let pCookieKey = document.createTextNode(cookie.name) - pCookieKeyElm.className = 'cookieKey' - pCookieKeyElm.appendChild(pCookieKey) - - let pCookieKeySecMessageElm = document.createElement('span') - let pCookieKeySecMessage = document.createTextNode('(secure cookie)') - pCookieKeySecMessageElm.className = 'secure-cookie' - pCookieKeySecMessageElm.appendChild(pCookieKeySecMessage) - - let pCookieValueElm = document.createElement('span') - let pCookieValue = document.createTextNode(cookie.value) - pCookieValueElm.className = 'cookieValue' - pCookieValueElm.appendChild(pCookieValue) - - p.appendChild(pCookieKeyElm) - p.appendChild(pCookieKeySecMessageElm) - p.appendChild(pCookieValueElm) - li.title = 'This cookie is secure for the domain and cannot be handled due to host permission restrictions.' - li.appendChild(p) - - cookieList.appendChild(li) - continue - } - let checkMark = document.createElement('button') checkMark.className = 'checkmark' checkMark.title = 'This cookie is allowed and unhandled' @@ -265,19 +238,21 @@ function updateUIData (data, cookies, activeCookieStoreName, tab) { let pCookieKeySecMessage = document.createTextNode('(secure cookie)') pCookieKeySecMessageElm.className = 'secure-cookie' pCookieKeySecMessageElm.appendChild(pCookieKeySecMessage) + p.appendChild(pCookieKeySecMessageElm) - p.title = 'This cookie is secure for the domain and might not be handled due to host permission restrictions.' + p.appendChild(pCookieValueElm) + if (cookie['fgHandled'] && !cookie['fgAllowed'] && !cookie['fgRemoved']) { + li.title = 'This cookie is secure for the domain and cannot be handled due to host permission restrictions.' + li.className = 'unremoved-secure-cookie' + } + } else { + p.appendChild(pCookieValueElm) } - p.appendChild(pCookieValueElm) li.appendChild(checkMark) li.appendChild(p) li.appendChild(lockSwitch) - if (cookie.secure) { - - } - cookieList.appendChild(li) } } diff --git a/manifest.json b/manifest.json index 55f40a9..c2c6f10 100644 --- a/manifest.json +++ b/manifest.json @@ -41,7 +41,7 @@ "homepage_url": "https://github.com/jrie/flagCookies", "manifest_version": 2, "name": "Flag Cookies", - "version": "2.2.5", + "version": "2.2.6", "permissions": ["cookies", "tabs", "webRequest", "", "webRequestBlocking", "storage", "unlimitedStorage", "notifications", "contextualIdentities"], "background": { "scripts": [