Skip to content

Commit 0803587

Browse files
authored
Add files via upload
0 parents  commit 0803587

File tree

8 files changed

+48
-0
lines changed

8 files changed

+48
-0
lines changed

background.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
2+
const tabId = sender.tab.id;
3+
let title = message;
4+
let icon;
5+
6+
if (message === "h2") {
7+
title = "HTTP/2";
8+
icon = "h2";
9+
} else if (message.startsWith("h3")) {
10+
title = "HTTP/3"
11+
icon = "h3";
12+
} else {
13+
icon = "h1";
14+
}
15+
16+
browser.pageAction.setIcon({ path: "icons/" + icon + ".png", tabId });
17+
browser.pageAction.setTitle({ tabId, title });
18+
});

content-script.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
chrome.runtime.sendMessage(
2+
performance.getEntriesByType("navigation")[0].nextHopProtocol
3+
);

icons/default.png

2.58 KB
Loading

icons/h1.png

1.6 KB
Loading

icons/h2.png

2.6 KB
Loading

icons/h3.png

2.38 KB
Loading

icons/quic.png

2.53 KB
Loading

manifest.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"manifest_version": 2,
3+
"name": "HTTP Version Indicator",
4+
"version": "1.0.1",
5+
"description": "Indicate the HTTP version for the current page.",
6+
"icons": {
7+
"128": "icons/default.png"
8+
},
9+
"background": {
10+
"persistent": false,
11+
"scripts": ["background.js"]
12+
},
13+
"content_scripts": [
14+
{
15+
"matches": ["<all_urls>"],
16+
"js": ["content-script.js"],
17+
"run_at": "document_end"
18+
}
19+
],
20+
"page_action": {
21+
"browser_style": true,
22+
"default_icon": "icons/default.png",
23+
"default_title": "HTTP Version Unknown",
24+
"show_matches": ["http://*/*", "https://*/*"],
25+
"hide_matches": ["https://addons.mozilla.org/*", "https://accounts.firefox.com/*"]
26+
}
27+
}

0 commit comments

Comments
 (0)