mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
35 lines
818 B
JavaScript
35 lines
818 B
JavaScript
(function (globalScope) {
|
|
|
|
if (!globalScope.MediaBrowser) {
|
|
globalScope.MediaBrowser = {};
|
|
}
|
|
|
|
globalScope.MediaBrowser.generateDeviceId = function (keyName, seed) {
|
|
|
|
keyName = keyName || 'randomId';
|
|
|
|
var keys = [];
|
|
|
|
keys.push(navigator.userAgent);
|
|
keys.push((navigator.cpuClass || ""));
|
|
|
|
if (seed) {
|
|
keys.push(seed);
|
|
}
|
|
var randomId = '';
|
|
|
|
// Since the above is not guaranteed to be unique per device, add a little more
|
|
randomId = appStorage.getItem(keyName);
|
|
|
|
if (!randomId) {
|
|
|
|
randomId = new Date().getTime();
|
|
|
|
appStorage.setItem(keyName, randomId.toString());
|
|
}
|
|
|
|
keys.push(randomId);
|
|
return CryptoJS.SHA1(keys.join('|')).toString();
|
|
};
|
|
|
|
})(window); |