youtube_ex

enhanced youtube

目前为 2016-02-04 提交的版本。查看 最新版本

// ==UserScript==
// @name        youtube_ex
// @description  enhanced youtube
// @namespace   http://userscripts.org/users/
// @include     https://www.youtube.com/*
// @version     0.1
// ==/UserScript==

//======  common ========
var obv_cfg={attributes: false, childList: true, characterData: false};

function observer_factory(callback, isforeach=true)
{
	var cb=isforeach ? function(mutations) {mutations.forEach(callback);} : callback;
	return new MutationObserver(cb);
}

function simpleRemoveElement(sel)
{
	var sep=sel.indexOf("##");
	var selector=sep>=0 ? sel.substr(sep+2) : sel;
	var node=document.querySelector(selector);
	if (node) node.parentNode.removeChild(node);
}

function killElementAttribute(attrname)
{
	var nodes=document.querySelectorAll('['+attrname+']');
	for (var i=0;i<nodes.length;i++)
	{
		nodes[i].removeAttribute(attrname);
	}
}

//======= end of common =========

function trackless()
{
	observer_factory(function (stub) {
		killElementAttribute("data-sessionlink");
		killElementAttribute("data-visibility-tracking");
	},false).observe(document.body, obv_cfg);
}


trackless();