-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bd6269
commit c45b2b2
Showing
6 changed files
with
77 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | ||
<script src="/polyfill/browser-polyfill.min.js"></script> | ||
<script src="/polyfill/asmcrypto.js"></script> | ||
<script src="/firefoxFix.js"></script> | ||
</head> | ||
<body></body> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> | ||
<script src="/polyfill/browser-polyfill.min.js"></script> | ||
<script src="/polyfill/asmcrypto.js"></script> | ||
<script src="/firefoxFix.js"></script> | ||
<script src="/env.js"></script> | ||
</head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Currently we don't have so much code that need conditional compilation. | ||
* | ||
* So let's set process.env.target in runtime and reduce the compile time. | ||
*/ | ||
if (!globalThis.process) { | ||
globalThis.process = {} | ||
} | ||
if (!globalThis.process.env) { | ||
globalThis.process.env = {} | ||
} | ||
if (!globalThis.process.env.target) { | ||
const isFirefox = navigator.userAgent.match('Firefox') | ||
const isChrome = navigator.appVersion.match(/(Chromium|Chrome)/) | ||
const isiOS = navigator.appVersion.toLowerCase().match('ios') | ||
// 'Chromium' | 'Firefox' | 'WKWebview' | undefined | ||
globalThis.process.env.target = isFirefox ? 'Firefox' : isChrome ? 'Chromium' : isiOS ? 'WKWebview' : undefined | ||
} | ||
if (globalThis.process.env.target === 'Firefox') { | ||
// firefoxVariant: 'android' | 'desktop' | 'GeckoView' | undefined | ||
const isMobile = navigator.userAgent.match(/Mobile|mobile/) | ||
if (!globalThis.process.env.firefoxVariant) { | ||
// TODO: How can we know if it is GeckoView in runtime? | ||
globalThis.process.env.firefoxVariant = isMobile ? 'desktop' : 'android' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
/// <reference types="web-ext-types" /> | ||
|
||
declare namespace NodeJS { | ||
interface ProcessEnv { | ||
readonly target: 'Chromium' | 'Firefox' | 'WKWebview' | undefined | ||
readonly firefoxVariant: 'android' | 'desktop' | 'GeckoView' | undefined | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters