Skip to content

Instantly share code, notes, and snippets.

@AndrewJHart
Last active August 20, 2023 16:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save AndrewJHart/556cea3362101c1292c534e000f01bbb to your computer and use it in GitHub Desktop.
Save AndrewJHart/556cea3362101c1292c534e000f01bbb to your computer and use it in GitHub Desktop.
Netflix Delete/Remove/Cleanup Your List: Simple Script to drop in browser to tidy up your queue/list of movies
/**
* You can copy and paste this into your browser console and it works as of 1/1/2021 - its not pretty.
*/
// replace "user-id" with your actual user id e.g. "123455" & same for auth url
const userId = 'my-user-id-goes-here';
const authUrl = 'auth-url-goes-here';
// first gather up all the DOM nodes in the list that have anchors w/ the title id to delete
const nodes = document.querySelectorAll('.rowList .title > a');
// This should create a nice array of all the movie id's by pulling the id from the href
let movies = Array.prototype.map.call(nodes, title => title.getAttribute('href').split('/', 3)[2]);
// to get this I just removed one movie from the list page, right clicked on the request and
// chose to copy the request using fetch (definitely better ways to do this)
movies.forEach(title => {
fetch(`https://www.netflix.com/api/shakti/${userId}/playlistop`, {
"headers": {
"accept": "application/json, text/javascript, */*",
"accept-language": "en-US,en;q=0.9,la;q=0.8",
"content-type": "application/json",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-netflix.browsername": "Chrome",
},
"referrer": "https://www.netflix.com/browse/my-list",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": `{\"operation\":\"remove\",\"videoId\":${title},\"authURL\":\"${authUrl}"}`,
"method": "POST",
"mode": "cors",
"credentials": "include"
});
});

Delete all (or a subset) of movies from your Netflix list or queue easily

Development

if you are not a developer, then skip this and go to the next section.

Devs, I wrote this for some non-technical people that really wanted to empty that list quickly w/o having to click on the X icon 400 times. Keep that in mind when you read this. Please feel free to turn this into a little node api wrapper that does some nice stuff, I would if I had the time :)

How to run the code

There is an attached Javascript file for this gist. You can scroll down and view it, look through it, and the comments should answer your questions.

To run the script all you need to do is copy and paste the code into a console debugger in the browser. For example, in the chrome browser simply right click and select "inspect element". This will open a debug tool on the bottom or the right side of the browser. There will be a few tabs, e.g. Elements, Console, Network, Resources etc.. Choose the console tab. Then ensure you've edited the code below so that the userId and authUrl variables actually contain the correct data (There are instructions on how to do this below). Then copy and paste the entire script into your console and hit enter to run it. Important You will need to make one request first to get your user id and auth url, as mentioned above. I've laid out steps on how to do that if you're not familiar with web development, http request/response cycle, or javascript.

Steps to retreive your user-id and auth-url so that you can run the code

Go to Netflix and change your list to be manually sortable first. You can hold cmd and click on this link Netflix.com or you can just right click on the link and select open in new tab. Once here, change the option to manual sorting so that Netflix no longer auto-sorts your list into oblivion - making it impossible to find something you added to your list the day before. After saving your change, you will need to navigate to the "My List" page in your browser.

Next you will need 2 things to proceed. -[x] Your user id - which will be in the api URL -[x] your auth URL code - an extra security measure

To get these 2 items, refer back to the inspector window in your browser and select the tab Network In the network tab, the next row down has a red record button and a clear all button. Click the clear all button to wipe out all the existing requests that will make it harder to find your information.

Now to get the 2 items, use the site to remove an item from the list by:

  • clicking on the X by any title you want to remove from your list on the website. Afterwards, look at the network list in the inspector network tab and you will see your request popup at the bottom of the list. It should be named someything like playlistop.
  • Click on that request and the details will pop up in the network tab.
  • Your userId will be listed beside the Request URL (It should be the first thing you see at the top of the request). Your user id will be in the url after api and before the end: /api/shakta/<123-user-id>/playlistop Copy your user id and paste it somewhere temporarily.
  • The authUrl will be at the very bottom of the network details in the section titled Request Payload. Click on the request payload and you will see 3 or 4 keys with values e.g. operation: remove .. find the key that says authUrl, select the value and copy it. Now paste it somewhere temporarily.

Executing the script with the proper user id and auth url. (do not share these values)

First, edit the javascript code below and paste your user id in place of the variable userId. Replace the text my-user-id-goes-here with the actual value e.g. If you're user if was 123456 then it would look like

const userId = '123456';

Do the exact same for the auth url.

Finally, copy the entire contents of the script below, after you've updated it, and paste it into your console. Then hit enter. It should delete everything in your list and allow you to easily start over.

You can find me at

Twitter @andruwhart gmail andruwhart@gmail.com

@amtsh
Copy link

amtsh commented Jan 10, 2023

Thanks for writing this script.

Tried to run this script (as of 10th Jan 2023) , and had to do some changes to the script to get it running successfully.

Change 1:

const nodes = document.querySelectorAll('.gallery .title-card-container a');

Change 2:

let movies = Array.prototype.map.call(nodes, title => title.getAttribute('href').split('/', 3)[2].split('?')[0]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment