您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Close, mute or hide Twitch ads automatically while watching a stream!
当前为
// ==UserScript== // @name Auto Close Twitch Ads // @namespace KiranMurmuTH // @description Close, mute or hide Twitch ads automatically while watching a stream! // @version 1.2.50 // @author KiranMurmuTH // @match *://*.twitch.tv/* // @grant none // ==/UserScript== (function() { var _video = {'interval': 1000, 'duration': 5, //set video ads close delay, '0' means no delay. default is '5' sec. 'skipped': true, //set 'true' for closing video ads, 'false' for not. default is 'true'. 'hidden': false, //set 'true' for mute, hide video and stream chat ads, 'false' for not. default is 'false'. 'muted': true, //set 'true' for muting video ads, 'false' for not. default is 'true'. 'console': false, //set 'true' for console logs. default is 'true'. 'true': true, 'false': false, 'present': null, 'advert': null, 'player': null, 'notice': null, 'dstyle': null, 'sheet': null, 'comad': null, 'empty': '', 'none': 'none', 'block': 'block', 'styleSheet': '.player-ad-notice > p {display: none;}', 'comadQuery': 'div.companion-ad', 'presentQuery': 'div.persistent-player.tw-border-radius-none', 'playerQuery': 'div.player-video video', 'noticeQuery': 'div.player-ad-notice', 'advertQuery': 'div.js-ima-ads-container.ima-ads-container video', 'dstyleQuery': 'div.js-ima-ads-container.ima-ads-container' }; function noticeAd() { // check if watching stream _video.present = document.querySelector(_video.presentQuery); if (typeof _video.present !== 'undefined' && _video.present) { // custom style sheet for hiding ads _video.dstyle = document.querySelector(_video.dstyleQuery); if (typeof _video.dstyle !== 'undefined' && _video.dstyle) { if (_video.hidden && _video.dstyle.style.display !== _video.none) { _video.dstyle.style.display = _video.none; if (typeof _video.sheet === 'undefined' || !_video.sheet) { _video.sheet = document.createElement('style'); _video.sheet.innerHTML = _video.styleSheet; document.body.appendChild(_video.sheet); } } } // stream chat companion ads hide _video.comad = document.querySelector(_video.comadQuery); if (typeof _video.comad !== 'undefined' && _video.comad) { if (_video.hidden && _video.comad.style.display !== _video.none) { _video.comad.style.display = _video.none; if (_video.console) { console.log('companion Ad found and hidden'); } } } // check if video ads available _video.notice = document.querySelector(_video.noticeQuery); if (typeof _video.notice !== 'undefined' && _video.notice) { _video.player = document.querySelector(_video.playerQuery); _video.advert = document.querySelector(_video.advertQuery); if ((typeof _video.player !== 'undefined' && _video.player) && (typeof _video.advert !== 'undefined' && _video.advert)) { // video ads mute if (_video.muted && !_video.advert.muted) { _video.advert.muted = _video.true; _video.player.muted = _video.false; if (_video.console) { console.log('video Ad found and muted'); } } // video ads hide and mute if (_video.hidden && _video.advert.style.display !== _video.none) { _video.notice.style.display = _video.none; _video.advert.style.display = _video.none; if (!_video.muted) { _video.advert.muted = _video.true; _video.player.muted = _video.false; } if (_video.console) { console.log('video Ad found and hidden'); } } // video ads close if (_video.skipped) { if (_video.advert.currentTime >= _video.duration) { _video.advert.src = _video.empty; if (_video.console) { console.log('video Ad found and skipped'); } } } } } } } // keep script running setInterval(noticeAd, _video.interval); })();