re: How to prevent pasting into input fields VIEW POST

VIEW FULL DISCUSSION
 

How to fix this "solution"

for (const elm of $$('*')){
  if (elm.onpaste) elm.onpaste = undefined
  const {paste} = getEventListeners(elm)
  if (paste) {
    for (const lis of paste) elm.removeEventListener('paste', lis.listener, lis)
  }
}

I get to use the Chrome-specific $$ because I'm already necessarily using Chrome-specific getEventListeners.

The provided example can be defeated by just this though:

for (const elm of document.querySelectorAll('*')){
  if (elm.onpaste) elm.onpaste = undefined
}
code of conduct - report abuse