我在我的网页上的 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
}
})
}
})()