haketilo / common / gen_unique.js @ 261548ff
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 |
/*
|
9 |
* IMPORTS_START
|
10 |
* IMPORT sha256
|
11 |
* IMPORT browser
|
12 |
* IMPORT is_chrome
|
13 |
* IMPORTS_END
|
14 |
*/
|
15 |
|
16 |
function get_id() |
17 |
{
|
18 |
if (is_chrome) |
19 |
return browser.runtime.getManifest().key.substring(0, 50); |
20 |
else
|
21 |
return browser.runtime.getURL("dummy"); |
22 |
}
|
23 |
|
24 |
function gen_unique(url) |
25 |
{
|
26 |
return "#" + sha256(get_id() + url); |
27 |
}
|
28 |
|
29 |
/*
|
30 |
* EXPORTS_START
|
31 |
* EXPORT gen_unique
|
32 |
* EXPORTS_END
|
33 |
*/
|