From 43185a808ae7ab59c6ca2f4aa7e90006538f88a3 Mon Sep 17 00:00:00 2001 From: pantyetta Date: Wed, 29 Nov 2023 00:36:03 +0900 Subject: [PATCH] support ads play x16 --- README.md | 1 + background.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c1016bd..42e21ca 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ youtube広告を自動でスキップします. 機能は以上です. - 15-30程度の広告のスキップボタンを自動で押します. +- スキップ不能の広告を16倍で再生します. **広告自体のブロックはしません** diff --git a/background.js b/background.js index 0e18229..39a2dc3 100644 --- a/background.js +++ b/background.js @@ -10,18 +10,26 @@ const skipAds = (tabId) => { }; const $player = document.getElementById('movie_player'); + const video = document.querySelector('video'); + const playerObserver = new MutationObserver(() => { const $skip_container = document.getElementsByClassName("video-ads ytp-ad-module")[0] || null; - if($skip_container == null) return; + if(!$skip_container.children.length) { + video.playbackRate = 1; + return; + } + + video.playbackRate = 16; const observer = new MutationObserver(() => { const $skip_button = document.getElementsByClassName('ytp-ad-skip-button-modern ytp-button')[0] || null; if($skip_button == null) return; $skip_button.click(); + + observer.disconnect(); }); observer.observe($skip_container, config); - playerObserver.disconnect(); }); playerObserver.observe($player, config); },