2024-09-13 20:33:51 -07:00
|
|
|
document.addEventListener(
|
|
|
|
|
'click',
|
|
|
|
|
function (e) {
|
|
|
|
|
window.top.postMessage({ modrinthAdClick: true }, 'https://modrinth.com')
|
|
|
|
|
|
2024-08-30 10:42:58 -07:00
|
|
|
let target = e.target
|
|
|
|
|
while (target != null) {
|
|
|
|
|
if (target.matches('a')) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
if (target.href) {
|
|
|
|
|
window.top.postMessage({ modrinthOpenUrl: target.href }, 'https://modrinth.com')
|
|
|
|
|
}
|
|
|
|
|
break
|
2024-08-28 21:44:08 -07:00
|
|
|
}
|
2024-08-30 10:42:58 -07:00
|
|
|
target = target.parentElement
|
2024-08-28 21:44:08 -07:00
|
|
|
}
|
2024-09-13 20:33:51 -07:00
|
|
|
},
|
|
|
|
|
true,
|
|
|
|
|
)
|
2024-08-28 21:44:08 -07:00
|
|
|
|
|
|
|
|
window.open = (url, target, features) => {
|
|
|
|
|
window.top.postMessage({ modrinthOpenUrl: url }, 'https://modrinth.com')
|
|
|
|
|
}
|