summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFéry Mathieu (Mathius) <ferymathieuy@gmail.com>2022-02-22 20:05:22 +0100
committerFéry Mathieu (Mathius) <ferymathieuy@gmail.com>2022-02-22 20:05:22 +0100
commitaa8758dec29cb70dbdd3e34af74a4925b0990225 (patch)
tree5a27310656113416d5bf5227266c90f07aff0a70
parentad6b29c09f3721cabdb1cb44de8a71f0498f3e13 (diff)
downloadinvidious-aa8758dec29cb70dbdd3e34af74a4925b0990225.tar.gz
invidious-aa8758dec29cb70dbdd3e34af74a4925b0990225.tar.bz2
invidious-aa8758dec29cb70dbdd3e34af74a4925b0990225.zip
Patch updateCookie for preserve extra args (like domain)
-rw-r--r--assets/js/player.js25
1 files changed, 13 insertions, 12 deletions
diff --git a/assets/js/player.js b/assets/js/player.js
index c7dd9159..8057b678 100644
--- a/assets/js/player.js
+++ b/assets/js/player.js
@@ -198,24 +198,25 @@ 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 {
- var date = new Date();
- // Set expiration in 2 year
- date.setTime(date.getTime() + 63115200);
- var ipv4Regex = /(([0-1]?[0-9]{1,2}\.)|(2[0-4][0-9]\.)|(25[0-5]\.)){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))/;
- var ipv6Regex = /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/;
- 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() + ';';
+ cookieData = encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue }));
}
+ var date = new Date();
+ // Set expiration in 2 year
+ date.setTime(date.getTime() + 63115200);
+ var ipv4Regex = /(([0-1]?[0-9]{1,2}\.)|(2[0-4][0-9]\.)|(25[0-5]\.)){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))/;
+ var ipv6Regex = /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/;
+ var domainUsed = window.location.hostname;
+ if (!ipv4Regex.test(domainUsed) && !ipv6Regex.test(domainUsed) && domainUsed != 'localhost')
+ domainUsed = '.' + window.location.hostname;
+ document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' +
+ domainUsed + '; expires=' + date.toGMTString() + ';';
video_data.params.volume = volumeValue;
video_data.params.speed = speedValue;
}