Revision 229e86f6
Added by jahoti about 2 years ago
build.sh | ||
---|---|---|
150 | 150 |
fi |
151 | 151 |
done |
152 | 152 |
|
153 |
echo $FILE
|
|
153 |
[ "x$FILE" = "xexports_init.js" ] || echo $FILE # exports_init.js is hardcoded to load first; the entire export system depends on it
|
|
154 | 154 |
map_set FILESTATES $FILEKEY "processed" |
155 | 155 |
} |
156 | 156 |
|
... | ... | |
194 | 194 |
|
195 | 195 |
main() { |
196 | 196 |
set_browser "$1" |
197 |
|
|
198 |
# placate importers of these, as they are exported by the yet-to-be-created exports_init.js |
|
199 |
EXPORTS__browser=exports_init.js |
|
200 |
EXPORTS__is_chrome=exports_init.js |
|
201 |
EXPORTS__is_mozilla=exports_init.js |
|
197 | 202 |
|
198 | 203 |
SCRIPTDIRS='background html common content' |
199 | 204 |
|
... | ... | |
288 | 293 |
fi |
289 | 294 |
done |
290 | 295 |
|
291 |
echo "\ |
|
292 |
window.killtheweb={}; |
|
293 |
window.browser = this.browser; /* fix for stupid Firefox */ |
|
294 |
" > $BUILDDIR/exports_init.js |
|
296 |
if [ "$BROWSER" = "chromium" ]; then |
|
297 |
echo "window.killtheweb={is_chrome: true, browser: window.chrome};" > $BUILDDIR/exports_init.js |
|
298 |
else |
|
299 |
echo "window.killtheweb={is_mozilla: true, browser: this.browser};" > $BUILDDIR/exports_init.js |
|
300 |
fi |
|
295 | 301 |
|
296 | 302 |
cp -r icons/ copyright licenses/ $BUILDDIR |
297 | 303 |
} |
common/browser.js | ||
---|---|---|
1 |
/** |
|
2 |
* Myext WebExtension API access normalization |
|
3 |
* |
|
4 |
* Copyright (C) 2021 Wojtek Kosior |
|
5 |
* Redistribution terms are gathered in the `copyright' file. |
|
6 |
*/ |
|
7 |
|
|
8 |
/* |
|
9 |
* This module normalizes access to WebExtension apis between |
|
10 |
* chrome-based and firefox-based browsers. |
|
11 |
*/ |
|
12 |
|
|
13 |
const is_mozilla = typeof window.browser === "object"; |
|
14 |
const is_chrome = !is_mozilla; |
|
15 |
const browser = window[is_chrome ? "chrome" : "browser"]; |
|
16 |
|
|
17 |
/* |
|
18 |
* EXPORTS_START |
|
19 |
* EXPORT browser |
|
20 |
* EXPORT is_chrome |
|
21 |
* EXPORT is_mozilla |
|
22 |
* EXPORTS_END |
|
23 |
*/ |
Also available in: Unified diff
Integrate browser.js into exports_init.js, and streamline the result