百度百科去广告,秒懂百科禁止自动播放

百度百科优化

  1. // ==UserScript==
  2. // @name 百度百科去广告,秒懂百科禁止自动播放
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.1
  5. // @description 百度百科优化
  6. // @author 1332019995@qq.com
  7. // @match https://baike.baidu.com/item/*
  8. // @run-at document-start
  9. // @icon none
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. function buildStyle(arr) {
  15. var ret = '<style>';
  16. arr.forEach(a => { ret += a + ' { display: none!important; }' });
  17. return ret + '</style>';
  18. }
  19.  
  20. const adsList = [".navbar-bg-top .appdownload", ".unionAd .union-content", ".after-content", ".header .topA", "#side-share", "#J-declare-wrap"];
  21. const baikeVideoId = "sl-player-el-video";
  22. const styleInsert = buildStyle(adsList);
  23.  
  24. (function() {
  25. 'use strict';
  26. (document.head || document.documentElement).insertAdjacentHTML('beforeend', styleInsert);
  27. function tryPausingVideo(videoEle) {
  28. videoEle.pause();
  29. !videoEle.paused && setTimeout(tryPausingVideo, 10, videoEle);
  30. }
  31. window.onload = function() {
  32. tryPausingVideo(document.getElementById(baikeVideoId));
  33. }
  34. })();

QingJ © 2025

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