mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Update cookie domain definition in player script
Related with : https://github.com/iv-org/invidious/pull/2895#issuecomment-1047762544
This commit is contained in:
parent
09a585c93b
commit
ad6b29c09f
1 changed files with 6 additions and 1 deletions
|
@ -207,9 +207,14 @@ function updateCookie(newVolume, newSpeed) {
|
||||||
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);
|
||||||
|
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=' +
|
document.cookie = 'PREFS=' +
|
||||||
encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue })) +
|
encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue })) +
|
||||||
'; SameSite=Strict; path=/; 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 a new issue