How to receive redirects in Safari extensions

I am developing a safari extension

When a redirect occurs on a web page, I want to detect the redirect and obtain all redirect URLs.

If there is any way, please let me know

Below is what I tried manifest version is 3

1, Use webNabvigation in background.js

browser.webNavigation.onBeforeNavigate.addListener(function(details) {
     console.log("Redirected to:", details.url);
});

This works, but I couldn't get the expected URL

2, Use webRequest in background.js

This resulted in an error as it was not possible to listen to events in a non-persistent background. This is caused by using manifest version 3.

Post not yet marked as solved Up vote post of minori123123 Down vote post of minori123123
433 views

Replies

Actually, webNavigation.onBeforeNavigate is not the only problem

webRequest.onBeforeRedirect - also doesn't catch all redirects

For example https://developer.apple.com/forums/thread/735111

webRequest is also does not work properly