UPDATE: I recently discovered a clever method using the iframe along with the webRequest
technique! Although I have not tested it myself, here is a useful gist that explains how to implement it:
https://gist.github.com/username/repo123
PREVIOUS RESPONSE
It seems challenging to accomplish this task without utilizing an external API due to certain limitations.
1) To make ajax requests, the server of the target URL must return CORS headers in order for the browser to accept them.
2) One workaround involves dynamically creating an iframe and accessing
chrome.loadTimes().connectionInfo
within its
contentWindow
, but if the server sends a
X-Frame-Options: Deny
header, loading the URL in the iframe will be blocked by the browser.
3) Attempting to bypass the X-frame
headers using the webRequest
API as discussed in this post
Bypassing X-Frame-Options DENY in a Browser Extension
might not produce the desired outcome; Chrome extensions are typically prohibited from altering response bodies.
Potential Solutions
1) Address these challenges by deploying a simple proxy that includes the necessary headers. This guide demonstrates how to achieve this using Nginx
http://example.com/nginx-proxy
2) Alternatively, consider developing a custom API to handle the request and verify HTTP/2 support on the server-side. In case your extension gains popularity, scaling up could involve strategies like caching and horizontal scaling.
I hope these suggestions prove beneficial!