Youtube Annotation Destroyer

If you want those damn annotations to go away at the start of every video, this is the right script for you!

当前为 2015-07-02 提交的版本,查看 最新版本

// ==UserScript==
// @name         Youtube Annotation Destroyer
// @namespace    http://userscripts.org/users/zackton
// @description  If you want those damn annotations to go away at the start of every video, this is the right script for you!
// @grant        GM_log
// @include	 http://www.youtube.com/watch*
// @include	 https://www.youtube.com/watch*
// @include	 http://www.youtube.com/user/*
// @include	 https://www.youtube.com/user/*
// @version      1.4
// ==/UserScript==

// ensure proper Youtube URL on normal watch pages
if ( location.href.search( "watch#!" ) != -1 ) {
	var url = location.href.split( "watch#!" );
	url = url[0] + "watch?" + url[1];
	window.open( url, "_self" );
}
	
function fetchPlayer() {
	if (window.top.document.getElementById('movie_player')) var player = window.top.document.getElementById('movie_player');
	else if (window.top.document.getElementById('movie_player-flash')) var player = window.top.document.getElementById('movie_player-flash');
	else if (window.top.document.getElementById('html5-main-video')) var player = window.top.document.getElementById('html5-main-video');
	
	var	myPlayer = player.cloneNode( true ),
		flashvars = myPlayer.getAttribute( "flashvars" );
	
	return [myPlayer, player, flashvars];
}	

// for playerDetails
    var playerDetails = fetchPlayer();
    var flashvars = playerDetails[1];

	function setFlashvar( field, newVal ) 
	{
		var delimited = "&" + field;
		if ( flashvars.indexOf( delimited ) == -1 ) {
			// field not found, so append it
			flashvars += delimited + "=" + newVal;
		}
		else {
			// modify existing field
			var tmp = flashvars.split( delimited );
			var tmp2 = tmp[1].indexOf( "&" );
			if ( tmp2 != -1 ) {
				flashvars = tmp[0] + delimited + "=" + newVal + tmp[1].substr( tmp2 );
			}
			else {
				flashvars = tmp[0] + delimited + "=" + newVal;
			}
		}
	}
	
	//indexOf is faster than Regex in one off use
	var start = flashvars.search("fmt_list=");
	var end = flashvars.indexOf("&", start);
	var len = ((end != -1)?end:flashVars.length) - start;
	var fmt_list = flashvars.substr(start, len);
	
	setFlashvar( "enablejsapi", "1" );
	setFlashvar( "iv_load_policy", "3" );

    myPlayer = playerDetails[0];
	myPlayer.setAttribute( "flashvars", flashvars );
	player = playerDetails[1];
	player.parentNode.replaceChild( myPlayer, player );
// end for playerDetails

Element.prototype.remove = function() {
    this.parentElement.removeChild(this);
};
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
    for(var i = 0, len = this.length; i < len; i++) {
        if(this[i] && this[i].parentElement) {
            this[i].parentElement.removeChild(this[i]);
        }
    }
};

document.getElementsByClassName('ytp-player-content ytp-iv-player-content').remove();
document.getElementsByClassName('video-annotations iv-module')[0].style.display = "none";

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址