Skip to content

Commit

Permalink
Adding opera/chrome changes for new features
Browse files Browse the repository at this point in the history
  • Loading branch information
jrie committed Apr 24, 2018
1 parent 9a81a93 commit f3c3fbc
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ async function clearCookiesOnWindowClose (window) {

async function gatherTabInformation (windowId) {
if (useChrome) {

chrome.tabs.query({windowId: windowId}, function (tabs) {
if (tabLoadAttempts === 0) tabsToGather[windowId] = tabs.length
for (let tab of tabs) addTabURLtoDataList(tab)
Expand All @@ -923,6 +922,7 @@ async function gatherTabInformation (windowId) {

++tabLoadAttempts
})
return
}

let tabs = await browser.tabs.query({windowId: windowId})
Expand Down Expand Up @@ -952,6 +952,33 @@ function addTabURLsToDataList (window) {
}


async function clearCookiesOnRequestChrome (details) {
chrome.tabs.query({currentWindow: true, active: true}, function (activeTabs) {
if (!checkChromeHadNoErrors()) return
if (activeTabs.length !== 0) {
let currentTab = activeTabs.pop()

if (currentTab.status === 'complete') return
currentTab.url = details.url

if (openTabData[currentTab.windowId] === undefined) openTabData[currentTab.windowId] = {}

let activeCookieStore = 'default'
openTabData[currentTab.windowId][currentTab.id] = {'u': currentTab.url.match(/(http|https):\/\/[a-zA-Z0-9öäüÖÄÜ.\-]*\//)[0], 'd': getURLDomain(currentTab.url)}

let domainURL
let urlMatch = details.url.replace(/\/www\./, '/').match(/(http|https):\/\/[a-zA-Z0-9öäüÖÄÜ.\-]*\//)
if (urlMatch !== null) domainURL = urlMatch[0]
else domainURL = details.url.replace(/\/www\./, '/')

clearDomainLog(domainURL, activeCookieStore)
chromeGetStorageAndClearCookies('document load', null, null, domainURL, false)
}
})
}



async function clearCookiesOnRequest (details) {
if (details.method === 'GET') {
let currentTab = await getActiveTabFirefox()
Expand All @@ -962,13 +989,8 @@ async function clearCookiesOnRequest (details) {
if (openTabData[currentTab.windowId] === undefined) openTabData[currentTab.windowId] = {}

let activeCookieStore = 'default'
if (!useChrome) {
if (currentTab.cookieStoreId !== undefined) {
activeCookieStore = currentTab.cookieStoreId
}
} else {
openTabData[currentTab.windowId][currentTab.id] = {'u': currentTab.url.match(/(http|https):\/\/[a-zA-Z0-9öäüÖÄÜ.\-]*\//)[0], 'd': getURLDomain(currentTab.url)}
return
if (currentTab.cookieStoreId !== undefined) {
activeCookieStore = currentTab.cookieStoreId
}

let domainURL
Expand Down Expand Up @@ -1032,7 +1054,7 @@ async function clearCookiesOnRequest (details) {
if (useChrome) {
chrome.tabs.onRemoved.addListener(clearCookiesOnLeave)
chrome.tabs.onUpdated.addListener(clearCookiesOnUpdate)
chrome.webNavigation.onBeforeNavigate.addListener(clearCookiesOnNavigate)
//chrome.webNavigation.onBeforeNavigate.addListener(clearCookiesOnNavigate)
chrome.runtime.onMessage.addListener(handleMessage)
chrome.commands.onCommand.addListener(getCommand)
chrome.cookies.onChanged.addListener(onCookieChanged)
Expand All @@ -1041,6 +1063,8 @@ if (useChrome) {
chrome.windows.onFocusChanged.addListener(addTabURLsToDataList)
chrome.windows.onRemoved.addListener(clearCookiesOnWindowClose)
chrome.tabs.onCreated.addListener(addTabURLtoDataList)
chrome.webRequest.onBeforeRequest.addListener(clearCookiesOnRequestChrome, {urls: ['<all_urls>'], types: ['main_frame', 'sub_frame', 'xmlhttprequest']}, ['blocking'])

} else {
browser.tabs.onRemoved.addListener(clearCookiesOnLeave)
browser.tabs.onUpdated.addListener(clearCookiesOnUpdate)
Expand All @@ -1054,5 +1078,5 @@ if (useChrome) {
browser.windows.onFocusChanged.addListener(addTabURLsToDataList)
browser.windows.onRemoved.addListener(clearCookiesOnWindowClose)
browser.tabs.onCreated.addListener(addTabURLtoDataList)
browser.webRequest.onBeforeRequest.addListener(clearCookiesOnRequest, {urls: ["<all_urls>"], types: ['main_frame', 'sub_frame', 'xmlhttprequest']}, ['blocking'])
browser.webRequest.onBeforeRequest.addListener(clearCookiesOnRequest, {urls: ['<all_urls>'], types: ['main_frame', 'sub_frame', 'xmlhttprequest']}, ['blocking'])
}

0 comments on commit f3c3fbc

Please sign in to comment.