From 680dc1f962365d20ba0e11362ae3c18d993618ed Mon Sep 17 00:00:00 2001
From: saltycrys <73420320+saltycrys@users.noreply.github.com>
Date: Tue, 8 Dec 2020 02:30:48 +0100
Subject: [PATCH] Shuffle URL params

The `list` and `index` params are the most important and come first now.
---
 assets/js/embed.js | 9 +++++----
 assets/js/watch.js | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/assets/js/embed.js b/assets/js/embed.js
index 99d2fc53..9d0be0ea 100644
--- a/assets/js/embed.js
+++ b/assets/js/embed.js
@@ -31,6 +31,11 @@ function get_playlist(plid, retries) {
                     player.on('ended', function () {
                         var url = new URL('https://example.com/embed/' + xhr.response.nextVideo);
 
+                        url.searchParams.set('list', plid);
+                        if (!plid.startsWith('RD')) {
+                            url.searchParams.set('index', xhr.response.index);
+                        }
+
                         if (video_data.params.autoplay || video_data.params.continue_autoplay) {
                             url.searchParams.set('autoplay', '1');
                         }
@@ -47,10 +52,6 @@ function get_playlist(plid, retries) {
                             url.searchParams.set('local', video_data.params.local);
                         }
 
-                        url.searchParams.set('list', plid);
-                        if (!plid.startsWith('RD')) {
-                            url.searchParams.set('index', xhr.response.index);
-                        }
                         location.assign(url.pathname + url.search);
                     });
                 }
diff --git a/assets/js/watch.js b/assets/js/watch.js
index e9ad2ddc..05530f3d 100644
--- a/assets/js/watch.js
+++ b/assets/js/watch.js
@@ -154,6 +154,11 @@ function get_playlist(plid, retries) {
                     player.on('ended', function () {
                         var url = new URL('https://example.com/watch?v=' + xhr.response.nextVideo);
 
+                        url.searchParams.set('list', plid);
+                        if (!plid.startsWith('RD')) {
+                            url.searchParams.set('index', xhr.response.index);
+                        }
+
                         if (video_data.params.autoplay || video_data.params.continue_autoplay) {
                             url.searchParams.set('autoplay', '1');
                         }
@@ -170,10 +175,6 @@ function get_playlist(plid, retries) {
                             url.searchParams.set('local', video_data.params.local);
                         }
 
-                        url.searchParams.set('list', plid);
-                        if (!plid.startsWith('RD')) {
-                            url.searchParams.set('index', xhr.response.index);
-                        }
                         location.assign(url.pathname + url.search);
                     });
                 }