Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

GM_setClipboard

Greg Parris edited this page · 9 revisions

Description

GM_setClipboard will allow you to add data to the clipboard.

Arguments

String data

Some data to copy to the clipboard.

String type

Optional. The type of data to copy to the clipboard. The following types are supported:

  • text: Only the data string will be copied to the clipboard.
  • html: The HTML representation of the data will be copied to the clipboard. See the example below.
  • image: Copies a Base64-encoded PNG image to the clipboard.

Note: PNG transparency is not currently supported for this option under Windows.

Returns

undefined

Example

// Copies 'hello clipboard!' to the clipboard
GM_setClipboard('hello clipboard!');
// Also copies 'hello clipboard!' to the clipboard
GM_setClipboard('hello clipboard!', 'text');
var myLink = "<a href='http://scriptish.org'>visit scriptish.org</a>";

// Copies the text content of `myLink` (i.e. "visit scriptish.org") to the clipboard
GM_setClipboard(myLink, 'text');

// Copies the HTML of `myLink` to the clipboard, with a text fallback
// HTML-friendly "paste" targets (e.g. Gmail's message area) will receive an actual HTML link
// Other targets (e.g. the location bar) will receive the text "visit scriptish.org"
GM_setClipboard(myLink, 'html');

Related Pages

Manual: API

Something went wrong with that request. Please try again.