Ctrl + Aを押してから現在のタブをクリップボードにコピーするのと同じように、ページ全体をコピーする方法を誰かに教えてもらえますか。
現在私はこれを持っていますが、拡張機能がchromeに正常に追加されましたが、何もしていません:
マニフェストファイル
"permissions":
[
"clipboardRead",
"clipboardWrite"
],
// etc
コンテンツスクリプト
chrome.extension.sendRequest({ text: "text you want to copy" });
背景ページ
<html>
<head>
<script type="text/javascript">
chrome.extension.onRequest.addListener(function (msg, sender, sendResponse) {
var textarea = document.getElementById("tmp-clipboard");
// now we put the message in the textarea
textarea.value = msg.text;
// and copy the text from the textarea
textarea.select();
document.execCommand("copy", false, null);
// finally, cleanup / close the connection
sendResponse({});
});
</script>
</head>
<body>
<textarea id="tmp-clipboard"></textarea>
</body>
</html>
現れる
<textarea id="tmp-clipboard"></textarea>
<input type="button" id="btn" value="Copy Page">
私はこれを機能させることができません、私がここで何が欠けているのか疑問に思います。
現在のタブをクリップボードに保存するために、Ctrl+のA後にCtrl+を模倣する方法を教えてもらえますか?C