@@ -229,6 +229,10 @@ async function getPlatform() {
229229 os = 'windows' ;
230230 } else if ( os === 'mac' ) {
231231 os = 'macos' ;
232+ } else if ( os === 'cros' ) {
233+ os = 'chromeos' ;
234+ } else if ( os . includes ( 'bsd' ) ) {
235+ os = 'linux' ;
232236 }
233237
234238 if ( [ 'x86-32' , 'i386' ] . includes ( arch ) ) {
@@ -242,20 +246,22 @@ async function getPlatform() {
242246 const isWindows = os === 'windows' ;
243247 const isMacos = os === 'macos' ;
244248 const isLinux = os === 'linux' ;
249+ const isChromeos = os === 'chromeos' ;
245250 const isAndroid = os === 'android' ;
246251 const isIos = os === 'ios' ;
247252 const isIpados = os === 'ipados' ;
253+ const isVisionos = os === 'visionos' ;
248254
249255 const isMobile = [ 'android' , 'ios' , 'ipados' ] . includes ( os ) ;
250256
251- const isChrome = targetEnv === 'chrome ' ;
257+ const isFirefox = targetEnv === 'firefox ' ;
252258 const isEdge =
253259 [ 'chrome' , 'edge' ] . includes ( targetEnv ) &&
254260 / \s e d g (?: e | a | i o s ) ? \/ / i. test ( navigator . userAgent ) ;
255- const isFirefox = targetEnv === 'firefox' ;
256261 const isOpera =
257262 [ 'chrome' , 'opera' ] . includes ( targetEnv ) &&
258263 / \s o p r \/ / i. test ( navigator . userAgent ) ;
264+ const isChrome = targetEnv === 'chrome' && ! isEdge && ! isOpera ;
259265 const isSafari = targetEnv === 'safari' ;
260266 const isSamsung = targetEnv === 'samsung' ;
261267
@@ -266,9 +272,11 @@ async function getPlatform() {
266272 isWindows,
267273 isMacos,
268274 isLinux,
275+ isChromeos,
269276 isAndroid,
270277 isIos,
271278 isIpados,
279+ isVisionos,
272280 isMobile,
273281 isChrome,
274282 isEdge,
@@ -280,8 +288,7 @@ async function getPlatform() {
280288}
281289
282290async function isAndroid ( ) {
283- const { os} = await getPlatform ( ) ;
284- return os === 'android' ;
291+ return ( await getPlatform ( ) ) . isAndroid ;
285292}
286293
287294function getDarkColorSchemeQuery ( ) {
@@ -297,11 +304,9 @@ function getDayPrecisionEpoch(epoch) {
297304}
298305
299306function isBackgroundPageContext ( ) {
300- const backgroundUrl = mv3
301- ? browser . runtime . getURL ( '/src/background/script.js' )
302- : browser . runtime . getURL ( '/src/background/index.html' ) ;
303-
304- return self . location . href === backgroundUrl ;
307+ return self . location . href . startsWith (
308+ browser . runtime . getURL ( '/src/background/' )
309+ ) ;
305310}
306311
307312function getExtensionDomain ( ) {
@@ -534,11 +539,21 @@ function sendOffscreenMessage(message) {
534539 } ) ;
535540}
536541
537- function runOnce ( name , func ) {
538- name = `${ name } Run ` ;
542+ function getStore ( name , { content = null } = { } ) {
543+ name = `${ name } Store ` ;
539544
540545 if ( ! self [ name ] ) {
541- self [ name ] = true ;
546+ self [ name ] = content || { } ;
547+ }
548+
549+ return self [ name ] ;
550+ }
551+
552+ function runOnce ( name , func ) {
553+ const store = getStore ( 'run' ) ;
554+
555+ if ( ! store [ name ] ) {
556+ store [ name ] = true ;
542557
543558 if ( ! func ) {
544559 return true ;
@@ -580,6 +595,7 @@ export {
580595 prepareAudio ,
581596 setupOffscreenDocument ,
582597 sendOffscreenMessage ,
598+ getStore ,
583599 runOnce ,
584600 sleep
585601} ;
0 commit comments