Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing clipboard data when copying/pasting from a website

I have seen a few sites now where if you highlight text of an article, copy it, and then paste in they can add more text to it.

Try copying and pasting a section of text from an article at http://belfasttelegraph.co.uk/ and you'll see what I mean - they add a link to the original article in the pasted text.

How is this done? I'm assuming there is some javascript at work here

like image 674
blippy Avatar asked Mar 08 '10 10:03

blippy


People also ask

How do I edit something on my clipboard?

When you long-press and copy text to save to the clipboard, it appears in the Clipboard log inside the app. Press the three dots to the right of the clipboard snippet to open a menu with more options. In this menu, you can View, Edit, Share, or Select that entry so that you can paste it anywhere you like.

Can websites see what you copy and paste?

Though they are great for picking up where your content is being used on other sites, they don't and can't measure how people are interacting with your content on your site. In short, they can't tell you what people are copying and pasting on your home page nor can they help you ensure that your work is attributed.

How do I manage copy and paste?

How do you copy and paste? Select the text or image you want, and on a Windows or Linux PC, or a Chromebook, press Ctrl + C to copy. Switch to the app or document where you want to add that item, and press Ctrl + V to paste.

Where is information stored when you copy or cut?

The Clipboard is a holding place on your computer where you can temporarily store data (text, pictures, and so on). When you copy something, your selection is held on the Clipboard, where it remains until you copy something else or shut down your computer.


1 Answers

This is a good effect, you can see the scripting that is fired on copy using Firebug (in Firefox).

Start up Firebug and load the page, choose clear (because the page uses a lot of ajax there are very quickly 100 requests). Then choose the 'All' tab and try to copy. You will see a request for a 1x1 pixel image but if you press on the + button to look at the details, you will see in the 'params' tab that this GET request passes your requested text as the 'content' parameter, with some xpath information that will be used to manipulate the clipboard DOM:

start_node_xpath    /HTML/BODY[@id='belfast']/DIV[@id='root']/DIV[@id='content']/DIV[@id='mainColumn']/DIV[@id='article']/DIV[5]/P[39]/text()

end_node_xpath  /HTML/BODY[@id='belfast']/DIV[@id='root']/DIV[@id='content']/DIV[@id='mainColumn']/DIV[@id='article']/DIV[5]/P[41]/text()

As @Crimson pointed out there are methods to manipulate the clipboard, like zeroclipboard which use Flash and an image.

I reckon that is how the technique is done by using the image get request to change the clipboard.

like image 76
amelvin Avatar answered Sep 26 '22 06:09

amelvin