Skip to content

Commit

Permalink
Merge pull request #1 from pantyetta/speed-x16
Browse files Browse the repository at this point in the history
support ads play x16
  • Loading branch information
pantyetta authored Nov 28, 2023
2 parents 5bf849d + 43185a8 commit 526cbe3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
youtube広告を自動でスキップします.
機能は以上です.
- 15-30程度の広告のスキップボタンを自動で押します.
- スキップ不能の広告を16倍で再生します.

**広告自体のブロックはしません**

Expand Down
12 changes: 10 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down

0 comments on commit 526cbe3

Please sign in to comment.