Skip to content

Commit 06ef3d8

Browse files
move the betafeatures check to global.ts so that its more performant
1 parent c6a6ada commit 06ef3d8

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/content-scripts/content_script/global.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,25 +1546,41 @@ export async function main(
15461546
},
15471547
})
15481548
}
1549-
const imageElements = document.getElementsByTagName('img')
15501549

1551-
const disabledServices = [
1552-
'https://www.facebook.com/',
1553-
'https://www.instagram.com/',
1554-
'https://www.pinterest.com/',
1555-
]
1550+
const betaFeatureSetting = await syncSettings.betaFeatures.get(
1551+
'imageOverlay',
1552+
)
15561553

1557-
if (
1558-
imageElements.length > 0 &&
1559-
!disabledServices.some((url) => fullPageUrl.includes(url))
1560-
) {
1561-
inPageUI.loadOnDemandInPageUI({
1562-
component: 'img-action-buttons',
1563-
options: {
1564-
imageElements,
1565-
contentScriptsBG,
1566-
},
1567-
})
1554+
let imageInjectionEnabled = null
1555+
if (betaFeatureSetting != null) {
1556+
imageInjectionEnabled = betaFeatureSetting
1557+
}
1558+
1559+
if (imageInjectionEnabled == null) {
1560+
await syncSettings.betaFeatures.set('imageOverlay', false)
1561+
}
1562+
1563+
if (imageInjectionEnabled) {
1564+
const imageElements = document.getElementsByTagName('img')
1565+
1566+
const disabledServices = [
1567+
'https://www.facebook.com/',
1568+
'https://www.instagram.com/',
1569+
'https://www.pinterest.com/',
1570+
]
1571+
1572+
if (
1573+
imageElements.length > 0 &&
1574+
!disabledServices.some((url) => fullPageUrl.includes(url))
1575+
) {
1576+
inPageUI.loadOnDemandInPageUI({
1577+
component: 'img-action-buttons',
1578+
options: {
1579+
imageElements,
1580+
contentScriptsBG,
1581+
},
1582+
})
1583+
}
15681584
}
15691585

15701586
// Function to track when the subscription has been updated by going to our website (which the user arrives through a redirect)

src/search-injection/img-action-buttons.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,6 @@ export const handleRenderImgActionButtons = async (
150150
imageElements: HTMLCollectionOf<HTMLImageElement>,
151151
contentScriptsBG: ContentScriptsInterface<'caller'>,
152152
) => {
153-
const betaFeatureSetting = await syncSettings.betaFeatures.get(
154-
'imageOverlay',
155-
)
156-
let imageInjectionEnabled = null
157-
if (betaFeatureSetting != null) {
158-
imageInjectionEnabled = betaFeatureSetting
159-
}
160-
161-
if (imageInjectionEnabled == null) {
162-
await syncSettings.betaFeatures.set('imageOverlay', false)
163-
}
164-
165-
if (!imageInjectionEnabled) {
166-
return
167-
}
168-
169153
let shouldShow = true
170154
if (imageElements.length === 0) {
171155
return

0 commit comments

Comments
 (0)