this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactoring Privacy & Security, prep for 1.4.0

+27 -16
+27 -16
background.js
··· 97 97 action.setIcon({ path: iconName, tabId }) 98 98 } 99 99 100 + // Map to store the last domain of each tab 101 + // This is used below to prevent triggering 102 + // peformAction unless the domain of a tab changes 103 + const tabsWithLastDomain = new Map() 104 + 100 105 // Main function to perform actions, but only if the privacy consent has been accepted 101 106 function performAction(tab) { 102 107 storage.get("privacyConsentAccepted", ({ privacyConsentAccepted }) => { ··· 104 109 if (privacyConsentAccepted) { 105 110 const domain = getDomainName(tab.url) 106 111 if (isValidDomain(domain)) { 107 - checkForDIDDNS(domain).then((domainDID) => { 108 - if (domainDID) { 109 - setIcon(tab.id, "logo48.png") 110 - tabsWithDID.set(tab.id, domainDID) 111 - } else { 112 - checkForDIDHTTPS(domain).then((httpsDID) => { 113 - if (httpsDID) { 114 - setIcon(tab.id, "logo48.png") 115 - tabsWithDID.set(tab.id, httpsDID) 116 - } else { 117 - setIcon(tab.id, "logo48_gray.png") 118 - tabsWithDID.delete(tab.id) 119 - } 120 - }) 121 - } 122 - }) 112 + const lastDomain = tabsWithLastDomain.get(tab.id) 113 + if (domain !== lastDomain) { 114 + // Update the last domain of the tab 115 + tabsWithLastDomain.set(tab.id, domain) 116 + // Check for DIDs 117 + checkForDIDDNS(domain).then((domainDID) => { 118 + if (domainDID) { 119 + setIcon(tab.id, "logo48.png") 120 + tabsWithDID.set(tab.id, domainDID) 121 + } else { 122 + checkForDIDHTTPS(domain).then((httpsDID) => { 123 + if (httpsDID) { 124 + setIcon(tab.id, "logo48.png") 125 + tabsWithDID.set(tab.id, httpsDID) 126 + } else { 127 + setIcon(tab.id, "logo48_gray.png") 128 + tabsWithDID.delete(tab.id) 129 + } 130 + }) 131 + } 132 + }) 133 + } 123 134 } 124 135 } 125 136 })