[DNR] main_frame redirect to an extension page + accessing the original URL and POST data #610
Labels
needs-triage: chrome
Chrome needs to assess this issue for the first time
needs-triage: firefox
Firefox needs to assess this issue for the first time
neutral: safari
Not opposed or supportive from Safari
Supersedes #604 with a different, more focused use case: redirecting an entire tab (optionally a frame) to a custom handler.
Extensions like Tapermonkey/Violentmonkey/Stylus/JSONViewer and others want to redirect an entire tab (or frame) based on a URL or on a Content-Type response header (soon will be possible via DNR) to their own built-in UI page. URLs ending on .json, .user.js or .user.css and such, so this is not solved by custom protocol handlers.
Primary goals
use_dynamic_url
;POST
data from submitted forms to allow extensions to preprocess it before uploading to the server.Optional goal
sub_frame
redirection in addition tomain_frame
.Although this is extremely rare to have a custom viewer in a frame, AFAIK, but it seems reasonable for consistency.
ManifestV2
{cancel:true}
or{redirectUrl: 'javascript:0'}
and then redirected the tab viachrome.tabs.update(tabId, {url: 'own.html'})
, passed the original URL either as a URL parameter or via messaging. This only worked with main_frame navigation, though.POST
preprocessing:chrome.webRequest.onBeforeRequest(..., ['requestBody', 'blocking'])
ManifestV3
It's complicated and problematic since normal extensions can't use webRequestBlocking anymore:
POST
preprocessing: interceptingsubmit
event in an isolated content script isn't enough, you'd need to spoof HTMLFormElement.prototype.submit in the main world, which is unsafe/unreliable.Possible solutions for goal 1: exposing the original URL
document.referrer
i.e. not exposed visually.?url=....
accessible asnew URLSearchParams(location.search).get('url')
.It may be appended as
&url=...
if the extension path already contains?
e.g."/foo.html?param=1"
.If deemed desirable, this behavior may be disabled by default, opt-in via
"originalUrlAsParameter": "url"
.Possible solutions for goal 2: redirection without self-exposure
extensionHandler: 'foo.html'
. The name suggests that the extension handles the page, like PDF viewer in Chrome.extensionTabHandler: 'foo.html'
. A more self-explanatory name if we want to support only main_frame navigation.extensionNavigationHandler: 'foo.html'
. Makes it even more obvious that this is only for navigation redirects.extensionPathForNavigation: 'foo.html'
. Also preserves continuity with the existing extensionPath.resourcesTypes: ['main_frame', 'sub_frame']
would automatically allowextensionPath: 'foo.html'
to redirect to the extension's foo.html without exposing it in web_accessible_resources. This is not explicit, though.Possible solutions for goal 3:
POST
data accesschrome.declarativeNetRequest.redirectedRequest
getter orgetRedirectedRequest()
method to get all infochrome.declarativeNetRequest.requestBody
getter orgetRequestBody()
method to get only the bodyThe text was updated successfully, but these errors were encountered: