├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── CODE_OF_CONDUCT.md ├── README.md ├── _locales ├── en │ └── messages.json ├── ja │ └── messages.json ├── ru │ └── messages.json └── tr │ └── messages.json ├── background.ts ├── icons ├── action-default-16.png ├── action-default-32.png ├── action-http2-16.png ├── action-http2-32.png ├── action-http3-16.png ├── action-http3-32.png ├── icon.svg └── src │ └── icon.svg ├── manifest.json ├── package-lock.json ├── package.json └── tsconfig.json /.eslintignore: -------------------------------------------------------------------------------- 1 | background.js 2 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: "@typescript-eslint/parser", 4 | plugins: ["@typescript-eslint", "prettier"], 5 | extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], 6 | rules: { 7 | "prettier/prettier": ["error", { endOfLine: "auto", printWidth: 120 }], 8 | }, 9 | env: { 10 | browser: true, 11 | es6: true, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | web-ext-artifacts/ 3 | .DS_Store 4 | background.js 5 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "firefox", 9 | "request": "attach", 10 | "name": "Attach", 11 | "port": 6005 12 | }, 13 | { 14 | "type": "firefox", 15 | "request": "launch", 16 | "reAttach": true, 17 | "name": "Launch add-on", 18 | "addonType": "webExtension", 19 | "addonPath": "${workspaceRoot}" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "start", 9 | "problemMatcher": [] 10 | }, 11 | { 12 | "type": "npm", 13 | "script": "build", 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at brandon@smartercode.net. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Firefox WebExtension to add an HTTP version support indicator in the address bar. 2 | 3 | **This extension is [hosted on AMO](https://addons.mozilla.org/en-US/firefox/addon/http2-indicator/).** 4 | 5 | This is a completely re-written version of the original add-on by Cheng Sun found here: https://github.com/chengsun/moz-spdy-indicator 6 | 7 | Address bar icon by http://fontawesome.io/ - [SIL OFL 1.1](http://scripts.sil.org/OFL) license. 8 | 9 | ## License 10 | 11 | Copyright © 2025 Brandon Siegel 12 | 13 | Licensed under the [WTFPL version 2](http://www.wtfpl.net/txt/copying/). 14 | -------------------------------------------------------------------------------- /_locales/en/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "HTTP Version Indicator", 4 | "description": "Name of the extension." 5 | }, 6 | "extensionDescription": { 7 | "message": "An indicator showing the HTTP version used to load the page in the address bar.", 8 | "description": "Description of the extension." 9 | }, 10 | "pageActionTitle": { 11 | "message": "Page was loaded over $VERSION$", 12 | "description": "Page action tooltip for the top-level document.", 13 | "placeholders": { 14 | "version" : { 15 | "content" : "$1", 16 | "example" : "HTTP/2" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /_locales/ja/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "HTTP Version Indicator", 4 | "description": "アドオンの名称" 5 | }, 6 | "extensionDescription": { 7 | "message": "アドレスバーに HTTP バージョンを表示します ", 8 | "description": "アドオンの概要" 9 | }, 10 | "pageActionTitle": { 11 | "message": "ページが $VERSION$ 経由で読み込まれました", 12 | "description": "トップレベルドキュメントにおいて有効な場合のページアクションツールチップ", 13 | "placeholders": { 14 | "version" : { 15 | "content" : "$1", 16 | "example" : "HTTP/2" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /_locales/ru/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "HTTP Version Indicator", 4 | "description": "Название дополнения" 5 | }, 6 | "extensionDescription": { 7 | "message": "Показывает версию HTTP в адресной строке", 8 | "description": "Описание дополнения" 9 | }, 10 | "pageActionTitle": { 11 | "message": "Страница была загружена через $VERSION$", 12 | "description": "Всплывающая подсказка, когда активен документ верхнего уровня", 13 | "placeholders": { 14 | "version" : { 15 | "content" : "$1", 16 | "example" : "HTTP/2" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /_locales/tr/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionName": { 3 | "message": "HTTP Version Indicator", 4 | "description": "Uzantının adı." 5 | }, 6 | "extensionDescription": { 7 | "message": "Adres çubuğunda HTTP sürümünü gösteren bir gösterge.", 8 | "description": "Eklentinin açıklaması." 9 | }, 10 | "pageActionTitle": { 11 | "message": "Sayfa, $VERSION$ ile yüklendi.", 12 | "description": "Üst düzey belge etkin olduğunda sayfa eylem ipucu.", 13 | "placeholders": { 14 | "version" : { 15 | "content" : "$1", 16 | "example" : "HTTP/2" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /background.ts: -------------------------------------------------------------------------------- 1 | const HEADER_SPDY = "x-firefox-spdy"; 2 | const HEADER_HTTP3 = "x-firefox-http3"; 3 | const RESOURCE_TYPE_MAIN_FRAME = "main_frame"; 4 | 5 | type HttpProtocol = { name: string; version?: string }; 6 | 7 | const state: { [key: number]: HttpProtocol | undefined } = {}; 8 | 9 | function setState(tabId: number, protocol: HttpProtocol) { 10 | state[tabId] = protocol; 11 | setPageAction(tabId); 12 | } 13 | 14 | function getHttp2Protocol(headerValue?: string): HttpProtocol { 15 | if (headerValue && headerValue.match(/^h2/)) { 16 | return { name: "HTTP/2" }; 17 | } else if (headerValue === "3.1") { 18 | return { name: "SPDY", version: "3.1" }; 19 | } else if (headerValue === "3") { 20 | return { name: "SPDY", version: "3" }; 21 | } else if (headerValue === "2") { 22 | return { name: "SPDY", version: "2" }; 23 | } else { 24 | return { name: "SPDY" }; 25 | } 26 | } 27 | 28 | function setPageAction(tabId: number) { 29 | const protocol = state[tabId]; 30 | 31 | if (!protocol) { 32 | browser.pageAction.hide(tabId); 33 | } else { 34 | browser.pageAction.show(tabId); 35 | browser.pageAction.setIcon({ 36 | tabId: tabId, 37 | path: getIcon(protocol), 38 | }); 39 | browser.pageAction.setTitle({ 40 | tabId: tabId, 41 | title: getTitle(protocol), 42 | }); 43 | } 44 | } 45 | 46 | function getIcon(protocol: HttpProtocol): Record { 47 | switch (protocol.name) { 48 | case "HTTP/3": 49 | return { 50 | 16: "icons/action-http3-16.png", 51 | 32: "icons/action-http3-32.png", 52 | }; 53 | case "HTTP/2": 54 | case "SPDY": 55 | return { 56 | 16: "icons/action-http2-16.png", 57 | 32: "icons/action-http2-32.png", 58 | }; 59 | default: 60 | return { 61 | 16: "icons/action-default-16.png", 62 | 32: "icons/action-default-32.png", 63 | }; 64 | } 65 | } 66 | 67 | function getTitle(protocol: HttpProtocol): string { 68 | let version = protocol.name; 69 | if (protocol.version) { 70 | version += " (" + protocol.version + ")"; 71 | } 72 | 73 | return browser.i18n.getMessage("pageActionTitle", version); 74 | } 75 | 76 | browser.webRequest.onHeadersReceived.addListener( 77 | (e) => { 78 | if (e.tabId === -1 || e.type !== RESOURCE_TYPE_MAIN_FRAME) { 79 | return; 80 | } 81 | 82 | for (const header of e.responseHeaders || []) { 83 | switch (header.name.toLowerCase()) { 84 | case HEADER_HTTP3: 85 | setState(e.tabId, { name: "HTTP/3", version: header.value }); 86 | return; 87 | case HEADER_SPDY: 88 | setState(e.tabId, getHttp2Protocol(header.value)); 89 | return; 90 | } 91 | } 92 | 93 | const statusLineVersion = e.statusLine.split(" ", 2)[0]; 94 | setState(e.tabId, { name: statusLineVersion }); 95 | }, 96 | { urls: [""] }, 97 | ["responseHeaders"] 98 | ); 99 | 100 | browser.webNavigation.onCommitted.addListener((e) => { 101 | if (e.frameId === 0) { 102 | setPageAction(e.tabId); 103 | } 104 | }); 105 | 106 | browser.tabs.onActivated.addListener((e) => { 107 | setPageAction(e.tabId); 108 | }); 109 | 110 | browser.tabs.onRemoved.addListener((tabId) => { 111 | state[tabId] = undefined; 112 | }); 113 | -------------------------------------------------------------------------------- /icons/action-default-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsiegel/http-version-indicator/39e85615fbefd1870c5a8e3a6815fb51efc0fffc/icons/action-default-16.png -------------------------------------------------------------------------------- /icons/action-default-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsiegel/http-version-indicator/39e85615fbefd1870c5a8e3a6815fb51efc0fffc/icons/action-default-32.png -------------------------------------------------------------------------------- /icons/action-http2-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsiegel/http-version-indicator/39e85615fbefd1870c5a8e3a6815fb51efc0fffc/icons/action-http2-16.png -------------------------------------------------------------------------------- /icons/action-http2-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsiegel/http-version-indicator/39e85615fbefd1870c5a8e3a6815fb51efc0fffc/icons/action-http2-32.png -------------------------------------------------------------------------------- /icons/action-http3-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsiegel/http-version-indicator/39e85615fbefd1870c5a8e3a6815fb51efc0fffc/icons/action-http3-16.png -------------------------------------------------------------------------------- /icons/action-http3-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bsiegel/http-version-indicator/39e85615fbefd1870c5a8e3a6815fb51efc0fffc/icons/action-http3-32.png -------------------------------------------------------------------------------- /icons/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /icons/src/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 53 | 55 | 56 | 58 | image/svg+xml 59 | 61 | 62 | 63 | 64 | 65 | 70 | 77 | 82 | HTTP 2 93 | 94 | 95 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "__MSG_extensionName__", 4 | "version": "3.2.1", 5 | "description": "__MSG_extensionDescription__", 6 | "default_locale": "en", 7 | "icons": { 8 | "48": "icons/icon.svg", 9 | "64": "icons/icon.svg", 10 | "96": "icons/icon.svg", 11 | "128": "icons/icon.svg" 12 | }, 13 | "browser_specific_settings": { 14 | "gecko": { 15 | "id": "spdyindicator@chengsun.github.com" 16 | } 17 | }, 18 | "permissions": [ 19 | "", 20 | "tabs", 21 | "webNavigation", 22 | "webRequest" 23 | ], 24 | "page_action": { 25 | "browser_style": false, 26 | "default_icon": { 27 | "16": "icons/action-default-16.png", 28 | "32": "icons/action-default-32.png" 29 | } 30 | }, 31 | "background": { 32 | "scripts": ["background.js"] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "http-version-indicator", 3 | "version": "3.2.1", 4 | "license": "WTFPL", 5 | "scripts": { 6 | "build": "tsc", 7 | "start": "tsc && web-ext run", 8 | "package": "tsc && web-ext build -n 'http-version-indicator-{version}.zip' -o --verbose", 9 | "sign": "web-ext sign -n 'http-version-indicator-{version}-signed.zip' --verbose", 10 | "lint": "eslint **/*.ts && web-ext lint", 11 | "prettify": "prettier --write **/*.ts" 12 | }, 13 | "devDependencies": { 14 | "@typescript-eslint/eslint-plugin": "^4.18.0", 15 | "@typescript-eslint/parser": "^4.18.0", 16 | "eslint": "^7.22.0", 17 | "eslint-config-prettier": "^8.1.0", 18 | "eslint-plugin-prettier": "^3.3.1", 19 | "prettier": "^2.2.1", 20 | "typescript": "^4.2.3", 21 | "web-ext": "^5.5.0", 22 | "web-ext-types": "^3.2.1" 23 | }, 24 | "webExt": { 25 | "ignoreFiles": [ 26 | "package*.json", 27 | "tsconfig.json", 28 | "*.ts", 29 | "*.md", 30 | "node_modules", 31 | "icons/src" 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "outDir": "./", 5 | "sourceMap": false, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "noImplicitAny": true, 11 | "strict": true, 12 | "target": "es6", 13 | "typeRoots": [ 14 | "node_modules/@types", 15 | "node_modules/web-ext-types" 16 | ], 17 | "lib": [ 18 | "es6", 19 | "dom" 20 | ] 21 | }, 22 | "exclude": ["node_modules/*"] 23 | } 24 | --------------------------------------------------------------------------------