News for hackers. Stuff that matters.
Re:Chrome allows websites to write to the clipboard without ... by matheusmoreira on Friday August 26, 2022 @10:29PM (#32615026)
> Don't you hate when news sites add a "- from XYZ" to your clipboard?

And then there's the "clever" sites that replace the text I copied with a message like "haha you thought you could copy this? think again sucker".

Re:Chrome allows websites to write to the clipboard without ... by zebracanevra on Friday August 26, 2022 @10:32PM (#32615043)
I feel like if you've selected some text, then pressing copy should always copy that text and nothing else.

But then: what's to stop websites from detecting you've selected text, unselecting it, and copying the bad text in, and then reselecting it...

There are so many loopholes I can imagine to get around these restrictions :(

Re:Chrome allows websites to write to the clipboard without ... by HWR_14 on Saturday August 27, 2022 @01:29AM (#32616030)
> what's to stop websites from detecting you've selected text, unselecting it, and copying the bad text in, and then reselecting it

Disabling JavaScript.

Re:Chrome allows websites to write to the clipboard without ... by devmunchies on Saturday August 27, 2022 @04:31AM (#32617022)
it'd be trivial to trick users to copy the wrong text with only CSS.
Re:Chrome allows websites to write to the clipboard without ... by HWR_14 on Sunday August 28, 2022 @02:59PM (#32630977)
Wait, how?
Re:Chrome allows websites to write to the clipboard without ... by devmunchies on Sunday August 28, 2022 @05:59PM (#32632497)
Make a layer that isn’t visible with “opacity: 0” that sits in front of the visible text. A user copies the invisible text instead.

Or conversely, make the visible text “pointer-events: none” and it sits in front of the dangerous text.

Re:Chrome allows websites to write to the clipboard without ... by HWR_14 on Monday August 29, 2022 @12:16AM (#32634750)
Both of those make sense.
Re:Chrome allows websites to write to the clipboard without ... by Latty on Saturday August 27, 2022 @12:16AM (#32615619)
If you just want to add text in, it is even easier, no JS required. just CSS: insert an element into your text that is positioned off-screen. When the user selects and copies, they'll get that text too.
Re:Chrome allows websites to write to the clipboard without ... by justahuman74 on Friday August 26, 2022 @10:43PM (#32615113)
Why are websites allowed to know that you've selected plain text? (genuinely clueless on web stuff)
Re:Chrome allows websites to write to the clipboard without ... by zebracanevra on Friday August 26, 2022 @10:50PM (#32615160)
I think there are a bunch of decent uses for that, like rich text editors (eg select text, hit ctrl-b, and the text is bolded).

There are also some sites that popup a small box above your selection with a share box. Straight to hell with those. Compulsive selectors go mad on those sites. That's you, medium.com.

Re:Chrome allows websites to write to the clipboard without ... by denton-scratch on Saturday August 27, 2022 @09:38AM (#32618840)
But why does a rich text editor need to talk to a website?
Re:Chrome allows websites to write to the clipboard without ... by LocalH on Saturday August 27, 2022 @09:51AM (#32619010)
What if the rich text editor and the website are the same thing? What if the rich text editor is part of a larger tool that is the website?
Re:Chrome allows websites to write to the clipboard without ... by denton-scratch on Saturday August 27, 2022 @10:16AM (#32619268)
Well, I'm not sure what you're waving at. If the website is nothing more than a RTE, then it's better (and safer) to do it in the browser. If the RTE is just part of the website, then that's a part that's better done in the browser.

Perhaps you want a RTE that doesn't depend on JS. I think that's a reasonable thing to want; but if you normally browse with JS switched off, then running into a working RTE is at least going to violate the Principle of Least Surprise.

Re:Chrome allows websites to write to the clipboard without ... by entropie on Friday August 26, 2022 @11:00PM (#32615214)
Why are websites allowed to know that I hover an element?

Javascript knows about clicks, doubleclicks, hovers... like almost every interaction the user does. There are use cases but also potential to be exploited somehow.

Re:Chrome allows websites to write to the clipboard without ... by paulryanrogers on Friday August 26, 2022 @11:21PM (#32615312)
Because websites are apps now. The browser is your operating system.
Re:Chrome allows websites to write to the clipboard without ... by cypress66 on Friday August 26, 2022 @11:43PM (#32615420)
Click events, hover, etc have always existed (since js exists I'm pretty sure).
Re:Chrome allows websites to write to the clipboard without ... by paulryanrogers on Saturday August 27, 2022 @11:10AM (#32619871)
Regardless of intent, today websites are often built as 'apps', making browsers more and more like your OS. JS is how that's usually implemented.
Re:Chrome allows websites to write to the clipboard without ... by shultays on Saturday August 27, 2022 @06:13AM (#32617506)
In forums you can select parts of someone's post and quote that part in your reply
Re:Chrome allows websites to write to the clipboard without ... by oarabbus_ on Friday August 26, 2022 @11:46PM (#32615430)
Humor me as someone without much web development experience - but what's to stop websites from displaying unclosable ads/popups? As in the "x" does nothing, or maybe doesn't appear at all?
Re:Chrome allows websites to write to the clipboard without ... by dreadlordbone on Saturday August 27, 2022 @12:13AM (#32615589)
It happens, but then people tend to not visit the site.
Re:Chrome allows websites to write to the clipboard without ... by dotancohen on Saturday August 27, 2022 @05:50AM (#32617394)
Both Pinterest and Quora have unclosable popups, as do many news websites.
Re:Chrome allows websites to write to the clipboard without ... by manfre on Saturday August 27, 2022 @06:05AM (#32617470)
There is a reason many articles and extensions exist to avoid those sites in search results.
Re:Chrome allows websites to write to the clipboard without ... by matheusmoreira on Saturday August 27, 2022 @09:19AM (#32618632)
> what's to stop websites from displaying unclosable ads/popups?

My uBlock Origin filters stop them with extreme prejudice.

Re:Chrome allows websites to write to the clipboard without ... by rasz on Saturday August 27, 2022 @10:28AM (#32619384)
Enjoy them while you can, less than one year left.
Re:Chrome allows websites to write to the clipboard without ... by rasz on Saturday August 27, 2022 @07:06AM (#32617755)
userscript injecting this everywhere:

    window.addEventListener('copy', function copyintercept(e) {
      console.log(copyintercept.caller, 'copy action initiated');
      e.stopImmediatePropagation();
    }, true)
    
    document.addEventListener("contextmenu", bringBackDefault, true);
    
    function bringBackDefault(event) { event.returnValue = true;
                                      (typeof event.stopPropagation === 'function') && event.stopPropagation();
                                      (typeof event.cancelBubble === 'function') && event.cancelBubble();
                                     }
Re:Chrome allows websites to write to the clipboard without ... by hulitu on Saturday August 27, 2022 @01:05AM (#32615901)
A news website must not know that i selected text. A webpage shall display text. Keyboard input shall not be allowed except in text fields.
Re:Chrome allows websites to write to the clipboard without ... by beebeepka on Saturday August 27, 2022 @04:26AM (#32616995)
I guess you must be really pissed off at something because you're not making any sense.

Couple of things

1. How do you focus a text field without a keyboard? Mouse or touch only? No TAB, no up/down keys for scrolling, no escape, etc.

2. You can disable all non text content in a web page. This was always possible

I can go on and on but what's the point?

Re:Chrome allows websites to write to the clipboard without ... by blep-arsh on Sunday August 28, 2022 @08:41AM (#32627964)
Firefox has (had?) a flag to disable clipboard-related JS events but this flag is global and toggling it breaks copying from various rich text editors.
Re:Chrome allows websites to write to the clipboard without ... by jacquesm on Saturday August 27, 2022 @07:17AM (#32617812)
That's pretty benign. Replacing it with "rm -rf /" would be a lot nastier. (And will teach people not to browse with root windows open ;) ).