Patch updateCookie for preserve extra args (like domain)
This commit is contained in:
parent
ad6b29c09f
commit
aa8758dec2
@ -198,12 +198,15 @@ function updateCookie(newVolume, newSpeed) {
|
||||
var volumeValue = newVolume != null ? newVolume : video_data.params.volume;
|
||||
var speedValue = newSpeed != null ? newSpeed : video_data.params.speed;
|
||||
var cookieValue = getCookieValue('PREFS');
|
||||
var cookieData;
|
||||
if (cookieValue != null) {
|
||||
var cookieJson = JSON.parse(decodeURIComponent(cookieValue));
|
||||
cookieJson.volume = volumeValue;
|
||||
cookieJson.speed = speedValue;
|
||||
document.cookie = document.cookie.replace(getCookieValue('PREFS'), encodeURIComponent(JSON.stringify(cookieJson)));
|
||||
cookieData = encodeURIComponent(JSON.stringify(cookieJson));
|
||||
} else {
|
||||
cookieData = encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue }));
|
||||
}
|
||||
var date = new Date();
|
||||
// Set expiration in 2 year
|
||||
date.setTime(date.getTime() + 63115200);
|
||||
@ -212,10 +215,8 @@ function updateCookie(newVolume, newSpeed) {
|
||||
var domainUsed = window.location.hostname;
|
||||
if (!ipv4Regex.test(domainUsed) && !ipv6Regex.test(domainUsed) && domainUsed != 'localhost')
|
||||
domainUsed = '.' + window.location.hostname;
|
||||
document.cookie = 'PREFS=' +
|
||||
encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue })) +
|
||||
'; SameSite=Strict; path=/; domain=' + domainUsed + '; expires=' + date.toGMTString() + ';';
|
||||
}
|
||||
document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' +
|
||||
domainUsed + '; expires=' + date.toGMTString() + ';';
|
||||
video_data.params.volume = volumeValue;
|
||||
video_data.params.speed = speedValue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user