From ea76543ccfdab68ee00fd569e31298c8f7d9bea4 Mon Sep 17 00:00:00 2001 From: Zhe Li Date: Tue, 17 Oct 2023 15:56:08 +0800 Subject: [PATCH] add favicon support --- _locales/en/messages.json | 4 ++++ manifests/manifest-chrome-testing.json | 4 +++- manifests/manifest-chrome.json | 4 +++- manifests/manifest-edge.json | 4 +++- sass/popup.scss | 7 ++++++ src/components/Popup/EntryComponent.vue | 27 +++++++++++++++++++++++- src/components/Popup/PreferencesPage.vue | 22 +++++++++++++++++++ src/definitions/module-interface.d.ts | 1 + src/store/Menu.ts | 5 +++++ svg/medal.svg | 1 + 10 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 svg/medal.svg diff --git a/_locales/en/messages.json b/_locales/en/messages.json index ff33ce7d6..44fc6f7e3 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -289,6 +289,10 @@ "message": "Use Autofill", "description": "Use Autofill" }, + "show_favicon": { + "message": "Show Issuer Icon", + "description": "Show Issuer Icon" + }, "use_high_contrast": { "message": "Use High Contrast", "description": "Use High Contrast" diff --git a/manifests/manifest-chrome-testing.json b/manifests/manifest-chrome-testing.json index 1447cb95f..da065ce02 100644 --- a/manifests/manifest-chrome-testing.json +++ b/manifests/manifest-chrome-testing.json @@ -56,6 +56,8 @@ ], "optional_permissions": [ "clipboardWrite", + "favicon", + "chrome://favicon/", "https://www.google.com/", "https://*.dropboxapi.com/*", "https://www.googleapis.com/*", @@ -65,5 +67,5 @@ ], "offline_enabled": true, "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjo5++7m6mlJGqKOnlYehr9tjIqahMZBJUG7PLa7dSRk6bDUu2pVodO1TQWviHlrDTLP+zfoVbDBS8v8cjloK5Tn90nzC6a957dPzOfyC1WUNYNDlGM0BCmZKVP/MWB3d0ffOmTwaxh0L47aLH5nTW0AUmuwCWCBEEl4Acuyp7rwLNGlazBpaom1Qb5ckn29gCJVVVIZ6wudmcrG/FPTNJXQbg8N6wObGrgGOaxmowbkzJmIfKTyHlYOKLAjZ7aJi0W6jsy47/aV+ojvn4gO+ka6BcRhUeWgoQxqEky119f3OWiVP46SJVbAi0pkknThUjDvX11lATGjB5EvJZGyotwIDAQAB", - "content_security_policy": "script-src 'self' 'unsafe-eval'; font-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/ ws://localhost:9090; default-src 'none'" + "content_security_policy": "script-src 'self' 'unsafe-eval'; font-src 'self'; img-src 'self' data: chrome://favicon/; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/ ws://localhost:9090; default-src 'none'" } diff --git a/manifests/manifest-chrome.json b/manifests/manifest-chrome.json index 6c9ab3a69..22c345444 100644 --- a/manifests/manifest-chrome.json +++ b/manifests/manifest-chrome.json @@ -56,6 +56,8 @@ ], "optional_permissions": [ "clipboardWrite", + "favicon", + "chrome://favicon/", "https://www.google.com/", "https://*.dropboxapi.com/*", "https://www.googleapis.com/*", @@ -64,5 +66,5 @@ "https://login.microsoftonline.com/common/oauth2/v2.0/token" ], "offline_enabled": true, - "content_security_policy": "script-src 'self'; font-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/; default-src 'none'" + "content_security_policy": "script-src 'self'; font-src 'self'; img-src 'self' data: chrome://favicon/; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/; default-src 'none'" } diff --git a/manifests/manifest-edge.json b/manifests/manifest-edge.json index 6a5d11d2f..7308dd0a0 100644 --- a/manifests/manifest-edge.json +++ b/manifests/manifest-edge.json @@ -56,6 +56,8 @@ ], "optional_permissions": [ "clipboardWrite", + "favicon", + "chrome://favicon/", "https://www.google.com/", "https://*.dropboxapi.com/*", "https://www.googleapis.com/*", @@ -64,5 +66,5 @@ "https://login.microsoftonline.com/common/oauth2/v2.0/token" ], "offline_enabled": true, - "content_security_policy": "script-src 'self'; font-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/; default-src 'none'" + "content_security_policy": "script-src 'self'; font-src 'self'; img-src 'self' data: chrome://favicon/; style-src 'self' 'unsafe-inline'; connect-src https://www.google.com/ https://*.dropboxapi.com https://www.googleapis.com/ https://accounts.google.com/o/oauth2/revoke https://login.microsoftonline.com/common/oauth2/v2.0/token https://graph.microsoft.com/; default-src 'none'" } diff --git a/sass/popup.scss b/sass/popup.scss index 4986f6c7a..7bfdabdca 100644 --- a/sass/popup.scss +++ b/sass/popup.scss @@ -212,6 +212,13 @@ svg { display: none; } + .issuerFavicon { + vertical-align: bottom; + margin-right: 5px; + height: 14px; + width: 14px; + } + &:hover { padding-right: 0; overflow-y: scroll; diff --git a/src/components/Popup/EntryComponent.vue b/src/components/Popup/EntryComponent.vue index 3111dbabf..5f67f9d76 100644 --- a/src/components/Popup/EntryComponent.vue +++ b/src/components/Popup/EntryComponent.vue @@ -38,7 +38,16 @@ > -
{{ entry.issuer.split("::")[0] }}
+
+ {{ entry.issuer.split("::")[0] }} +
+
{ + this.$store.commit( + "menu/setShowFavicon", + granted ? showFavicon : false + ); + } + ); + }, + }, }, data() { return { newStorageLocation: this.$store.state.menu.storageArea || localStorage.storageLocation, + isNotFirefox: navigator.userAgent.indexOf("Firefox") === -1, }; }, methods: { diff --git a/src/definitions/module-interface.d.ts b/src/definitions/module-interface.d.ts index 45ad62c49..e96d06b38 100644 --- a/src/definitions/module-interface.d.ts +++ b/src/definitions/module-interface.d.ts @@ -37,6 +37,7 @@ interface MenuState { theme: string; backupDisabled: boolean; storageArea: "sync" | "local"; + showFavicon: boolean; } interface StyleState { diff --git a/src/store/Menu.ts b/src/store/Menu.ts index 1b0f04fab..3dfe0d3e3 100644 --- a/src/store/Menu.ts +++ b/src/store/Menu.ts @@ -8,6 +8,7 @@ export class Menu implements Module { zoom: Number(localStorage.zoom) || 100, useAutofill: localStorage.autofill === "true", smartFilter: localStorage.smartFilter !== "false", + showFavicon: localStorage.showFavicon === "true", theme: localStorage.theme || (localStorage.highContrast === "true" ? "accessibility" : "normal"), @@ -37,6 +38,10 @@ export class Menu implements Module { state.smartFilter = smartFilter; localStorage.smartFilter = smartFilter; }, + setShowFavicon(state: MenuState, showFavicon: boolean) { + state.showFavicon = showFavicon; + localStorage.showFavicon = showFavicon; + }, setTheme(state: MenuState, theme: string) { state.theme = theme; localStorage.theme = theme; diff --git a/svg/medal.svg b/svg/medal.svg new file mode 100644 index 000000000..48c83d328 --- /dev/null +++ b/svg/medal.svg @@ -0,0 +1 @@ + \ No newline at end of file