2024-08-30 10:42:58 -07:00
|
|
|
if (!window.modrinthClickListener) {
|
|
|
|
|
window.modrinthClickListener = true
|
|
|
|
|
document.addEventListener('click', function (e) {
|
|
|
|
|
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-08-30 10:42:58 -07:00
|
|
|
})
|
|
|
|
|
}
|
2024-08-28 21:44:08 -07:00
|
|
|
|
|
|
|
|
window.open = (url, target, features) => {
|
|
|
|
|
window.top.postMessage({ modrinthOpenUrl: url }, 'https://modrinth.com')
|
|
|
|
|
}
|