0

I have a tampermonkey script that runs on a video play list. It should run on each playlist I click on, but it only runs on the first playlist and I have to close chrome and repopen it to get it to work on a new playlist.

var playlistmax = document.querySelectorAll('.PlaylistVideo').length;
var i = 1;

setInterval( function () { 
  document.getElementsByClassName('PlaylistVideo')[i].click();
  alert ("I is : " + i);
  i++;             
}, 42000);

On the first play list the alert popup and tells me I (what video it's on). But after the first playlist I get no alerts.

Thanks for any help

Sagi
  • 578
  • 1
  • 4
  • 13
User
  • 1
  • 5
  • I've noticed that if I let it just run after the playlist (5 videos total) is done I get these alerts for I in this order: 1 2 3 4 5 1 1 1 6 2 2 2 7 3 3 3 8 ... and so on. – User Oct 12 '15 at 05:36
  • The script is inserted in all `iframe` elements. Use [`@noframes` meta key](https://tampermonkey.net/documentation.php#_noframes). – wOxxOm Oct 12 '15 at 12:17
  • @wOxxOm adding the '@noframes' to the script disabled the script and it did nothing at all. – User Oct 12 '15 at 20:48
  • Well, your question doesn't provide a complete picture so, unless you make it more specific, all we can do is shoot in the dark. Maybe the playlist is in the iframe. Maybe the page/frame is reloaded by the page script. Maybe it even clears the timers it didn't set. Or something else. – wOxxOm Oct 12 '15 at 20:53
  • @wOxxOm . There are Iframes on the page, but the video playlist is not in one . I first set works fine so I know it's something the the var I the alerts tell me it's reseting but also that it keeps counting (see above). I was thinking that maye I need to make it a globel var but I don't know if that would do it and if so how to do it and reset it when needed. – User Oct 12 '15 at 22:55

1 Answers1

0

the tampermonkey script is reseting on page load. that's why i is always 1

User
  • 1
  • 5