Add persistent global function across pages via window, or localstorage, etc

I am trying to hide an icon on a page I can’t edit directly. I need to add a function that has in it document.getElementById('icon').style.display = 'none';. I don’t need help with the function.

So more in-depth: there is a page, let’s call it unEditPage, that I cannot edit directly. It doesn’t share any resources like our other pages on the website do – aka no global js files or css.

unEditPage and all other pages that I have access to are all on the same domain.

I’ve tried attaching an event listen to the window and fire on url contains, but that listener is destroyed on page navigation.

Solution would be something I can inject in another page that carries over to the unEditable page. Something maybe using unload, localstorage, cookies, or global something.