1
|
/**
|
2
|
* Myext generating unique, per-site hash
|
3
|
*
|
4
|
* Copyright (C) 2021 Wojtek Kosior
|
5
|
* Redistribution terms are gathered in the `copyright' file.
|
6
|
*/
|
7
|
|
8
|
"use strict";
|
9
|
|
10
|
(() => {
|
11
|
const sha256 = window.sha256;
|
12
|
const browser = window.browser;
|
13
|
const is_chrome = window.is_chrome;
|
14
|
|
15
|
function get_id()
|
16
|
{
|
17
|
if (is_chrome)
|
18
|
return browser.runtime.getManifest().key.substring(0, 50);
|
19
|
else
|
20
|
return browser.runtime.getURL("dummy");
|
21
|
}
|
22
|
|
23
|
function gen_unique(url)
|
24
|
{
|
25
|
return "#" + sha256(get_id() + url);
|
26
|
}
|
27
|
|
28
|
window.gen_unique = gen_unique;
|
29
|
})();
|