MoonWalk Assistant

Убирает рекламу из онлайн плееров.

  1. // ==UserScript==
  2. // @name MoonWalk Assistant
  3. // @name:en MoonWalk Assistant
  4. // @namespace ANT0x1
  5. // @version 2.5.2
  6. // @date 2018-12-02
  7. // @description Убирает рекламу из онлайн плееров.
  8. // @description:en Removes ads from online players.
  9. // @author ANT0x1
  10. // @match http://*.abbanole.com/*/iframe*
  11. // @match http://*.mastarti.com/*/iframe*
  12. // @icon http://hdrezka.me/templates/hdrezka/images/favicon.ico
  13. // @supportURL http://clc.am/RemoveAds
  14. // @run-at document-end
  15. // @homepage http://clc.am/zWStKw
  16. // @grant none
  17. // @copyright 2018, ANT0x1
  18. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  19. // @namespace ANT0x1
  20. // ==/UserScript==
  21.  
  22. // ==OpenUserJS==
  23. // @author ANT0x1
  24. // ==/OpenUserJS==
  25.  
  26. (function () {
  27. 'use strict';
  28. setTimeout(removeAds, 2000);
  29. })();
  30.  
  31. var currentVideo = {
  32. position: 0,
  33. isFinished: false,
  34. volume: 100
  35. };
  36.  
  37. function removeAds() {
  38. if (typeof video_balancer !== 'undefined') {
  39. console.log('[Assistant] Removin Ads');
  40.  
  41. video_balancer.adv_loader.options.adb_vast.urls = [];
  42. video_balancer.adv_loader.options.vast.urls = [];
  43. video_balancer.adv_loader.options.reserve_vast.urls = [];
  44. }
  45.  
  46. console.log("[Assistant] Ads disabled.");
  47. playVideo();
  48. }
  49.  
  50. function playVideo() {
  51. setTimeout(function () {
  52. if (typeof player === 'undefined' || typeof player.api === 'undefined') {
  53. playVideo();
  54. return;
  55. }
  56.  
  57. console.log("[Assistant] Playing.");
  58.  
  59. setTimeout(function () {
  60. setTimeout(restoreFromStorage, 2000);
  61. player.api.setVolume(currentVideo.volume);
  62. autoSave();
  63. }, 2000);
  64. }, 2000);
  65. }
  66.  
  67. function autoSave() {
  68. var timeout = api.paused ? 20000 : 5000;
  69.  
  70. setTimeout(function () {
  71. savePosition();
  72.  
  73. if (!api.paused)
  74. saveToStorage();
  75.  
  76. if (!currentVideo.isFinished)
  77. autoSave();
  78.  
  79. }, timeout);
  80. }
  81.  
  82. function savePosition() {
  83. currentVideo.position = _mw_current_time;
  84. currentVideo.volume = api.volumeLevel;
  85. currentVideo.isFinished = api.finished;
  86. }
  87.  
  88. function restorePosition() {
  89.  
  90. if (currentVideo.position > 0) {
  91. player.api.seek(currentVideo.position);
  92. console.log("[Assistant] Position restored to " + currentVideo.position + ' sec.');
  93. }
  94. }
  95.  
  96. function saveToStorage() {
  97. var videos = JSON.parse(localStorage.getItem('videos'));
  98.  
  99. if (!videos)
  100. videos = {};
  101.  
  102. videos[video_balancer.options.video_token] = currentVideo;
  103. localStorage.setItem('videos', JSON.stringify(videos));
  104.  
  105. //console.log('[Assistant] Saved to storage');
  106. }
  107.  
  108. function restoreFromStorage() {
  109. var videos = JSON.parse(localStorage.getItem('videos'));
  110.  
  111. if (!videos) {
  112. videos = {};
  113. }
  114.  
  115. currentVideo = videos[video_balancer.options.video_token];
  116.  
  117. if (!currentVideo) {
  118. currentVideo = {
  119. position: 0,
  120. isFinished: false,
  121. volume: api.volumeLevel
  122. };
  123. }
  124.  
  125. console.log('[Assistant] Restored from storage');
  126.  
  127. if (!currentVideo.isFinished)
  128. restorePosition();
  129. else
  130. currentVideo.isFinished = false;
  131. }