Skip to content

Commit

Permalink
Bugfixing profile mode protected cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
jrie committed Jan 28, 2019
1 parent a241508 commit 9f2bf21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
35 changes: 16 additions & 19 deletions cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,12 @@ async function clearCookiesAction (action, data, cookies, domainURL, currentTab,
if (hasGlobalProfile) {
if (data['flagCookies_accountMode'][contextName]['https://' + domain] !== undefined) accountDomain = 'https://' + domain
else accountDomain = 'http://' + domain

hasLogged = data['flagCookies_logged'] !== undefined && data['flagCookies_logged'][contextName] !== undefined && data['flagCookies_logged'][contextName][accountDomain] !== undefined
if (hasLogged && Object.keys(data['flagCookies_logged'][contextName][accountDomain]).length === 0) protectDomainCookies = true
} else if (hasLocalProfile) {
hasLogged = data['flagCookies_logged'] !== undefined && data['flagCookies_logged'][contextName] !== undefined && data['flagCookies_logged'][contextName][domainURL] !== undefined
accountDomain = domainURL
if (hasLogged) {
if (Object.keys(data['flagCookies_logged'][contextName][domainURL]).length === 0) protectDomainCookies = true
}
if (hasLogged && Object.keys(data['flagCookies_logged'][contextName][domainURL]).length === 0) protectDomainCookies = true
}
}

Expand Down Expand Up @@ -1067,11 +1064,8 @@ async function clearCookiesOnUpdate (tabId, changeInfo, currentTab) {
let domain = domainSplit.splice(domainSplit.length - 2, 2).join('.')
addTabURLtoDataList(currentTab, { 'url': tabDomain, 'frameId': 0, 'parentFrameId': -1, 'type': 'main_frame' }, domain, true)

if (useChrome) {
chrome.browserAction.enable(currentTab.id)
} else {
browser.browserAction.enable(currentTab.id)
}
if (useChrome) chrome.browserAction.enable(currentTab.id)
else browser.browserAction.enable(currentTab.id)

if (!useChrome) browser.contextualIdentities.get(currentTab.cookieStoreId).then(firefoxOnGetContextSuccess, firefoxOnGetContextError)
else contextName = 'default'
Expand Down Expand Up @@ -1130,17 +1124,20 @@ async function clearCookiesOnUpdate (tabId, changeInfo, currentTab) {
if (count !== 0) browser.browserAction.setBadgeText({ text: count.toString(), tabId: currentTab.id })
else browser.browserAction.setBadgeText({ text: '', tabId: currentTab.id })
}
}

if (useChrome) {
getChromeStorageForFunc3(displayCookieDeleteChrome, count, tabDomain, contextName)
return
}

let data = await browser.storage.local.get()
if (useChrome) {
chrome.browserAction.setTitle({ 'title': titleString, 'tabId': currentTab.id })
getChromeStorageForFunc3(setBrowserActionIconChrome, contextName, tabDomain, currentTab.id)
getChromeStorageForFunc3(displayCookieDeleteChrome, count, tabDomain, contextName)
return
}
browser.browserAction.setTitle({ 'title': titleString, 'tabId': currentTab.id })
setBrowserActionIconFirefox(contextName, tabDomain, currentTab.id)
let data = await browser.storage.local.get()

if (count !== 0 && data['flagCookies_notifications'] !== undefined && data['flagCookies_notifications'] === true) {
browser.notifications.create('cookie_cleared', { type: 'basic', message: getMsg('NotificationCookiesRemoved', [count, tabDomain, contextName]), title: getMsg('NotificationCookiesRemovedTitle'), iconUrl: 'icons/cookie_128.png' })
}
if (count !== 0 && data['flagCookies_notifications'] !== undefined && data['flagCookies_notifications'] === true) {
browser.notifications.create('cookie_cleared', { type: 'basic', message: getMsg('NotificationCookiesRemoved', [count, tabDomain, contextName]), title: getMsg('NotificationCookiesRemovedTitle'), iconUrl: 'icons/cookie_128.png' })
}
}
}
Expand Down Expand Up @@ -1245,7 +1242,7 @@ function addToLogData (currentTab, msg, timeString, timestamp, domain) {
}

// Account mode switch key command
async function toggleAccountMode (data, contextName, url, tabid, useNotifcations) {
async function toggleAccountMode (data, contextName, url, tabid) {
if (data['flagCookies_accountMode'] === undefined) data['flagCookies_accountMode'] = {}
if (data['flagCookies_accountMode'][contextName] === undefined) data['flagCookies_accountMode'][contextName] = {}

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"homepage_url": "https://github.com/jrie/flagCookies",
"manifest_version": 2,
"name": "Flag Cookies",
"version": "3.0.47",
"version": "3.0.48",
"permissions": ["cookies", "tabs", "webRequest", "<all_urls>", "storage", "unlimitedStorage", "notifications", "contextualIdentities"],
"background": {
"scripts": [
Expand Down

0 comments on commit 9f2bf21

Please sign in to comment.