refactor: remove existing content

This commit is contained in:
Astrian Zheng 2025-05-23 20:45:16 +10:00
parent 889adc3774
commit d9587d3e9d
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA

View File

@ -4,29 +4,23 @@ import App from './App.vue'
// Replace the body content with the Vue app // Replace the body content with the Vue app
// Remove existing body content // Remove existing body content
document.body.innerHTML = '' document.getElementsByTagName('html')[0].innerHTML = `
// Create a new container for the Vue app <head>
const container = document.createElement('div') <meta charset="UTF-8" />
container.id = 'app' <meta name="viewport" content="width=device-width, initial-scale=1.0" />
document.body.appendChild(container) <title>Popup</title>
</head>
<body>
<div id="app"></div>
</body>
`
// remove all script and link tags if ('serviceWorker' in navigator) {
const scripts = document.getElementsByTagName('script') navigator.serviceWorker.getRegistrations().then(registrations => {
console.log(scripts) for (let registration of registrations) {
const links = document.getElementsByTagName('link') registration.unregister()
for (let i in scripts) { }
console.log(scripts[i]) })
console.log(typeof scripts[i])
if (typeof scripts[i] === 'object') {
scripts[i].remove()
}
}
for (let i in links) {
console.log(links[i])
console.log(typeof links[i])
if (typeof links[i] === 'object') {
links[i].remove()
}
} }
// mount Vue app // mount Vue app