我在网页上的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
}
})
}
})()
答案 0 :(得分:1)
安装勇敢的浏览器,然后转到此站点,以查看您的CSP策略允许或不允许的内容。 https://content-security-policy.com/browser-test/
关于dapp检测,该站点将进行更详细的介绍: https://www.howtogeek.com/449046/what-is-the-brave-browser-and-how-does-it-compare-to-chrome/
但是,简而言之……Brave使用BAT(基本注意令牌),并且已经安装了一个广告拦截程序(Brave Shields)。 BAT基于Etherium区块链,是他们在允许广告和获利的同时还尊重用户隐私的方式。