|
Revision 23, 1.2 kB
(checked in by hill, 5 months ago)
|
|
Added new art. Updated to use new clipboard permissions (now only works with Chrome 13 or later). Added the ability to define the comment string that gets added to the copied text. Added paste on middle click.
|
| Line | |
|---|
| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <script type="text/javascript"> |
|---|
| 4 | chrome.extension.onRequest.addListener( |
|---|
| 5 | function (req, sender, callback) { |
|---|
| 6 | var i, len, resp = {}; |
|---|
| 7 | if (req.type === "config") { |
|---|
| 8 | if (window.localStorage != null && req.keys != null) { |
|---|
| 9 | len = req.keys.length; |
|---|
| 10 | for (i=0; i<len; i++) { |
|---|
| 11 | resp[req.keys[i]] = |
|---|
| 12 | window.localStorage[req.keys[i]] || undefined; |
|---|
| 13 | } |
|---|
| 14 | callback(resp); |
|---|
| 15 | } else { |
|---|
| 16 | callback({}); |
|---|
| 17 | } |
|---|
| 18 | } else if (req.type === "reformat") { |
|---|
| 19 | if (req.text.length > 0) { |
|---|
| 20 | var ta = document.getElementById('ta'); |
|---|
| 21 | ta.value = req.text; |
|---|
| 22 | ta.select(); |
|---|
| 23 | var rv = document.execCommand("copy"); |
|---|
| 24 | } |
|---|
| 25 | } else if (req.type === "paste") { |
|---|
| 26 | var ta = document.getElementById('ta'); |
|---|
| 27 | ta.value = ""; |
|---|
| 28 | ta.select(); |
|---|
| 29 | var rv = document.execCommand("paste"); |
|---|
| 30 | callback(ta.value); |
|---|
| 31 | } |
|---|
| 32 | } |
|---|
| 33 | ); |
|---|
| 34 | </script> |
|---|
| 35 | </head> |
|---|
| 36 | <body> |
|---|
| 37 | <textarea id="ta"></textarea> |
|---|
| 38 | </body> |
|---|
| 39 | </html> |
|---|