mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Improve context detection
This commit is contained in:
parent
6afda3b632
commit
9a9ba48d51
1 changed files with 17 additions and 1 deletions
|
@ -3,7 +3,23 @@ import browserProxy from './browser_proxy'
|
|||
import * as config from '../config'
|
||||
|
||||
export function inContentScript() {
|
||||
return ! ('tabs' in browser)
|
||||
return getContext() == 'content'
|
||||
}
|
||||
|
||||
/** WebExt code can be run from three contexts:
|
||||
|
||||
Content script
|
||||
Extension page
|
||||
Background page
|
||||
*/
|
||||
export function getContext() {
|
||||
if (! ('tabs' in browser)) {
|
||||
return 'content'
|
||||
} else if (browser.runtime.getURL('_generated_background_page.html') == window.location.href) {
|
||||
return 'background'
|
||||
} else {
|
||||
return 'extension'
|
||||
}
|
||||
}
|
||||
|
||||
export let browserBg
|
||||
|
|
Loading…
Add table
Reference in a new issue