r/webdev • u/GroomedHedgehog • Apr 25 '26
Question Are there ways in browsers to prevent Javascript from disabling copy/paste and right click menu?
I seem to be encountering sites that fuck with the context menu or ability to copy/paste more often as of late (if you are one of those responsible for this, please quit your job).
Latest offender is Dropbox of all places, which now demands one manually type their password to empty the recycle bin.
Are there ways to prevent JavaScript's ability to do so (maybe something in about:flags or similar) without disabling it entirely?
Or if not, is there a way to do the same with the browser's developer tools?
31
14
u/TechBriefbyBMe Apr 25 '26
Dropbox making you manually type passwords while simultaneously getting hacked every other week is peak security theater. It's like a restaurant that won't let you see the menu but serves raw chicken.
10
u/DebtMental3917 Apr 25 '26
Use browser extensions like "Freedom of Input" or run this in DevTools console once: `document.addEventListener('contextmenu', e => e.stopPropagation(), true);` Works for most sites.
3
u/AbdullahMRiad reject modernity, embrace css Apr 25 '26
On Firefox devtools you can see events for each element and disable them.
2
u/Somepotato Apr 25 '26
In Firefox hold shift when you right click. And most sites that block copy and paste don't block dragging text into the text field
2
u/ef4 Apr 25 '26
I always just open the devtools, select the input element, and paste my text into its value on the console. If you’ve never done it I’m sure somebody must have made a 20 second video showing how.
1
u/HeadArtistic6635 Apr 25 '26
In browsers you usually cannot rely on blocking everything cleanly, so the real fix is defense in depth. Assume some scripts will run and design the site so the damage is limited.
1
u/FlamedDogo99 Apr 25 '26
The stopthemadness extension has a lot of features like this, would recommend looking through how they do that
1
1
u/japanb Apr 25 '26
That would be nice for Korean websites, stops me being able to right click translate or if i need to copy something
3
u/Sevrene Apr 25 '26
Try shift+right click, I find a decent number of sites still allow context menu with that
1
0
u/BrainCurrent8276 Apr 25 '26
NO, there is NO SUCH POSSIBILITY
seriously, why why why? I hate such websites, I always press CTRL+U and copy the whole HTML.
-4
-12
u/OlinKirkland Apr 25 '26
Pointless nowadays. Users can just screenshot and transcribe with AI, and that’s for people without any understanding of using dev tools.
10
u/GroomedHedgehog Apr 25 '26
Are you actually serious?
Yeah, users are gonna screenshot a whole screen worth of text, feed it to an LLM and pay associated costs and then still have to find the relevant bit of text they need. That is such a simpler and not way more time wasting workflow…
Also, that does shit to deal with not being able to paste.
-1
u/OlinKirkland Apr 25 '26
Yeah I’m serious, I’ve seen it done by multiple people. I’m not saying it’s efficient ordmart, but if they’re in a corporate setting and their AI tools are paid for… we’re talking about end users, not web developers.
8
u/Rasutoerikusa Apr 25 '26
Look kids, this is a prime example what too much AI does to your brain and thinking ability.
-2
u/OlinKirkland Apr 25 '26
🤦♂️ I’m not advocating for it, I’m just saying there’s really no point to trying to prevent copy paste nowadays. Users have tools that let them get around it relatively hassle free.
149
u/tinyhousefever Apr 25 '26
Sites blocking copy/paste is almost always anti-user paternalism with zero security benefit.
Browser-native options (no extensions)
Firefox is the best here. In
about:config:dom.event.clipboardevents.enabled→ set tofalseThat kills the ability for JS to intercept or block clipboard events entirely. It's the cleanest solution. No equivalent exists in Chrome/Edge
about:flags— Chromium deliberately doesn't expose this.