aboutsummaryrefslogtreecommitdiff
path: root/common/gen_unique.js
diff options
context:
space:
mode:
Diffstat (limited to 'common/gen_unique.js')
-rw-r--r--common/gen_unique.js32
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;
+})();