【问题标题】:Tag inserted by the browser Brave before the head tag浏览器插入的标签 Brave 在 head 标签之前
【发布时间】:2020-11-04 03:08:39
【问题描述】:

我在我的网页上的 head 标签之前发现了一个标签,由 Brave 浏览器插入。 如果我的内容 Content-Security-Policy 不允许运行没有有效随机数或完整性属性的脚本,我的问题将在我的页面上运行。 第二个问题,脚本要求禁用(disableDappDetectionInsertion)??? 第三,这个脚本是做什么的?该脚本具有“data-dapp-detection”属性。 它发生在窗口模糊一段时间后。 勇敢的控制台也没有错误。 Brave 版本 1.10.97 Chromium:83.0.4103.116(官方版本)(64 位)

(function() {
  let alreadyInsertedMetaTag = false

  function __insertDappDetected() {
    if (!alreadyInsertedMetaTag) {
      const meta = document.createElement('meta')
      meta.name = 'dapp-detected'
      document.head.appendChild(meta)
      alreadyInsertedMetaTag = true
    }
  }

  if (window.hasOwnProperty('web3')) {
    // Note a closure can't be used for this var because some sites like
    // www.wnyc.org do a second script execution via eval for some reason.
    window.__disableDappDetectionInsertion = true
    // Likely oldWeb3 is undefined and it has a property only because
    // we defined it. Some sites like wnyc.org are evaling all scripts
    // that exist again, so this is protection against multiple calls.
    if (window.web3 === undefined) {
      return
    }
    __insertDappDetected()
  } else {
    var oldWeb3 = window.web3
    Object.defineProperty(window, 'web3', {
      configurable: true,
      set: function (val) {
        if (!window.__disableDappDetectionInsertion)
          __insertDappDetected()
        oldWeb3 = val
      },
      get: function () {
        if (!window.__disableDappDetectionInsertion)
          __insertDappDetected()
        return oldWeb3
      }
    })
  }
})()

【问题讨论】:

  • 与您的问题无关,但要禁用此脚本的自动注入,请转到“钱包”下的 Brave 设置,并将“使用 Dapps 的以太坊提供商”设置为“无”

标签: javascript content-security-policy brave-browser


【解决方案1】:

安装勇敢的浏览器并访问此站点以查看您的 CSP 策略允许或不允许的内容。 https://content-security-policy.com/browser-test/

至于 dapp-detection,本网站将更详细地介绍: https://www.howtogeek.com/449046/what-is-the-brave-browser-and-how-does-it-compare-to-chrome/

但简而言之... Brave 使用 BAT(基本注意令牌)并附带已安装的广告拦截器(Brave Shields)。 BAT 基于以太坊区块链,是他们允许广告和货币化同时尊重用户隐私的方式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多