Guest User

Disable Lenta.ru autoplay video

a guest
Aug 20th, 2018
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Disable Lenta.ru autoplay
  3. // @namespace    lenta.ru
  4. // @version      0.5
  5. // @description  Ставит на паузу видео и попутно удаляет рекламу на ленте.
  6. // @author       Anonymouse
  7. // @run-at       document-start
  8. // @include      https://lenta.ru/*
  9. // @include      https://lentaru.media.eagleplatform.com/index/player*
  10. // @match        https://lenta.ru/*
  11. // @match        https://lentaru.media.eagleplatform.com/index/player*
  12. // @grant        none
  13. // ==/UserScript==
  14.  
  15.  
  16. if(document.location.href.indexOf('lentaru.media.eagleplatform.com') !== -1){
  17.     if(document.location.href.indexOf('autoplay=0') === -1) document.location = document.location+"&autoplay=0"
  18. }else{
  19.     var StopTimer=0;
  20.     //Функция вызывается при создании на странице какого-либо элемента с помощью JavaScript-а.
  21.     var DetectAddNode = function (ev) {
  22.         if( (typeof(ev.target.innerHTML) == "string") && ((ev.target.innerHTML.indexOf('palacesquare.rambler.ru') !== -1)) ){
  23.             ev.target.parentNode.removeChild(ev.target);
  24.             StopTimer=0;
  25.         }
  26.     };
  27.     //Начинаем проверять, какие элементы добавляются на страницу динамически.
  28.     document.addEventListener("DOMNodeInserted", DetectAddNode, false);
  29.     //Запускаем таймер для отключения функции DOMNodeInserted
  30.     var timerStop = setInterval(function() {
  31.         if(StopTimer>=2){
  32.             clearInterval(timerStop);
  33.             document.removeEventListener("DOMNodeInserted", DetectAddNode, false);
  34.         }
  35.         StopTimer++;
  36.     }, 5000);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment