Improve ad security, add CMP changes (#2399)

This commit is contained in:
Geometrically
2024-09-13 20:33:51 -07:00
committed by GitHub
parent 3d619e6a98
commit 95cd48571e
16 changed files with 220 additions and 169 deletions

View File

@@ -1,6 +1,8 @@
if (!window.modrinthClickListener) {
window.modrinthClickListener = true
document.addEventListener('click', function (e) {
document.addEventListener(
'click',
function (e) {
window.top.postMessage({ modrinthAdClick: true }, 'https://modrinth.com')
let target = e.target
while (target != null) {
if (target.matches('a')) {
@@ -12,8 +14,9 @@ if (!window.modrinthClickListener) {
}
target = target.parentElement
}
})
}
},
true,
)
window.open = (url, target, features) => {
window.top.postMessage({ modrinthOpenUrl: url }, 'https://modrinth.com')