Make local storage unique to Tautulli instance
This commit is contained in:
@@ -517,23 +517,23 @@ function PopupCenter(url, title, w, h) {
|
|||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLocalStorage(key, value) {
|
|
||||||
|
function setLocalStorage(key, value, path) {
|
||||||
|
if (path !== false) {
|
||||||
|
key = key + '_' + window.location.pathname;
|
||||||
|
}
|
||||||
localStorage.setItem(key, value);
|
localStorage.setItem(key, value);
|
||||||
}
|
}
|
||||||
function getLocalStorage(key, default_value) {
|
function getLocalStorage(key, default_value, path) {
|
||||||
var value = localStorage.getItem(key);
|
var value = localStorage.getItem(key);
|
||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
return value
|
return value
|
||||||
} else if (default_value !== undefined) {
|
} else if (default_value !== undefined) {
|
||||||
setLocalStorage(key, default_value);
|
setLocalStorage(key, default_value, path);
|
||||||
return default_value
|
return default_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getLocalStorage('Tautulli_ClientId')) {
|
|
||||||
setLocalStorage('Tautulli_ClientId', uuidv4());
|
|
||||||
}
|
|
||||||
|
|
||||||
function uuidv4() {
|
function uuidv4() {
|
||||||
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
|
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
|
||||||
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
|
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
|
||||||
@@ -545,7 +545,7 @@ var x_plex_headers = {
|
|||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'X-Plex-Product': 'Tautulli',
|
'X-Plex-Product': 'Tautulli',
|
||||||
'X-Plex-Version': 'Plex OAuth',
|
'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': p.name,
|
||||||
'X-Plex-Platform-Version': p.version,
|
'X-Plex-Platform-Version': p.version,
|
||||||
'X-Plex-Device': p.os,
|
'X-Plex-Device': p.os,
|
||||||
|
Reference in New Issue
Block a user