Skip to content

Commit

Permalink
Updating to v2.2.6 ...
Browse files Browse the repository at this point in the history
- Removal of non-present cookies from UI
- Removing cookie not present log messages in Opera/Chrome browsers
  • Loading branch information
jrie committed Jun 30, 2018
1 parent b282173 commit 1cb5f39
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 41 deletions.
4 changes: 4 additions & 0 deletions cookies.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
54 changes: 48 additions & 6 deletions cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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]) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand All @@ -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]) {
Expand Down Expand Up @@ -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
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
}

Expand Down
43 changes: 9 additions & 34 deletions flagCookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<all_urls>", "webRequestBlocking", "storage", "unlimitedStorage", "notifications", "contextualIdentities"],
"background": {
"scripts": [
Expand Down

0 comments on commit 1cb5f39

Please sign in to comment.