Content-Script Extension

manifest.json
{
"name": "H1 to Title",
"version": "1.0",
"manifest_version": 3,
"content_scripts": [
{
"matches": ["https://example.com/"],
"js": ["script.js"]
}
]
}




script.js
;(n=>{
console.log('injection running.')

// --------------
const go = n=>{
const h1 = document.querySelector('h1')
const t = h1.textContent

document.querySelector('title').textContent = t+'!!'
}


// https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
console.log(document.readyState) // interactive

// this needed?
window.addEventListener('load',e=>{
console.log('loaded!')
go()
})



})();