killBDMusicBox_Ad

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

目前为 2016-09-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name killBDMusicBox_Ad
  3. // @namespace killBDMusicBox_Ad.xinggsf
  4. // @author xinggsf
  5. // @description 删除百度音乐盒广告脚本,禁止插播音频广告
  6. // downloadUrl https://raw.githubusercontent.com/xinggsf/gm/master/killBDMusicBox_Ad.user.js
  7. // @include http://play.baidu.com/*
  8. // @version 2016.9.26
  9. // @encoding utf-8
  10. // @run-at document-start
  11. // @grant unsafeWindow
  12. // ==/UserScript==
  13. "use strict";
  14. if (unsafeWindow.top === unsafeWindow.self) {
  15. let r = /(?:^|\W|_)ad(?:$|\W|_)/,
  16. delAdScript = function(e) {
  17. if ('SCRIPT' === e.tagName &&
  18. e.hasAttribute('data-requiremodule') &&
  19. r.test(e.getAttribute('data-requiremodule'))
  20. ) e.parentNode.removeChild(e);
  21. };
  22.  
  23. window.onload = function() {
  24. //mo.disconnect();
  25. unsafeWindow.showAd = !1;
  26. unsafeWindow.audioAd.disable();
  27. //unsafeWindow.audioAd = null;
  28. window.onload = null;
  29. };
  30.  
  31. let mo = new MutationObserver(function(rs) {
  32. for (let col of rs)
  33. for (let e of col.addedNodes)
  34. delAdScript(e);
  35. });
  36. mo.observe(document.head, {childList: true});
  37. }