Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. function isJQueryLoaded(){
  2. if (window.jQuery) {
  3. //jQuery is loaded
  4. alert("jQuery sucessfully loaded!");
  5. return true;
  6. } else {
  7. //jQuery is not loaded
  8. alert("jQuery doesn't work!");
  9. return false;
  10. }
  11. }
  12.  
  13. //Playback counter.
  14. var counter = 0;
  15. var observer;
  16.  
  17. function lel(){
  18.  
  19. //isJQueryLoaded();
  20.  
  21. //Start video if it already exists.
  22. let x = document.getElementsByClassName('state-paused');
  23. if(x[0] !== undefined){
  24. x[0].click();
  25. }
  26.  
  27. //Run observer on site body.
  28. var bodyNode = document.body;
  29.  
  30. // Create an observer instance
  31. observer = new MutationObserver(function (mutations) {
  32. mutations.every(function (mutation) {
  33. //console.log(mutation);
  34.  
  35. var target = mutation.target; // Changed DOM Element.
  36.  
  37. //If changed target contains state-paused and play-pause class (video only) , click play button.
  38. if(target.classList.contains('state-paused') && target.classList.contains('play-pause'))
  39. {
  40. counter++;
  41. console.log("Video Restarted " + counter + " times.");
  42. target.click();
  43. return false; //Cancel .every iteration.
  44. }
  45. else if(target.classList.contains('activity-button')){
  46. console.log(target);
  47. }
  48. });
  49. });
  50.  
  51. // Configuration of the observer:
  52. var config = {
  53. attributes: true,
  54. characterData: true,
  55. childList: true,
  56. subtree: true,
  57. attributeOldValue: true,
  58. characterDataOldValue: true,
  59. attributeFilter: ['class']
  60. };
  61.  
  62. // Pass in the target node, as well as the observer options
  63. observer.observe(bodyNode, config);
  64. }
  65.  
  66. lel();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement