I recently had the idea to attempt to make a proxy all in front end html and js. I have realized from multiple attempts this is a dumb idea. The machine I’m making this for has a special program on the device that redirects a url to another url with a “Blocked URL Message” I had an idea and that was to create a middle man that would take your website request, redirect you to that page, and prevent the blockers redirect from happening. I have looked all over but I don’t think there is a way to inject code into a redirected page. The code I am trying to inject is this
window.addEventListener(“beforeunload”, (event) => {
event.preventDefault();
});
I am very new to HTML and JS and I was wondering if this was a good idea or not. If I can’t figure this out I will go back to writing a web server and then using an iframe to render the contents of that proxy. But in sum, I need to know if one this code I mentioned will prevent a redirect and 2 if it is possible to redirect to a specified URL and inject this code into the html from the redirected page