I made an extension where I can copy a text clicking a button. However, it doesn´t work...
manifest.js:
{
"manifest_version": 2,
"name": "Copy",
"description": "Copy",
"version": "1.0",
"browser_action":{
"default_popup": "popup.html",
"default_title": "Copy"
},
"content_scripts": [ {
"matches": ["http://www.google.com/*"],
"js": ["popup.js"]
} ],
"permissions": ["tabs","clipboardWrite","clipboardRead"]
}
popup.html:
<script src='popup.js'></script>
<button onclick="copyToClipboard()">Copy text</button>
popup.js:
function copyToClipboard() {
var $temp = $("<input>");
$("body").append($temp);
$temp.val("this is a text").select();
document.execCommand("copy");
$temp.remove();
}
Any idea what's wrong?