Last active
August 16, 2024 12:23
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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