Skip to content

Commit

Permalink
Fix missing watched times (Close #14)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
patrickmaher committed Mar 4, 2021
1 parent 4ded505 commit 98b2e14
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Enhanced RT.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1239,6 +1252,7 @@ function recentlyAdded()
watchTimeXMLHttp.setRequestHeader('Authorization', 'Bearer ' + accessToken);
watchTimeXMLHttp.send();
}
*/
}


Expand Down

0 comments on commit 98b2e14

Please sign in to comment.