Automate the removal of likes in TikTok
Tags: javascript, automate, tiktok, tutorial
Published: 2022-10-16 16:33:46



If you have ever tried to **delete your likes on TikTok** you would have realized that there are too many videos, then it becomes more tedious and time consuming to scroll and delete likes manually.

## Remove likes with a JavaScript code

The idea is simple, place the **like button** and the **arrow button** to scroll to the next video, then make a loop to intersperse the clicks of the like button and then the scroll button.

## Writing the code

For this case we will use an anonymous function that receives two parameters, one is the waiting time to go to the next video and the second is a number that will indicate how many videos the like will be removed, by default this is -1 which is equal to infinity.

The code would look like this:

```js
((timeout, limit = -1) => {
    const likeButton = document.querySelector('span[data-e2e="browse-like-icon"]').parentElement
    const scrollButton = document.querySelector('button[data-e2e="arrow-right"]')
    if (likeButton && scrollButton) {
        let i = 1, interval = setInterval(() => {
            likeButton.click()
            setTimeout(() => scrollButton.click(), 300)
            if (i++ === limit) clearInterval(interval)
        }, timeout * 1000)
    }
})(1) // parameters are passed here, which are the timeout and the likes limit, which by default is infinite.
``` 

## Executing the code

> You will need to have a computer or laptop nearby, as it is necessary to use the browser console to run the script.

To remove multiple likes on **TikTok** quickly and automatically follow the steps below:

1. First open tiktok.com and log in.
2. Then open your profile page and go to the "Liked" tab.
![Liked preview tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ft1ni1n967ooq9823qx8.png)
3. Open the developer console with "Ctrl +Shift +J" or by right clicking and selecting "inspect" or by pressing "F12". (Remember to go to the "console" tab).
![browser console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2adpwvut2w8cjmc5o3a4.png)
4. Copy and paste the code into the console and press enter.
	```js
	((timeout, limit = -1) => {
	    const likeButton = document.querySelector('span[data-e2e="browse-like-icon"]').parentElement
	    const scrollButton = document.querySelector('button[data-e2e="arrow-right"]')
	    if (likeButton && scrollButton) {
	        let i = 1, interval = setInterval(() => {
	            likeButton.click()
	            setTimeout(() => scrollButton.click(), 300)
	            if (i++ === limit) clearInterval(interval)
	        }, timeout * 1000)
	    }
	})(1) // -> (timeout in seconds, limit)
	```
	Example:
	![Example console text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vieruckml0qtyhk14g2q.png)
5. Done 🥳, now you just have to wait for the likes to be removed without doing anything.

## Conclusion

This code works as of today and maybe in a next update of the TikTok web application it will break, but you can leave it in the comments if that happens, I will try to update this article.

Although if you have knowledge you can change and practice how to get the element of both buttons from the html, if you fix that then everything will work perfect.

> And remember that the timeout cannot be less than one second. 👀