From 98b2e1466f69704b619d2bd6330e22ba7ede6405 Mon Sep 17 00:00:00 2001 From: Patrick Maher Date: Thu, 4 Mar 2021 15:41:37 -0800 Subject: [PATCH] Fix missing watched times (Close #14) RT Engineering has moved the rt_access_token from a cookie into the local storage. The access token is needed to retrieve the users watch times. The access token is now being retrieved from local storage. --- Enhanced RT.user.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Enhanced RT.user.js b/Enhanced RT.user.js index 20ddd10..f60eb0b 100644 --- a/Enhanced RT.user.js +++ b/Enhanced RT.user.js @@ -1228,6 +1228,19 @@ function recentlyAdded() function getWatchTimes(watchTimeXMLHttp, episodeBatch) { // Only get watch times if access token exists + if(localStorage.getItem("rt_access_token") != null) + { + // Retrieve rt_access_token from local storage + var accessToken = localStorage.getItem("rt_access_token"); + + // Request watch times for current episode batch + watchTimeXMLHttp.open("GET", "https://wtcg.roosterteeth.com/api/v1/my/played_positions/mget/" + episodeBatch, true); + watchTimeXMLHttp.setRequestHeader('Authorization', 'Bearer ' + accessToken); + watchTimeXMLHttp.send(); + } + + // Old code used to retrieve rt_access_token when it was stored in a cookie. + /* if(document.cookie.indexOf("rt_access_token=") != -1) { // Retrieve rt_access_token from document.cookie @@ -1239,6 +1252,7 @@ function recentlyAdded() watchTimeXMLHttp.setRequestHeader('Authorization', 'Bearer ' + accessToken); watchTimeXMLHttp.send(); } + */ }