Skip to content

Instantly share code, notes, and snippets.

@searls
Last active August 16, 2024 12:23
Show Gist options
  • Save searls/7ba37ceb824321e5bd0a89c61bee049f to your computer and use it in GitHub Desktop.
Save searls/7ba37ceb824321e5bd0a89c61bee049f to your computer and use it in GitHub Desktop.
There's no way for web developers to prevent 1Password from thinking it can fill one-time-passwords (OTP) if they have autocomplete=one-time-code. This is madness, because 80% of these are SMS/email, and 1Password offers no way to fill these.
import { Controller } from '@hotwired/stimulus'
const BANNED_NODES = ['com-1password-button', 'com-1password-menu']
export default class extends Controller {
connect () {
this.observer = new window.MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (BANNED_NODES.includes(node.nodeName.toLowerCase())) {
node.remove()
}
})
})
})
this.observer.observe(document.body, { childList: true, subtree: true })
}
disconnect () {
if (this.observer) {
this.observer.disconnect()
this.observer = null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment