mirror of
https://github.com/iv-org/invidious
synced 2024-11-03 03:40:35 +00:00
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 volumeValue = newVolume != null ? newVolume : video_data.params.volume;
|
||||||
var speedValue = newSpeed != null ? newSpeed : video_data.params.speed;
|
var speedValue = newSpeed != null ? newSpeed : video_data.params.speed;
|
||||||
var cookieValue = getCookieValue('PREFS');
|
var cookieValue = getCookieValue('PREFS');
|
||||||
|
var cookieData;
|
||||||
if (cookieValue != null) {
|
if (cookieValue != null) {
|
||||||
var cookieJson = JSON.parse(decodeURIComponent(cookieValue));
|
var cookieJson = JSON.parse(decodeURIComponent(cookieValue));
|
||||||
cookieJson.volume = volumeValue;
|
cookieJson.volume = volumeValue;
|
||||||
cookieJson.speed = speedValue;
|
cookieJson.speed = speedValue;
|
||||||
document.cookie = document.cookie.replace(getCookieValue('PREFS'), encodeURIComponent(JSON.stringify(cookieJson)));
|
cookieData = encodeURIComponent(JSON.stringify(cookieJson));
|
||||||
} else {
|
} else {
|
||||||
|
cookieData = encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue }));
|
||||||
|
}
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
// Set expiration in 2 year
|
// Set expiration in 2 year
|
||||||
date.setTime(date.getTime() + 63115200);
|
date.setTime(date.getTime() + 63115200);
|
||||||
@ -212,10 +215,8 @@ function updateCookie(newVolume, newSpeed) {
|
|||||||
var domainUsed = window.location.hostname;
|
var domainUsed = window.location.hostname;
|
||||||
if (!ipv4Regex.test(domainUsed) && !ipv6Regex.test(domainUsed) && domainUsed != 'localhost')
|
if (!ipv4Regex.test(domainUsed) && !ipv6Regex.test(domainUsed) && domainUsed != 'localhost')
|
||||||
domainUsed = '.' + window.location.hostname;
|
domainUsed = '.' + window.location.hostname;
|
||||||
document.cookie = 'PREFS=' +
|
document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' +
|
||||||
encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue })) +
|
domainUsed + '; expires=' + date.toGMTString() + ';';
|
||||||
'; SameSite=Strict; path=/; domain=' + domainUsed + '; expires=' + date.toGMTString() + ';';
|
|
||||||
}
|
|
||||||
video_data.params.volume = volumeValue;
|
video_data.params.volume = volumeValue;
|
||||||
video_data.params.speed = speedValue;
|
video_data.params.speed = speedValue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user