Youtubuのあれ
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
* はじめに [#ycc15613]
Youtubeではなく、ここに書いてあるのはYoutubuという架空の...
このページは、どなたでも編集することが可能です
* chromeの拡張機能 [#b719ea6a]
https://chromewebstore.google.com/detail/tampermonkey/dhd...
* スニペット集 [#w3f99894]
https://roshi.tv/blog/20220718-tampermonkey-javascript-sn...
* 見やすくする参考スクリプト [#qcaa5575]
https://greasyfork.org/ja/scripts/by-site/youtube.com
* あれのコード [#naba10b9]
使用しないでね。と書いておく。
つかったことがないので、動くかどうかわかりません。と書い...
広告を見たい長さを調節。
```
// ==UserScript==
// @name YouTube Ad Auto-Skipper
// @namespace http://tampermonkey.net/
// @version 0.8
// @description Automatically clicks the skip ad button...
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function clickSkipButton() {
const skipButton = document.querySelector('.ytp-...
if (skipButton) {
skipButton.click();
}
}
// 広告スキップボタンを探して1秒ごとにクリックを試みる
setInterval(clickSkipButton, 1000);
})();
```
** ver0.6 [#x601e682]
// ==UserScript==
// @name YouTube Ad Skipper with Player Z-Index ...
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Automatically skips YouTube ads, resume...
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let skipAttempted = false;
function clickSkipButton() {
const skipButton = document.querySelector('.ytp-...
document.querySelector('.ytp-...
document.querySelector('butto...
document.querySelector('butto...
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 ...
}
}
function resumePlayback() {
if (skipAttempted) {
const video = document.querySelector('video');
if (video) {
console.log('Attempting to resume playba...
video.click();
video.play().catch(e => console.log('Fai...
document.querySelector('ytd-watch-flexy[...
bringPlayerToFront();
}
skipAttempted = false;
}
}
function bringPlayerToFront() {
const player = document.querySelector('.html5-vi...
if (player) {
player.style.zIndex = '2147483647'; // 最大...
console.log('Player brought to front');
} else {
console.log('Player not found');
}
}
// 1秒ごとにチェック
setInterval(clickSkipButton, 1000);
observer.observe(document.body, { childList: true, s...
console.log('YouTube Ad Skipper with Player Z-Index ...
})();
* ボタンID調査例:右クリック無効 [#l04b6205]
F12を押し、コンソールに以下を入力.
document.addEventListener('contextmenu',function(e){e.st...
* 例のあれを非表示に [#gce0b1f9]
document.getElementById('error-screen').style.display = ...
* あれを表示させる [#l70a7521]
document.querySelector('ytd-watch-flexy[player-unavailab...
* 再生停止を観測 [#dd1019d1]
function checkPlayerState() {
const player = document.getElementById('movie_player');
const isPlaying = player.classList.contains('playing-m...
if (!isPlaying) {
const playButton = player.querySelector('.ytp-play-b...
if (playButton) {
playButton.click();
}
}
}
setInterval(checkPlayerState, 1000); // 1秒ごとに状態を...
* 既存のfunctionをオーバーライド [#h1d109ab]
// ==UserScript==
// @name Website Code Override
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Overrides specific code on a website
// @match https://example.com/*
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
// 1. 既存の関数や変数の再定義
if (typeof unsafeWindow.existingFunction === 'functi...
unsafeWindow.existingFunction = function() {
console.log('This function has been overridd...
// 新しい実装をここに記述
};
}
// 2. スクリプトインジェクション
function injectScript(func) {
const script = document.createElement('script');
script.textContent = `(${func.toString()})();`;
document.body.appendChild(script);
document.body.removeChild(script);
}
injectScript(function() {
// このコンテキストはページのグローバルスコープ...
// 例: 既存の関数をオーバーライド
if (typeof window.anotherExistingFunction === 'f...
const original = window.anotherExistingFunct...
window.anotherExistingFunction = function() {
console.log('Function called with argume...
return original.apply(this, arguments);
};
}
// 例: 新しい関数や変数を定義
window.newFunction = function() {
console.log('This is a new function added to...
};
// 例: イベントリスナーの追加や変更
document.addEventListener('click', function(e) {
console.log('Document clicked at:', e.client...
});
});
console.log('Website Code Override script is running...
})();
** あれがでたら、リロード [#y0ee5910]
// ==UserScript==
// @name YouTube Error Screen Reloader
// @namespace http://tampermonkey.net/
// @version 1.0
// @description YouTube のエラー画面が表示された場合に...
// @author Your Name
// @match *://*.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// エラー画面の要素を取得する
const errorScreen = document.getElementById('error-scr...
// エラー画面が表示されたら自動でリロードするイベント...
errorScreen.addEventListener('DOMNodeInserted', functi...
// エラー画面が表示された場合に実行される
// 関数の説明: エラー画面が表示された場合、自動的に...
function reloadAutomatically() {
// リロードを実行する
location.reload();
}
// 1秒後に自動リロードを実行する
setTimeout(reloadAutomatically, 1000);
console.log('エラー画面表示確認。自動でリロードしま...
// エラー画面が非表示になったらイベントリスナーを削...
errorScreen.addEventListener('DOMNodeRemoved', funct...
// イベントの説明: エラー画面が削除された場合に実...
console.log('エラー画面が非表示になりました。');
});
});
})();
** ver0.8 [#u270e512]
// ==UserScript==
// @name Auto Skip YouTube Ads
// @name:vi Tự Động Bỏ Qua Quảng Cáo YouTube
// @name:zh-CN 自动跳过 YouTube 广告
// @name:zh-TW 自動跳過 YouTube 廣告
// @name:ja YouTube 広告を自動スキップ
// @name:ko YouTube 광고 자동 건너뛰기
// @name:es Saltar Automáticamente Anuncios D...
// @name:ru Автоматический Пропуск Рекламы На...
// @name:id Lewati Otomatis Iklan YouTube
// @name:hi YouTube विज्ञापन स्वचालित रूप से ...
// @namespace https://github.com/tientq64/users...
// @version 4.3.5
// @description Automatically skip YouTube ads in...
// @description:vi Tự động bỏ qua quảng cáo YouTube ...
// @description:zh-CN 自动立即跳过 YouTube 广告。删除广...
// @description:zh-TW 立即自動跳過 YouTube 廣告。刪除廣...
// @description:ja YouTube 広告を即座に自動的にスキ...
// @description:ko YouTube 광고를 즉시 자동으로 건너...
// @description:es Omita automáticamente los anuncio...
// @description:ru Автоматически пропускайте рекламу...
// @description:id Lewati iklan YouTube secara otoma...
// @description:hi YouTube विज्ञापनों को तुरंत स्वचा...
// @author tientq64
// @icon https://cdn-icons-png.flaticon.co...
// @match https://www.youtube.com
// @match https://www.youtube.com/*
// @grant none
// @license MIT
// @compatible firefox
// @compatible chrome
// @compatible opera
// @compatible safari
// @compatible edge
// @noframes
// @homepage https://github.com/tientq64/users...
// @downloadURL https://update.greasyfork.org/scripts/49...
// @updateURL https://update.greasyfork.org/scripts/4981...
// ==/UserScript==
function skipAd() {
video = document.querySelector('#movie_player video....
const adPlayer = document.querySelector('#movie_play...
if (adPlayer) {
const skipButton = document.querySelector(`
.ytp-skip-ad-button,
.ytp-ad-skip-button,
.ytp-ad-skip-button-modern
`)
if (skipButton) {
skipButton.click()
} else if (video) {
video.currentTime = 9999
}
}
const adBlockerWarningDialog = document.querySelecto...
if (adBlockerWarningDialog) {
adBlockerWarningDialog.remove()
}
const playButton = document.querySelector('button.yt...
if (playButton) {
playButton.addEventListener('click', allowPauseV...
}
fineScrubbing = document.querySelector('.ytp-fine-sc...
if (video) {
video.addEventListener('pause', handlePauseVideo)
video.addEventListener('mouseup', allowPauseVideo)
}
}
function allowPauseVideo() {
isAllowPauseVideo = true
window.clearTimeout(allowPauseVideoTimeoutId)
allowPauseVideoTimeoutId = window.setTimeout(disallo...
}
function disallowPauseVideo() {
isAllowPauseVideo = false
window.clearTimeout(allowPauseVideoTimeoutId)
}
function handlePauseVideo() {
if (isAllowPauseVideo) {
disallowPauseVideo()
return
}
if (fineScrubbing?.checkVisibility()) return
if (video) {
if (video.duration - video.currentTime < 0.1) re...
video.play()
}
}
function handleGlobalKeyDownKeyUp(event) {
if (document.activeElement?.matches('input, textarea...
if (event.type === 'keydown') {
if (event.code === 'KeyK') {
allowPauseVideo()
}
} else {
if (event.code === 'Space') {
allowPauseVideo()
}
}
}
let video = null
let fineScrubbing = null
let isAllowPauseVideo = false
let allowPauseVideoTimeoutId = 0
if (window.MutationObserver) {
const observer = new MutationObserver(skipAd)
observer.observe(document.body, {
attributes: true,
attributeFilter: ['class', 'src'],
childList: true,
subtree: true
})
} else {
window.setInterval(skipAd, 500)
}
skipAd()
window.addEventListener('keydown', handleGlobalKeyDownKe...
window.addEventListener('keyup', handleGlobalKeyDownKeyUp)
const style = document.createElement('style')
style.textContent = `
#player-ads,
#masthead-ad,
#panels:has(ytd-ads-engagement-panel-content-rendere...
ytd-ad-slot-renderer,
ytd-rich-item-renderer:has(.ytd-ad-slot-renderer),
ytd-reel-video-renderer:has(.ytd-ad-slot-renderer),
tp-yt-paper-dialog:has(#dismiss-button) {
display: none !important;
}`
document.head.appendChild(style)
** よくわからない [#pa5e12cb]
これもよくわかりません、ネットから拾ってきました。つかっ...
// ==UserScript==
// @name B9DM広告改善
// @namespace http://tampermonkey.net/
// @version 0.2
// @description B9DMの動画ページの広告を改善・緩和
// @author You
// @match https://b9dm.in/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 広告要素を削除
const commonAdSelectors = [
'.adsbygoogle', // Google AdSense
'[id^="div-gpt-ad"]', // Google Ad Manager
'.ad', // 一般的な広告クラス
'.advertisement', // 一般的な広告クラス
'.banner', // バナー広告
'.pop-up', // ポップアップ広告
'.interstitial', // インタースティシャル広告
];
// ページ固有の広告セレクタ (必要に応じて追加)
const pageSpecificAdSelectors = [
// 例: '#sidebar .widget' // サイドバーのウィジ...
];
const allAdSelectors = commonAdSelectors.concat(page...
// 広告要素を削除
function removeAds() {
for (const selector of allAdSelectors) {
const adElements = document.querySelectorAll...
for (const adElement of adElements) {
adElement.remove();
}
}
}
// 意図しないジャンプを防ぐ
function preventRedirects() {
const links = document.querySelectorAll('a');
for (const link of links) {
// target="_blank"属性を削除または_selfに変更
if (link.target === "_blank") {
link.target = "_self"; // 同じタブで開く
// link.removeAttribute("target"); // ta...
}
}
}
// ページ読み込み時に広告を削除
removeAds();
// DOMの変更を監視し、新しい広告が挿入されたら削除
const observer = new MutationObserver(removeAds);
observer.observe(document.body, { childList: true, s...
// 意図しないジャンプを防ぐ
preventRedirects();
})();
終了行:
* はじめに [#ycc15613]
Youtubeではなく、ここに書いてあるのはYoutubuという架空の...
このページは、どなたでも編集することが可能です
* chromeの拡張機能 [#b719ea6a]
https://chromewebstore.google.com/detail/tampermonkey/dhd...
* スニペット集 [#w3f99894]
https://roshi.tv/blog/20220718-tampermonkey-javascript-sn...
* 見やすくする参考スクリプト [#qcaa5575]
https://greasyfork.org/ja/scripts/by-site/youtube.com
* あれのコード [#naba10b9]
使用しないでね。と書いておく。
つかったことがないので、動くかどうかわかりません。と書い...
広告を見たい長さを調節。
```
// ==UserScript==
// @name YouTube Ad Auto-Skipper
// @namespace http://tampermonkey.net/
// @version 0.8
// @description Automatically clicks the skip ad button...
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function clickSkipButton() {
const skipButton = document.querySelector('.ytp-...
if (skipButton) {
skipButton.click();
}
}
// 広告スキップボタンを探して1秒ごとにクリックを試みる
setInterval(clickSkipButton, 1000);
})();
```
** ver0.6 [#x601e682]
// ==UserScript==
// @name YouTube Ad Skipper with Player Z-Index ...
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Automatically skips YouTube ads, resume...
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let skipAttempted = false;
function clickSkipButton() {
const skipButton = document.querySelector('.ytp-...
document.querySelector('.ytp-...
document.querySelector('butto...
document.querySelector('butto...
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 ...
}
}
function resumePlayback() {
if (skipAttempted) {
const video = document.querySelector('video');
if (video) {
console.log('Attempting to resume playba...
video.click();
video.play().catch(e => console.log('Fai...
document.querySelector('ytd-watch-flexy[...
bringPlayerToFront();
}
skipAttempted = false;
}
}
function bringPlayerToFront() {
const player = document.querySelector('.html5-vi...
if (player) {
player.style.zIndex = '2147483647'; // 最大...
console.log('Player brought to front');
} else {
console.log('Player not found');
}
}
// 1秒ごとにチェック
setInterval(clickSkipButton, 1000);
observer.observe(document.body, { childList: true, s...
console.log('YouTube Ad Skipper with Player Z-Index ...
})();
* ボタンID調査例:右クリック無効 [#l04b6205]
F12を押し、コンソールに以下を入力.
document.addEventListener('contextmenu',function(e){e.st...
* 例のあれを非表示に [#gce0b1f9]
document.getElementById('error-screen').style.display = ...
* あれを表示させる [#l70a7521]
document.querySelector('ytd-watch-flexy[player-unavailab...
* 再生停止を観測 [#dd1019d1]
function checkPlayerState() {
const player = document.getElementById('movie_player');
const isPlaying = player.classList.contains('playing-m...
if (!isPlaying) {
const playButton = player.querySelector('.ytp-play-b...
if (playButton) {
playButton.click();
}
}
}
setInterval(checkPlayerState, 1000); // 1秒ごとに状態を...
* 既存のfunctionをオーバーライド [#h1d109ab]
// ==UserScript==
// @name Website Code Override
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Overrides specific code on a website
// @match https://example.com/*
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
// 1. 既存の関数や変数の再定義
if (typeof unsafeWindow.existingFunction === 'functi...
unsafeWindow.existingFunction = function() {
console.log('This function has been overridd...
// 新しい実装をここに記述
};
}
// 2. スクリプトインジェクション
function injectScript(func) {
const script = document.createElement('script');
script.textContent = `(${func.toString()})();`;
document.body.appendChild(script);
document.body.removeChild(script);
}
injectScript(function() {
// このコンテキストはページのグローバルスコープ...
// 例: 既存の関数をオーバーライド
if (typeof window.anotherExistingFunction === 'f...
const original = window.anotherExistingFunct...
window.anotherExistingFunction = function() {
console.log('Function called with argume...
return original.apply(this, arguments);
};
}
// 例: 新しい関数や変数を定義
window.newFunction = function() {
console.log('This is a new function added to...
};
// 例: イベントリスナーの追加や変更
document.addEventListener('click', function(e) {
console.log('Document clicked at:', e.client...
});
});
console.log('Website Code Override script is running...
})();
** あれがでたら、リロード [#y0ee5910]
// ==UserScript==
// @name YouTube Error Screen Reloader
// @namespace http://tampermonkey.net/
// @version 1.0
// @description YouTube のエラー画面が表示された場合に...
// @author Your Name
// @match *://*.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// エラー画面の要素を取得する
const errorScreen = document.getElementById('error-scr...
// エラー画面が表示されたら自動でリロードするイベント...
errorScreen.addEventListener('DOMNodeInserted', functi...
// エラー画面が表示された場合に実行される
// 関数の説明: エラー画面が表示された場合、自動的に...
function reloadAutomatically() {
// リロードを実行する
location.reload();
}
// 1秒後に自動リロードを実行する
setTimeout(reloadAutomatically, 1000);
console.log('エラー画面表示確認。自動でリロードしま...
// エラー画面が非表示になったらイベントリスナーを削...
errorScreen.addEventListener('DOMNodeRemoved', funct...
// イベントの説明: エラー画面が削除された場合に実...
console.log('エラー画面が非表示になりました。');
});
});
})();
** ver0.8 [#u270e512]
// ==UserScript==
// @name Auto Skip YouTube Ads
// @name:vi Tự Động Bỏ Qua Quảng Cáo YouTube
// @name:zh-CN 自动跳过 YouTube 广告
// @name:zh-TW 自動跳過 YouTube 廣告
// @name:ja YouTube 広告を自動スキップ
// @name:ko YouTube 광고 자동 건너뛰기
// @name:es Saltar Automáticamente Anuncios D...
// @name:ru Автоматический Пропуск Рекламы На...
// @name:id Lewati Otomatis Iklan YouTube
// @name:hi YouTube विज्ञापन स्वचालित रूप से ...
// @namespace https://github.com/tientq64/users...
// @version 4.3.5
// @description Automatically skip YouTube ads in...
// @description:vi Tự động bỏ qua quảng cáo YouTube ...
// @description:zh-CN 自动立即跳过 YouTube 广告。删除广...
// @description:zh-TW 立即自動跳過 YouTube 廣告。刪除廣...
// @description:ja YouTube 広告を即座に自動的にスキ...
// @description:ko YouTube 광고를 즉시 자동으로 건너...
// @description:es Omita automáticamente los anuncio...
// @description:ru Автоматически пропускайте рекламу...
// @description:id Lewati iklan YouTube secara otoma...
// @description:hi YouTube विज्ञापनों को तुरंत स्वचा...
// @author tientq64
// @icon https://cdn-icons-png.flaticon.co...
// @match https://www.youtube.com
// @match https://www.youtube.com/*
// @grant none
// @license MIT
// @compatible firefox
// @compatible chrome
// @compatible opera
// @compatible safari
// @compatible edge
// @noframes
// @homepage https://github.com/tientq64/users...
// @downloadURL https://update.greasyfork.org/scripts/49...
// @updateURL https://update.greasyfork.org/scripts/4981...
// ==/UserScript==
function skipAd() {
video = document.querySelector('#movie_player video....
const adPlayer = document.querySelector('#movie_play...
if (adPlayer) {
const skipButton = document.querySelector(`
.ytp-skip-ad-button,
.ytp-ad-skip-button,
.ytp-ad-skip-button-modern
`)
if (skipButton) {
skipButton.click()
} else if (video) {
video.currentTime = 9999
}
}
const adBlockerWarningDialog = document.querySelecto...
if (adBlockerWarningDialog) {
adBlockerWarningDialog.remove()
}
const playButton = document.querySelector('button.yt...
if (playButton) {
playButton.addEventListener('click', allowPauseV...
}
fineScrubbing = document.querySelector('.ytp-fine-sc...
if (video) {
video.addEventListener('pause', handlePauseVideo)
video.addEventListener('mouseup', allowPauseVideo)
}
}
function allowPauseVideo() {
isAllowPauseVideo = true
window.clearTimeout(allowPauseVideoTimeoutId)
allowPauseVideoTimeoutId = window.setTimeout(disallo...
}
function disallowPauseVideo() {
isAllowPauseVideo = false
window.clearTimeout(allowPauseVideoTimeoutId)
}
function handlePauseVideo() {
if (isAllowPauseVideo) {
disallowPauseVideo()
return
}
if (fineScrubbing?.checkVisibility()) return
if (video) {
if (video.duration - video.currentTime < 0.1) re...
video.play()
}
}
function handleGlobalKeyDownKeyUp(event) {
if (document.activeElement?.matches('input, textarea...
if (event.type === 'keydown') {
if (event.code === 'KeyK') {
allowPauseVideo()
}
} else {
if (event.code === 'Space') {
allowPauseVideo()
}
}
}
let video = null
let fineScrubbing = null
let isAllowPauseVideo = false
let allowPauseVideoTimeoutId = 0
if (window.MutationObserver) {
const observer = new MutationObserver(skipAd)
observer.observe(document.body, {
attributes: true,
attributeFilter: ['class', 'src'],
childList: true,
subtree: true
})
} else {
window.setInterval(skipAd, 500)
}
skipAd()
window.addEventListener('keydown', handleGlobalKeyDownKe...
window.addEventListener('keyup', handleGlobalKeyDownKeyUp)
const style = document.createElement('style')
style.textContent = `
#player-ads,
#masthead-ad,
#panels:has(ytd-ads-engagement-panel-content-rendere...
ytd-ad-slot-renderer,
ytd-rich-item-renderer:has(.ytd-ad-slot-renderer),
ytd-reel-video-renderer:has(.ytd-ad-slot-renderer),
tp-yt-paper-dialog:has(#dismiss-button) {
display: none !important;
}`
document.head.appendChild(style)
** よくわからない [#pa5e12cb]
これもよくわかりません、ネットから拾ってきました。つかっ...
// ==UserScript==
// @name B9DM広告改善
// @namespace http://tampermonkey.net/
// @version 0.2
// @description B9DMの動画ページの広告を改善・緩和
// @author You
// @match https://b9dm.in/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 広告要素を削除
const commonAdSelectors = [
'.adsbygoogle', // Google AdSense
'[id^="div-gpt-ad"]', // Google Ad Manager
'.ad', // 一般的な広告クラス
'.advertisement', // 一般的な広告クラス
'.banner', // バナー広告
'.pop-up', // ポップアップ広告
'.interstitial', // インタースティシャル広告
];
// ページ固有の広告セレクタ (必要に応じて追加)
const pageSpecificAdSelectors = [
// 例: '#sidebar .widget' // サイドバーのウィジ...
];
const allAdSelectors = commonAdSelectors.concat(page...
// 広告要素を削除
function removeAds() {
for (const selector of allAdSelectors) {
const adElements = document.querySelectorAll...
for (const adElement of adElements) {
adElement.remove();
}
}
}
// 意図しないジャンプを防ぐ
function preventRedirects() {
const links = document.querySelectorAll('a');
for (const link of links) {
// target="_blank"属性を削除または_selfに変更
if (link.target === "_blank") {
link.target = "_self"; // 同じタブで開く
// link.removeAttribute("target"); // ta...
}
}
}
// ページ読み込み時に広告を削除
removeAds();
// DOMの変更を監視し、新しい広告が挿入されたら削除
const observer = new MutationObserver(removeAds);
observer.observe(document.body, { childList: true, s...
// 意図しないジャンプを防ぐ
preventRedirects();
})();
ページ名: