diff options
author | Wojtek Kosior <wk@koszkonutek-tmp.pl.eu.org> | 2021-05-12 17:25:57 +0200 |
---|---|---|
committer | Wojtek Kosior <wk@koszkonutek-tmp.pl.eu.org> | 2021-05-12 17:25:57 +0200 |
commit | 55fb3e4bd833f042a82657cc75e7e4c657402f9e (patch) | |
tree | c5198bfc075d680629850c7e47f45027581d8707 /common/gen_unique.js | |
parent | 9c246cfa2e30c2f7887472084b4ace4ab99b9819 (diff) | |
download | browser-extension-55fb3e4bd833f042a82657cc75e7e4c657402f9e.tar.gz browser-extension-55fb3e4bd833f042a82657cc75e7e4c657402f9e.zip |
use unique hashes when smuggling whitelist setting
Diffstat (limited to 'common/gen_unique.js')
-rw-r--r-- | common/gen_unique.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/common/gen_unique.js b/common/gen_unique.js new file mode 100644 index 0000000..920426b --- /dev/null +++ b/common/gen_unique.js @@ -0,0 +1,32 @@ +/** +* Myext generating unique, per-site hash +* +* Copyright (C) 2021 Wojtek Kosior +* +* Dual-licensed under: +* - 0BSD license +* - GPLv3 or (at your option) any later version +*/ + +"use strict"; + +(() => { + const sha256 = window.sha256; + const browser = window.browser; + const is_chrome = window.is_chrome; + + function get_id() + { + if (is_chrome) + return browser.runtime.getManifest().key.substring(0, 50); + else + return browser.runtime.getURL("dummy"); + } + + function gen_unique(url) + { + return "#" + sha256(get_id() + url); + } + + window.gen_unique = gen_unique; +})(); |