diff --git a/assets/js/player.js b/assets/js/player.js
index 34f721b4..5498df48 100644
--- a/assets/js/player.js
+++ b/assets/js/player.js
@@ -176,17 +176,55 @@ if (video_data.params.video_start > 0 || video_data.params.video_end > 0) {
player.currentTime(video_data.params.video_start);
}
-/*
- If the video settings are default, we enable the management of the settings by
- the videojs-persist module otherwise we apply the preferences.
-*/
-if (video_data.params.volume == 100 && video_data.params.speed == "1.0")
- player.persist();
-else {
- player.volume(video_data.params.volume / 100);
- player.playbackRate(video_data.params.speed);
+player.volume(video_data.params.volume / 100);
+player.playbackRate(video_data.params.speed);
+
+/**
+ * Method for get content of Cookie
+ * @param {String} name Name of cookie
+ * @returns cookieValue
+ */
+function getCookieValue(name) {
+ var value = document.cookie.split(";").filter(item => {
+ return item.includes(name + "=");
+ });
+ return value != null && value.length >= 1 ? value[0].substring((name + "=").length, value[0].length) : null;
}
+/**
+ * Method for update Prefs cookie (Or create if missing)
+ * @param {number} newVolume New Volume defined (Null if unchanged)
+ * @param {number} newSpeed New Speed defined (Null if unchanged)
+ */
+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');
+ 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)));
+ } else {
+ var date = new Date();
+ //Set expiration in 2 year
+ date.setTime(date.getTime() + 63115200);
+ document.cookie = 'PREFS=' +
+ encodeURIComponent(JSON.stringify({ 'volume': volumeValue, 'speed': speedValue })) +
+ '; expires=' + date.toGMTString() + '; SameSite=Strict; path=/';
+ }
+ video_data.params.volume = volumeValue;
+ video_data.params.speed = speedValue;
+}
+
+player.on('ratechange', function () {
+ updateCookie(null, player.playbackRate());
+});
+
+player.on('volumechange', function () {
+ updateCookie(Math.ceil(player.volume() * 100), null);
+});
+
player.on('waiting', function () {
if (player.playbackRate() > 1 && player.liveTracker.isLive() && player.liveTracker.atLiveEdge()) {
console.log('Player has caught up to source, resetting playbackRate.')
diff --git a/src/invidious/user/cookies.cr b/src/invidious/user/cookies.cr
index 99df1b07..367f700f 100644
--- a/src/invidious/user/cookies.cr
+++ b/src/invidious/user/cookies.cr
@@ -30,7 +30,7 @@ struct Invidious::User
value: URI.encode_www_form(preferences.to_json),
expires: Time.utc + 2.years,
secure: SECURE,
- http_only: true
+ http_only: false
)
end
end
diff --git a/src/invidious/views/components/player_sources.ecr b/src/invidious/views/components/player_sources.ecr
index 305464c8..9af3899c 100644
--- a/src/invidious/views/components/player_sources.ecr
+++ b/src/invidious/views/components/player_sources.ecr
@@ -11,7 +11,6 @@
-
diff --git a/videojs-dependencies.yml b/videojs-dependencies.yml
index b9754e0e..6de23d25 100644
--- a/videojs-dependencies.yml
+++ b/videojs-dependencies.yml
@@ -25,10 +25,6 @@ videojs-overlay:
version: 2.1.4
shasum: 5a103b25374dbb753eb87960d8360c2e8f39cc05
-videojs-persist:
- version: 0.1.2
- shasum: 44da05aced1fbf15693a36b7cce3cc4a9960dabe
-
videojs-share:
version: 3.2.1
shasum: 0a3024b981387b9d21c058c829760a72c14b8ceb