Skip to content

Commit 0f65f16

Browse files
committed
add favicon support
1 parent c5976b6 commit 0f65f16

File tree

10 files changed

+74
-4
lines changed

10 files changed

+74
-4
lines changed

_locales/en/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@
289289
"message": "Use Autofill",
290290
"description": "Use Autofill"
291291
},
292+
"show_favicon": {
293+
"message": "Show Issuer Icon",
294+
"description": "Show Issuer Icon"
295+
},
292296
"use_high_contrast": {
293297
"message": "Use High Contrast",
294298
"description": "Use High Contrast"

manifests/manifest-chrome-testing.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
"optional_permissions": [
5858
"clipboardWrite",
5959
"contextMenus",
60+
"favicon",
61+
"chrome://favicon/",
6062
"https://www.google.com/",
6163
"https://*.dropboxapi.com/*",
6264
"https://www.googleapis.com/*",
@@ -66,5 +68,5 @@
6668
],
6769
"offline_enabled": true,
6870
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjo5++7m6mlJGqKOnlYehr9tjIqahMZBJUG7PLa7dSRk6bDUu2pVodO1TQWviHlrDTLP+zfoVbDBS8v8cjloK5Tn90nzC6a957dPzOfyC1WUNYNDlGM0BCmZKVP/MWB3d0ffOmTwaxh0L47aLH5nTW0AUmuwCWCBEEl4Acuyp7rwLNGlazBpaom1Qb5ckn29gCJVVVIZ6wudmcrG/FPTNJXQbg8N6wObGrgGOaxmowbkzJmIfKTyHlYOKLAjZ7aJi0W6jsy47/aV+ojvn4gO+ka6BcRhUeWgoQxqEky119f3OWiVP46SJVbAi0pkknThUjDvX11lATGjB5EvJZGyotwIDAQAB",
69-
"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'"
71+
"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'"
7072
}

manifests/manifest-chrome.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
"optional_permissions": [
6161
"clipboardWrite",
6262
"contextMenus",
63+
"favicon",
64+
"chrome://favicon/",
6365
"https://www.google.com/",
6466
"https://*.dropboxapi.com/*",
6567
"https://www.googleapis.com/*",
@@ -68,5 +70,5 @@
6870
"https://login.microsoftonline.com/common/oauth2/v2.0/token"
6971
],
7072
"offline_enabled": true,
71-
"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'"
73+
"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'"
7274
}

manifests/manifest-edge.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
"optional_permissions": [
6161
"clipboardWrite",
6262
"contextMenus",
63+
"favicon",
64+
"chrome://favicon/",
6365
"https://www.google.com/",
6466
"https://*.dropboxapi.com/*",
6567
"https://www.googleapis.com/*",
@@ -68,5 +70,5 @@
6870
"https://login.microsoftonline.com/common/oauth2/v2.0/token"
6971
],
7072
"offline_enabled": true,
71-
"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'"
73+
"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'"
7274
}

sass/popup.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ svg {
212212
display: none;
213213
}
214214

215+
.issuerFavicon {
216+
vertical-align: bottom;
217+
margin-right: 5px;
218+
height: 14px;
219+
width: 14px;
220+
}
221+
215222
&:hover {
216223
padding-right: 0;
217224
overflow-y: scroll;

src/components/Popup/EntryComponent.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@
3939
<IconRedo />
4040
</div>
4141
<div class="issuer">
42-
{{
42+
<img
43+
class="issuerFavicon"
44+
v-if="shouldShowFavicon() && entry.issuer.split('::')[1]"
45+
v-bind:src="getFaviconUrl(entry.issuer.split('::')[1])"
46+
/><IconMedal
47+
class="issuerFavicon"
48+
v-if="shouldShowFavicon() && !entry.issuer.split('::')[1]"
49+
/>
50+
{{
4351
entry.issuer.split("::")[0] +
4452
(theme === "compact" ? ` (${entry.account})` : "")
4553
}}
@@ -96,6 +104,7 @@ import IconRedo from "../../../svg/redo.svg";
96104
import IconQr from "../../../svg/qrcode.svg";
97105
import IconBars from "../../../svg/bars.svg";
98106
import IconPin from "../../../svg/pin.svg";
107+
import IconMedal from "../../../svg/medal.svg";
99108
100109
const computedPrototype = [
101110
mapState("accounts", [
@@ -137,6 +146,20 @@ export default Vue.extend({
137146
entry.type !== OTPType.steam
138147
);
139148
},
149+
shouldShowFavicon() {
150+
return (
151+
navigator.userAgent.indexOf("Firefox") === -1 &&
152+
this.$store.state.menu.showFavicon
153+
);
154+
},
155+
getFaviconUrl(u: string) {
156+
// for MV3
157+
// const url = new URL(chrome.runtime.getURL("/_favicon/"));
158+
// url.searchParams.set("pageUrl", "https://" + u);
159+
// url.searchParams.set("size", "16");
160+
// return url.toString();
161+
return "chrome://favicon/https://" + u;
162+
},
140163
showCode(code: string) {
141164
if (code === CodeState.Encrypted) {
142165
return this.i18n.encrypted;
@@ -261,6 +284,7 @@ export default Vue.extend({
261284
IconQr,
262285
IconBars,
263286
IconPin,
287+
IconMedal,
264288
},
265289
});
266290

src/components/Popup/PreferencesPage.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
@change="requireContextMenuPermission()"
4444
v-if="isSupported"
4545
/>
46+
<a-toggle-input
47+
:label="i18n.show_favicon"
48+
v-model="showFavicon"
49+
v-if="isNotFirefox"
50+
/>
4651
<div class="control-group" v-show="encryption.getEncryptionStatus()">
4752
<label class="combo-label">{{ i18n.autolock }}</label>
4853
<input
@@ -141,11 +146,28 @@ export default Vue.extend({
141146
return !isFirefox && !isSafari;
142147
},
143148
},
149+
showFavicon: {
150+
get(): boolean {
151+
return this.$store.state.menu.showFavicon;
152+
},
153+
set(showFavicon: boolean) {
154+
chrome.permissions.request(
155+
{ permissions: ["favicon"], origins: ["chrome://favicon/"] },
156+
(granted) => {
157+
this.$store.commit(
158+
"menu/setShowFavicon",
159+
granted ? showFavicon : false
160+
);
161+
}
162+
);
163+
},
164+
},
144165
},
145166
data() {
146167
return {
147168
newStorageLocation:
148169
this.$store.state.menu.storageArea || localStorage.storageLocation,
170+
isNotFirefox: navigator.userAgent.indexOf("Firefox") === -1,
149171
};
150172
},
151173
methods: {

src/definitions/module-interface.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface MenuState {
3838
theme: string;
3939
backupDisabled: boolean;
4040
storageArea: "sync" | "local";
41+
showFavicon: boolean;
4142
}
4243

4344
interface StyleState {

src/store/Menu.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class Menu implements Module {
1010
useAutofill: localStorage.autofill === "true",
1111
smartFilter: localStorage.smartFilter !== "false",
1212
enableContextMenu: localStorage.enableContextMenu === "true",
13+
showFavicon: localStorage.showFavicon === "true",
1314
theme:
1415
localStorage.theme ||
1516
(localStorage.highContrast === "true"
@@ -47,6 +48,10 @@ export class Menu implements Module {
4748
state.enableContextMenu = enableContextMenu;
4849
localStorage.enableContextMenu = enableContextMenu;
4950
},
51+
setShowFavicon(state: MenuState, showFavicon: boolean) {
52+
state.showFavicon = showFavicon;
53+
localStorage.showFavicon = showFavicon;
54+
},
5055
setTheme(state: MenuState, theme: string) {
5156
state.theme = theme;
5257
localStorage.theme = theme;

svg/medal.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)