diff --git a/cookies.js b/cookies.js index 4fc3130..5b9d473 100755 --- a/cookies.js +++ b/cookies.js @@ -115,10 +115,9 @@ async function clearCookiesAction (action, data, cookies) { } } } - } else if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal']['use'] === true) { + } else if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'] === true) { if (data[domainURL] === undefined) { for (let cookie of cookies) { - if (hasProfile && hasLogged && data['flagCookies_logged'][domainURL][cookie.name] !== undefined) { let msg = "Allowed profile cookie on '" + action + "', cookie: '" + cookie.name + "' for '" + domainURL + "'" addToLogData(msg) @@ -292,12 +291,17 @@ function chromeUpdateLogData (data, writeData) { } } +function clearCookiesOnNavigate (tabId, changeInfo, tab) { + if (changeInfo.status && changeInfo.status === 'loading') { + clearCookiesWrapper('tab reload/load', useChrome) + } +} + async function clearCookiesOnUpdate (tabId, changeInfo, tab) { + if (changeInfo.status && changeInfo.status === 'loading') { + clearDomainLog() clearCookiesWrapper('tab reload/load', useChrome) - if (changeInfo['url'] === undefined) { - clearDomainLog(); - } } else if (changeInfo.status && changeInfo.status === 'complete') { if (logData !== '') { let urlMatch = tab.url.replace(/\/www\./, '/').match(/(http|https):\/\/[a-zA-Z0-9öäüÖÄÜ.-]*\//) @@ -354,7 +358,7 @@ function clearDomainLog () { } } -function addToLogData (msg) { +async function addToLogData (msg) { if (logData.indexOf(msg) === -1) logData.push(msg) } @@ -363,8 +367,10 @@ if (useChrome) { chrome.tabs.onRemoved.addListener(clearCookiesOnLeave) chrome.tabs.onUpdated.addListener(clearCookiesOnUpdate) chrome.tabs.onActivated.addListener(setDomainURLOnActivation) + chrome.webNavigation.onBeforeNavigate.addListener(clearCookiesOnNavigate) } else { browser.tabs.onRemoved.addListener(clearCookiesOnLeave) browser.tabs.onUpdated.addListener(clearCookiesOnUpdate) browser.tabs.onActivated.addListener(setDomainURLOnActivation) + browser.webNavigation.onBeforeNavigate.addListener(clearCookiesOnNavigate) } diff --git a/flagCookies.js b/flagCookies.js index 6fa9b24..d84df99 100644 --- a/flagCookies.js +++ b/flagCookies.js @@ -238,7 +238,7 @@ function updateUIData (data, cookies) { document.getElementById('profileNoData').removeAttribute('class') } - if (data['flagCookies_flagGlobal'] && data['flagCookies_flagGlobal']['use'] === true) { + if (data['flagCookies_flagGlobal'] && data['flagCookies_flagGlobal'] === true) { flagGlobalAutoNonEvent() } @@ -359,7 +359,7 @@ async function flaggedCookieSwitchNeutral (data, event) { // Uncheck from flagged in active cookies, if present let domainCookieList = document.getElementById('cookie-list') let hasAutoFlag = data['flagCookies_autoFlag'] !== undefined && data['flagCookies_autoFlag'][domainURL] !== undefined - let hasGlobal = data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal']['use'] === true + let hasGlobal = data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'] === true for (let child of domainCookieList.children) { if (child.children[0].dataset['name'] === cookieName) { @@ -417,7 +417,7 @@ async function permittedCookieSwitchNeutral (data, event) { // Uncheck from permitted in active cookies, if present let domainCookieList = document.getElementById('cookie-list') let hasAutoFlag = data['flagCookies_autoFlag'] !== undefined && data['flagCookies_autoFlag'][domainURL] !== undefined - let hasGlobal = data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal']['use'] === true + let hasGlobal = data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'] === true for (let child of domainCookieList.children) { if (child.children[0].dataset['name'] === cookieName) { if (hasAutoFlag) { @@ -498,7 +498,7 @@ async function cookieFlagSwitchNeutral (data, event) { } else if (hasAutoFlag && data[domainURL][cookieName] !== 'af') { data[domainURL][cookieName] = 'af' event.target.className = 'checkmark auto-flagged' - } else if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal']['use'] !== undefined && data['flagCookies_flagGlobal']['use'] === true) { + } else if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'] === true) { delete data[domainURL][cookieName] event.target.className = 'checkmark auto-flagged' } else { @@ -679,12 +679,12 @@ function flagGlobalAutoNonEventWrapper(data) { if (globalFlagButton.className !== 'active') { globalFlagButton.className = 'active' - data['flagCookies_flagGlobal']['use'] = true + data['flagCookies_flagGlobal'] = true setChromeStorage(data) switchAutoFlagGlobal(true, 'cookie-list') } else { globalFlagButton.removeAttribute('class') - data['flagCookies_flagGlobal']['use'] = false + data['flagCookies_flagGlobal'] = false setChromeStorage(data) let hasAutoFlag = data['flagCookies_autoFlag'] !== undefined && data['flagCookies_autoFlag'][domainURL] !== undefined @@ -715,12 +715,12 @@ async function flagGlobalAutoNonEvent () { if (globalFlagButton.className !== 'active') { globalFlagButton.className = 'active' - data['flagCookies_flagGlobal']['use'] = true + data['flagCookies_flagGlobal'] = true await browser.storage.local.set(data) switchAutoFlagGlobal(true, 'cookie-list') } else { globalFlagButton.removeAttribute('class') - data['flagCookies_flagGlobal']['use'] = false + data['flagCookies_flagGlobal'] = false await browser.storage.local.set(data) let hasAutoFlag = data['flagCookies_autoFlag'] !== undefined ? data['flagCookies_autoFlag'][domainURL] !== undefined : false @@ -782,7 +782,7 @@ async function switchAutoFlagNeutral(data, switchOn, targetList) { if (data[domainURL][cookieKey] === 'af') { delete data[domainURL][cookieKey] - if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal']['use'] !== true) { + if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'] !== true) { contentChild.className = 'checkmark' } } @@ -958,7 +958,7 @@ async function resetUIDomain (data) { let contentChild = child.children[0] let contentChildProfile = child.children[2] - if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal']['use'] === true) { + if (data['flagCookies_flagGlobal'] !== undefined && data['flagCookies_flagGlobal'] === true) { contentChild.className = 'checkmark auto-flagged' } else { contentChild.className = 'checkmark' diff --git a/manifest.json b/manifest.json index b32ec30..960b9f2 100644 --- a/manifest.json +++ b/manifest.json @@ -32,7 +32,7 @@ "manifest_version": 2, "name": "Flag Cookies", "version": "1.6.1", - "permissions": ["cookies", "tabs", "", "storage", "unlimitedStorage"], + "permissions": ["cookies", "tabs", "webNavigation", "", "storage", "unlimitedStorage"], "background": { "scripts": [ "cookies.js"