V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thefack
V2EX  ›  问与答

虎牙 PC 网页端是屏蔽了 MutationObserver 功能吗?

  •  
  •   thefack · 2022-02-10 08:41:57 +08:00 · 605 次点击
    这是一个创建于 808 天前的主题,其中的信息可能已经有所发展或是发生改变。

    下面这段代码我试过很多网站,是可以检测到网页改变的,但是对虎牙主播的直播页面完全无效,就算写成扩展也无效,这是怎么做到的?

      // Create callback function to execute when changes are observed
      let fun= function (records) {
        // 无论怎么增删元素,都不输出这句
        console.log("检测到改动", records)
      }
    
      // Create an observer instance linked to the callback function
      let observer = new MutationObserver(fun)
    
      // Start observing the target node for configured mutations(changes)
      observer.observe(document.body, {
        attributes: true,
        childList: true,
        subtree: true
      })
    
    BreadKiller
        1
    BreadKiller  
       2022-02-10 10:43:21 +08:00
    看了一下只是重写 console.log 这个方法而已
    thefack
        2
    thefack  
    OP
       2022-02-10 18:19:14 +08:00
    @BreadKiller 谢谢大哥啊,学到了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3348 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:17 · PVG 19:17 · LAX 04:17 · JFK 07:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.