I developing new extension for google chrome browser, and now I stacked this task:
data:text/javascript;charset=utf-8
, (empty js).developer chrome docs says, that I can do it like this:
chrome.webRequest.onBeforeRequest.addListener((details)=>{
//some if statments and etc...
return { redirectUrl: 'data:text/javascript;charset=utf-8,'}
}, {urls: ["<all_urls>"]}, ["blocking"]);
And I am very sure it's allowed to redirect to data:
links like this, because of this docs:
redirectUrl Only used as a response to the onBeforeRequest and onHeadersReceived events. If set, the original request is prevented from being sent/completed and is instead redirected to the given URL. Redirections to non-HTTP schemes such as data: are allowed. Redirects initiated by a redirect action use the original request method for the redirect, with one exception: If the redirect is initiated at the onHeadersReceived stage, then the redirect will be issued using the GET method. Redirects from URLs with ws:// and wss:// schemes are ignored.
But when I tries to do this, I see this error in console: net:ERR_UNSAFE_REDIRECT
So, what is my problem?
P.S. in my mainfest.json I have this permisions
:
"permissions": [ "webNavigation", "tabs", "webRequest", "webRequestBlocking", "<all_urls>", "notifications", "storage", "contextMenus", "unlimitedStorage" ],