A little trick to auto click buttons in Linkedin using Javascript and HTML
I usually play with the Chrome console dev tool when it comes to clicking buttons multiple times. This trick is fun for lazy people like me
For example, I have 50 contacts waiting to connect with me. In order to click all of these 50 buttons at the same time, I did the following steps:
- Open Chrome dev tool by Cmd+shift+I , inspect the class of these 50 buttons. Usually, the button would have the same class name pattern. If you can get the class name pattern, you could select all of them
2. Use this piece of code to select elements with the extracted class name and assign a variable to store them. In this case, I assign for the buttonList constant
const buttonList = document.getElementsByClassname(“button-class-name”)
3. After that, we would have an HTML node collection. So the next step is to loop this list and click every single item. However, you can’t use the forEach function for Javascript array because buttonList is a Node list, not an array. All you have to do is to convert it to an array using the below code:
Array.from(buttonList).forEach((button)=>{ button.click()})
Finally, I record the whole process in the below GIF. Enjoy your internet browsing experience ^^