您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Close, mute or hide Twitch video ads automatically while watching a stream!
当前为
// ==UserScript== // @name Auto Close Twitch Ads // @namespace KiranMurmuTH // @description Close, mute or hide Twitch video ads automatically while watching a stream! // @version 1.3.81 // @author KiranMurmuTH // @match *://*.twitch.tv/* // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_registerMenuCommand // ==/UserScript== (function() { var _video = {interval: 250, duration: 5, skipped: true, hidden: false, muted: true, console: true, present: null, advert: null, player: null, dstyle: null, sheet: document.createElement('style'), scriptName: 'Auto Close Twitch Ads', volume: null, playerQuery: 'div.player-video video', styleSheet: '.player-ad-notice > p {display: none;}', unmuted: 'mute-button', dstyleQuery: 'div.js-ima-ads-container.ima-ads-container', presentQuery: 'div.persistent-player.tw-border-radius-none', volumeQuery: 'button.player-button.player-button--volume span', advertQuery: 'div.js-ima-ads-container.ima-ads-container video', setStore: function(_key, _val) { return GM_setValue(_key, _val);}, getStore: function(_key, _val) { return GM_getValue(_key, _val);}, delStore: function(_key) { return GM_deleteValue(_key); }}; _video.duration = _video.getStore('_video.duration', _video.duration); _video.skipped = _video.getStore('_video.skipped', _video.skipped); _video.hidden = _video.getStore('_video.hidden', _video.hidden); _video.muted = _video.getStore('_video.muted', _video.muted); function noticeAd() { _video.present = document.querySelector(_video.presentQuery); if (typeof _video.present !== 'undefined' && _video.present) { _video.volume = document.querySelector(_video.volumeQuery); _video.dstyle = document.querySelector(_video.dstyleQuery); _video.advert = document.querySelector(_video.advertQuery); _video.player = document.querySelector(_video.playerQuery); if (typeof _video.dstyle !== 'undefined' && _video.dstyle) { if (_video.hidden && !_video.dstyle.style.display) { _video.dstyle.style.display = 'none'; if (typeof _video.sheet !== 'undefined' && !_video.sheet.innerHTML) { _video.sheet.innerHTML = _video.styleSheet; document.body.appendChild(_video.sheet);} if (_video.console) { console.log(_video.scriptName + ': video ad hidden.');} }} if ((typeof _video.volume !== 'undefined' && _video.volume) && (typeof _video.advert !== 'undefined' && _video.advert) && (typeof _video.player !== 'undefined' && _video.player)) { if (_video.muted && !_video.advert.muted && _video.advert.volume) { _video.advert.muted = true; _video.advert.volume = 0; if (_video.player.muted && _video.volume.className === _video.unmuted) { _video.player.muted = false;} if (_video.console) { console.log(_video.scriptName + ': video ad muted.'); }} if (_video.skipped && _video.advert.duration && _video.advert.src) { if (_video.advert.currentTime !== _video.advert.duration && _video.advert.currentTime >= (_video.duration ? _video.duration + 1 : 0)) { _video.advert.currentTime = _video.advert.duration; if (_video.console) { console.log(_video.scriptName + ': video ad skipped.');}} }} }} setInterval(noticeAd, _video.interval); GM_registerMenuCommand(_video.scriptName + ': Set video ad duration.', function() { var _wait = parseInt(prompt('Current video ad duration is ' + _video.duration + ' sec. Enter new duration value, 0 means no ads.')); if (!isNaN(_wait)) { _video.duration = _wait; _video.setStore('_video.duration', _video.duration); }}); GM_registerMenuCommand(_video.scriptName + ': ' + (_video.skipped ? 'Disable' : 'Enable') + ' video ad skip.', function() { _video.setStore('_video.skipped', !_video.skipped); location.reload(); }); GM_registerMenuCommand(_video.scriptName + ': ' + (_video.hidden ? 'Disable' : 'Enable') + ' video ad hide.', function() { _video.setStore('_video.hidden', !_video.hidden); if (!_video.hidden) { _video.setStore('_video.muted', !_video.hidden);} location.reload(); }); GM_registerMenuCommand(_video.scriptName + ': ' + (_video.muted ? 'Disable' : 'Enable') + ' video ad mute.', function() { _video.setStore('_video.muted', !_video.muted); location.reload(); }); GM_registerMenuCommand(_video.scriptName + ': Restore default setting.', function() { _video.delStore('_video.duration'); _video.delStore('_video.skipped'); _video.delStore('_video.hidden'); _video.delStore('_video.muted'); location.reload(); }); })();