@ -3,6 +3,7 @@ import ChangePasswordRuntimeMessage from "../../background/models/changePassword
@@ -3,6 +3,7 @@ import ChangePasswordRuntimeMessage from "../../background/models/changePassword
import AutofillField from "../models/autofill-field" ;
import { WatchedForm } from "../models/watched-form" ;
import { FormData } from "../services/abstractions/autofill.service" ;
import { UserSettings } from "../types" ;
interface HTMLElementWithFormOpId extends HTMLElement {
formOpId : string ;
@ -26,10 +27,64 @@ interface HTMLElementWithFormOpId extends HTMLElement {
@@ -26,10 +27,64 @@ interface HTMLElementWithFormOpId extends HTMLElement {
* and async scripts to finish loading .
* https : //developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event
* /
document . addEventListener ( "DOMContentLoaded" , ( event ) = > {
// Do not show the notification bar on the Bitwarden vault
// because they can add logins and change passwords there
if ( window . location . hostname . endsWith ( "vault.bitwarden.com" ) ) {
document . addEventListener ( "DOMContentLoaded" , async ( event ) = > {
// These are preferences for whether to show the notification bar based on the user's settings
// and they are set in the Settings > Options page in the browser extension.
let disabledAddLoginNotification = false ;
let disabledChangedPasswordNotification = false ;
let showNotificationBar = true ;
// Look up the active user id from storage
const activeUserIdKey = "activeUserId" ;
let activeUserId : string ;
await chrome . storage . local . get ( activeUserIdKey , ( obj : any ) = > {
if ( obj == null || obj [ activeUserIdKey ] == null ) {
return ;
}
activeUserId = obj [ activeUserIdKey ] ;
} ) ;
// Look up the user's settings from storage
await chrome . storage . local . get ( activeUserId , ( obj : any ) = > {
if ( obj ? . [ activeUserId ] == null ) {
return ;
}
const userSettings : UserSettings = obj [ activeUserId ] . settings ;
// Do not show the notification bar on the Bitwarden vault
// because they can add logins and change passwords there
if ( window . location . origin === userSettings . serverConfig . environment . vault ) {
showNotificationBar = false ;
return ;
}
// NeverDomains is a dictionary of domains that the user has chosen to never
// show the notification bar on (for login detail collection or password change).
// It is managed in the Settings > Excluded Domains page in the browser extension.
// Example: '{"bitwarden.com":null}'
const excludedDomainsDict = userSettings . neverDomains ;
if (
excludedDomainsDict != null &&
// eslint-disable-next-line
excludedDomainsDict . hasOwnProperty ( window . location . hostname )
) {
return ;
}
// Set local disabled preferences
disabledAddLoginNotification = userSettings . disableAddLoginNotification ;
disabledChangedPasswordNotification = userSettings . disableChangedPasswordNotification ;
if ( ! disabledAddLoginNotification || ! disabledChangedPasswordNotification ) {
// If the user has not disabled both notifications, then handle the initial page change (null -> actual page)
handlePageChange ( ) ;
}
} ) ;
if ( ! showNotificationBar ) {
return ;
}
@ -77,53 +132,6 @@ document.addEventListener("DOMContentLoaded", (event) => {
@@ -77,53 +132,6 @@ document.addEventListener("DOMContentLoaded", (event) => {
] ) ;
const changePasswordButtonContainsNames = new Set ( [ "pass" , "change" , "contras" , "senha" ] ) ;
// These are preferences for whether to show the notification bar based on the user's settings
// and they are set in the Settings > Options page in the browser extension.
let disabledAddLoginNotification = false ;
let disabledChangedPasswordNotification = false ;
// Look up the active user id from storage
const activeUserIdKey = "activeUserId" ;
let activeUserId : string ;
chrome . storage . local . get ( activeUserIdKey , ( obj : any ) = > {
if ( obj == null || obj [ activeUserIdKey ] == null ) {
return ;
}
activeUserId = obj [ activeUserIdKey ] ;
} ) ;
// Look up the user's settings from storage
chrome . storage . local . get ( activeUserId , ( obj : any ) = > {
if ( obj ? . [ activeUserId ] == null ) {
return ;
}
const userSettings = obj [ activeUserId ] . settings ;
// NeverDomains is a dictionary of domains that the user has chosen to never
// show the notification bar on (for login detail collection or password change).
// It is managed in the Settings > Excluded Domains page in the browser extension.
// Example: '{"bitwarden.com":null}'
const excludedDomainsDict = userSettings . neverDomains ;
if (
excludedDomainsDict != null &&
// eslint-disable-next-line
excludedDomainsDict . hasOwnProperty ( window . location . hostname )
) {
return ;
}
// Set local disabled preferences
disabledAddLoginNotification = userSettings . disableAddLoginNotification ;
disabledChangedPasswordNotification = userSettings . disableChangedPasswordNotification ;
if ( ! disabledAddLoginNotification || ! disabledChangedPasswordNotification ) {
// If the user has not disabled both notifications, then handle the initial page change (null -> actual page)
handlePageChange ( ) ;
}
} ) ;
// Message Processing
// Listen for messages from the background script