vendredi 4 décembre 2015

JavaScript: How to click a thumbnail as soon as a new video is uploaded on a page?

Currently, there are a total of 50 video thumbnails lined up in several rows on a certain page. And once a new video is uploaded, its thumbnail will be added to the extreme left in the top row.

What I would like to do is to KEEP refreshing the page as FAST as possible UNTIL a new video is uploaded. And once a new video is uploaded, I then want to stop refreshing and click its thumbnail as soon as it appears on the page.

And once the thumbnail is clicked, I want to go on to click the “Add this video to the Watch Later list” button on the next page.


How should I go about writing this program in JavaScript? I’m new to JavaScript, and below is my attempt. Thank you very much.


1) We suppose that the thumbnail/image URL of the video currently at the top left is “https:xxxxx”. At the moment, this is the most recently added video, and its thumbnail is designated as the 1st image on the page, since it is located at the top left.

2) As long as this “https:xxxxx” thumbnail is located at the top left, I would like the page to keep refreshing as fast as possible without clicking the thumbnail. After all, I have already watched this specific video, and I do not need to click this one.

3) And then, once a new video is uploaded at the top left, I want to stop refreshing the page and click its thumbnail. (Now, the “https:xxxxx” thumbnail has been moved to the second left in the top row, because this video is no longer the most recently added one.)

4) After clicking the thumbnail, I want to go on to click the “Add this video to the Watch Later list” button on the next page.

5) Once this button is clicked, I want to repeat this whole process endlessly. I mean, as long as the first thumbnail located at the top left on the page is not the “https:xxxxx” one, I want to repeat the process of clicking the currently first thumbnail at the top left and then going on to click the “Add this video to the Watch Later list” button on the next page.

6) I’m assuming that this program involves using “if/else”, “loop”, and “setInterval” etc.

Aucun commentaire:

Enregistrer un commentaire