killBDMusicBox_Ad

删除百度音乐盒广告脚本,禁止插播音频广告

目前為 2016-09-01 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           killBDMusicBox_Ad
// @namespace      killBDMusicBox_Ad.xinggsf
// @author	       xinggsf~gmail。com
// @description    删除百度音乐盒广告脚本,禁止插播音频广告
// @license        GPL version 3
// @include        http://play.baidu.com/*
// @version        2016.8.31
// @encoding       utf-8
// @run-at         document-start
// @grant          unsafeWindow
// ==/UserScript==

var r = /(?:^|\W|_)ad(?:$|\W|_)/;
/* 三种实现中1、3都无须定义@run-at、@grant
-function() {
	var e, k;
	function delAdScript(s) {
		e = document.querySelector('script[src$="' + s +'"]');
		console.log('del ', e);
		e && e.parentNode.removeChild(e);
	}
	for (k in _MD5_HASHMAP) {
		r.test(k) && delAdScript(_MD5_HASHMAP[k]);
	}
}(); */
if (unsafeWindow.top !== unsafeWindow.self) return;
function delAdScript(ev) {
	var e = ev.target;
	if ('SCRIPT' === e.tagName &&
		e.hasAttribute('data-requiremodule') &&
		r.test(e.getAttribute('data-requiremodule'))
	) ev.relatedNode.removeChild(e);
}
document.addEventListener('DOMNodeInserted', delAdScript, !1);

window.onload = function() {
/* 三种实现之三
	var c = document.querySelectorAll('script[data-requiremodule]');//[src^="//mu"]
	Array.prototype.forEach.call(c, function(e) {
		r.test(e.getAttribute('data-requiremodule')) &&
		e.parentNode.removeChild(e);
	}); */
    document.removeEventListener('DOMNodeInserted', delAdScript);
	unsafeWindow.showAd = !1;
	unsafeWindow.audioAd.disable();
	//unsafeWindow.audioAd = null;

	window.onload = null;
}