diff options
author | jahoti <jahoti@tilde.team> | 2021-07-11 00:00:00 +0000 |
---|---|---|
committer | jahoti <jahoti@tilde.team> | 2021-07-11 00:00:00 +0000 |
commit | 229e86f6086f90f5c132b4a11e5922de899dbb21 (patch) | |
tree | 24a7aecf5006bcb8644de74acc5d004aa7dd9418 | |
parent | c86bdfcd9d56309faca69b58830cea1fa98870e0 (diff) | |
download | browser-extension-229e86f6086f90f5c132b4a11e5922de899dbb21.tar.gz browser-extension-229e86f6086f90f5c132b4a11e5922de899dbb21.zip |
Integrate browser.js into exports_init.js, and streamline the result
-rwxr-xr-x | build.sh | 16 | ||||
-rw-r--r-- | common/browser.js | 23 |
2 files changed, 11 insertions, 28 deletions
@@ -150,7 +150,7 @@ compute_scripts_list_rec() { fi done - echo $FILE + [ "x$FILE" = "xexports_init.js" ] || echo $FILE # exports_init.js is hardcoded to load first; the entire export system depends on it map_set FILESTATES $FILEKEY "processed" } @@ -194,6 +194,11 @@ set_browser() { main() { set_browser "$1" + + # placate importers of these, as they are exported by the yet-to-be-created exports_init.js + EXPORTS__browser=exports_init.js + EXPORTS__is_chrome=exports_init.js + EXPORTS__is_mozilla=exports_init.js SCRIPTDIRS='background html common content' @@ -288,10 +293,11 @@ $(map_get EXPORTCODES $FILEKEY) fi done - echo "\ -window.killtheweb={}; -window.browser = this.browser; /* fix for stupid Firefox */ -" > $BUILDDIR/exports_init.js + if [ "$BROWSER" = "chromium" ]; then + echo "window.killtheweb={is_chrome: true, browser: window.chrome};" > $BUILDDIR/exports_init.js + else + echo "window.killtheweb={is_mozilla: true, browser: this.browser};" > $BUILDDIR/exports_init.js + fi cp -r icons/ copyright licenses/ $BUILDDIR } diff --git a/common/browser.js b/common/browser.js deleted file mode 100644 index e50a121..0000000 --- a/common/browser.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Myext WebExtension API access normalization - * - * Copyright (C) 2021 Wojtek Kosior - * Redistribution terms are gathered in the `copyright' file. - */ - -/* - * This module normalizes access to WebExtension apis between - * chrome-based and firefox-based browsers. - */ - -const is_mozilla = typeof window.browser === "object"; -const is_chrome = !is_mozilla; -const browser = window[is_chrome ? "chrome" : "browser"]; - -/* - * EXPORTS_START - * EXPORT browser - * EXPORT is_chrome - * EXPORT is_mozilla - * EXPORTS_END - */ |