https://chromewebstore.google.com/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=ja
使用しないでね。と書いておく。
つかったことがないので、動くかどうかわかりません。と書いておく。
広告を見たい長さを調節できます。
```
// ==UserScript==
// @name YouTube Ad Auto-Skipper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatically clicks the skip ad button on YouTube
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function clickSkipButton() {
const skipButton = document.querySelector('.ytp-ad-skip-button');
if (skipButton) {
skipButton.click();
}
}
// 広告スキップボタンを探して1秒ごとにクリックを試みる
setInterval(clickSkipButton, 1000);
})();
```
// ==UserScript==
// @name YouTube Ad Skipper with Player Z-Index Fix
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Automatically skips YouTube ads, resumes playback, and fixes player z-index
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let skipAttempted = false;
function clickSkipButton() {
const skipButton = document.querySelector('.ytp-ad-skip-button') ||
document.querySelector('.ytp-skip-ad-button') ||
document.querySelector('button[class*="ytp-ad-skip-button"]') ||
document.querySelector('button[class*="ytp-skip-ad-button"]');
if (skipButton && !skipButton.disabled) {
console.log('Skip button found and clicked');
skipButton.click();
skipAttempted = true;
setTimeout(resumePlayback, 5000); // 5秒後に再生を再開
} else {
console.log('No skip button found or button is disabled');
}
}
function resumePlayback() {
if (skipAttempted) {
const video = document.querySelector('video');
if (video) {
console.log('Attempting to resume playback');
video.click();
video.play().catch(e => console.log('Failed to resume playback:', e));
document.querySelector('ytd-watch-flexy[player-unavailable] #player-container-outer.ytd-watch-flexy').style.visibility = 'visible';
bringPlayerToFront();
}
skipAttempted = false;
}
}
function bringPlayerToFront() {
const player = document.querySelector('.html5-video-player');
if (player) {
player.style.zIndex = '2147483647'; // 最大のz-index値
console.log('Player brought to front');
} else {
console.log('Player not found');
}
}
// 1秒ごとにチェック
setInterval(clickSkipButton, 1000);
observer.observe(document.body, { childList: true, subtree: true });
console.log('YouTube Ad Skipper with Player Z-Index Fix script is running');
})();
F12を押し、コンソールに以下を入力.
document.addEventListener('contextmenu',function(e){e.stopPropagation();},true);
document.getElementById('error-screen').style.display = 'none';
document.querySelector('ytd-watch-flexy[player-unavailable] #player-container-outer.ytd-watch-flexy').style.visibility = 'visible';
function checkPlayerState() {
const player = document.getElementById('movie_player');
const isPlaying = player.classList.contains('playing-mode');
if (!isPlaying) {
const playButton = player.querySelector('.ytp-play-button');
if (playButton) {
playButton.click();
}
}
}
setInterval(checkPlayerState, 1000); // 1秒ごとに状態をチェック