YouTube - Mute Ads

Automatically mutes VideoAds

目前為 2015-10-25 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name		YouTube - Mute Ads
// @name:de		YouTube - Mute Ads
// @versio		1.0.2
// @descriptio		Automatically mutes VideoAds
// @description:de	Schaltet Werbung auf YouTube automatisch stumm
// @autor		VVind0wM4ker
// @namespace		https://github.com/VVind0wM4ker/Userscripts
// @license		MIT License
// @gran		none
// @includ		http*://*.youtube.com/watch*
// @version 0.0.1.20151025110620
// @description Automatically mutes VideoAds
// ==/UserScript==


var adPlaying = 0;
var interval = 500
var vid = document.getElementsByClassName("video-stream html5-main-video")[0];

var timer, adTimeout;


vid.onplay = function() {startTimer();};
vid.onpause = function() {pauseTimer();};
    
	
	
var muteAds = function () {
    
    //console.log("check for Ads")					//for testing
    
    if (document.getElementsByClassName("ad-showing").length > 0) {
        
        adPlaying = 1;
        vid.mute();
    }
    else {
        
        if (adPlaying == 1) {
            
            adPlaying = 0;
            vid.unMute();
        }
    }
};



function pauseTimer () {
    
    clearInterval(timer);
    clearTimeout(adTimeout);
}

function startTimer () {
    
    clearInterval(timer);
    clearTimeout(adTimeout);
    timer = setInterval(muteAds, interval);
}