3
私のChrome拡張機能に、選択したテキストの周りにフレーム/枠(Evernote Web Clipper:下の画像など)を追加する方法を探しています。Chrome拡張機能が選択されたテキスト
それを行うには、私は選択のHTMLコードをキャプチャし、現在選択されているテキストの周りにフレーム/境界線を追加思いました。しかし、私はそれを行うことができますどのように表示されていない...ここで
は私のコードです:manifest.jsonを:
{
"name": "Selected Text",
"version": "0.1",
"description": "Selected Text",
"manifest_version": 2,
"browser_action": {
"default_title": "Selected Text",
"default_icon": "online.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs",
"<all_urls>"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["popup.js"]
}
]
}
popup.js:
chrome.tabs.executeScript({
code: "window.getSelection().toString();"
}, function(selection) {
console.log(selection[0]);
if(selection[0].length > 0){
document.getElementById("text").value = selection[0];
}
});
ポップアップ.html:
<!DOCTYPE html>
<html>
<head>
<script src="popup.js"></script>
<style>
body { width: 300px; }
textarea { width: 250px; height: 100px;}
</style>
</head>
<body>
<textarea id="text"> </textarea>
</body>
</html>
popup.htmlのテキスト領域の使用方法は? – sabithpocker
@sabithpockerちょうど一時的なプレビューを持つことです。 – Steve23