Make local storage unique to Tautulli instance

This commit is contained in:
JonnyWong16 2018-10-15 18:20:16 -07:00
parent 1bce850765
commit f2fedb182c

View file

@ -517,23 +517,23 @@ function PopupCenter(url, title, w, h) {
return newWindow;
}
function setLocalStorage(key, value) {
function setLocalStorage(key, value, path) {
if (path !== false) {
key = key + '_' + window.location.pathname;
}
localStorage.setItem(key, value);
}
function getLocalStorage(key, default_value) {
function getLocalStorage(key, default_value, path) {
var value = localStorage.getItem(key);
if (value !== null) {
return value
} else if (default_value !== undefined) {
setLocalStorage(key, default_value);
setLocalStorage(key, default_value, path);
return default_value
}
}
if (!getLocalStorage('Tautulli_ClientId')) {
setLocalStorage('Tautulli_ClientId', uuidv4());
}
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
@ -545,7 +545,7 @@ var x_plex_headers = {
'Accept': 'application/json',
'X-Plex-Product': 'Tautulli',
'X-Plex-Version': 'Plex OAuth',
'X-Plex-Client-Identifier': localStorage.getItem('Tautulli_ClientId'),
'X-Plex-Client-Identifier': getLocalStorage('Tautulli_ClientID', uuidv4(), false),
'X-Plex-Platform': p.name,
'X-Plex-Platform-Version': p.version,
'X-Plex-Device': p.os,