0

I wrote a tampermokey script that counts the i intervals and clicks the next video, but the odd thing is it works only if the alert is uncommented:

var i = 1;
setInterval(function () {
   document.getElementsByClassName('PlaylistVideo')[i].click();
      // alert("i is equal to: "+ i); 
      i ++      
}, 5000);
wOxxOm
  • 65,848
  • 11
  • 132
  • 136
User
  • 1
  • 5
  • it's a site you have to have an account for to use and I edited the class name to protect the site name. – User Oct 11 '15 at 19:25

2 Answers2

0

Javascript has a zero-based array, so you should start you i with 0;

var i = 0;
Franklin Satler
  • 320
  • 1
  • 7
  • when i did that at first it was playing the 1st video 2 times. It seem that the getElementsByClassName is counting 4 videos 1-4 – User Oct 11 '15 at 19:29
  • Can you tell me how to reset i back to nothing for the next run (when I move a diffrent page it stops working even though the URL is included in the @match section of the script) – User Oct 11 '15 at 19:37
0

for some reason did it not like the \ alert

User
  • 1
  • 5