I thought about getting the final output link using some listener for redirect event JavaScript like OnHashChange and then cancel the redirect if it was an 'specified link'.
https://developer.mozilla.org/pt-BR/docs/Web/API/WindowEventHandlers/onhashchange
Where OnHashCahnge return the new URL and old URL, but only for hash urls.
So I try beforeunload
https://developer.mozilla.org/pt-BR/docs/Web/Events/beforeunload
But although I can use a function before leaving the page, it does not return the new URL