My Chrome extension copy text from the current page and show that inside a box on the left side of the current page, which will remain fixed even if I scroll the current page. My code is:
content.js
string=[];i=0;
function doc_keyUp(e) {
if (getSelectionText() != "") {
if (e.key === '1') {
string[i]=string+getSelectionText();
view = window.open("","Viewer", "width=400,height=600"); //"_parent",
edit = document.createElement("div");
edit.textContent = "Arranging Text.nn"+string;
view.document.body.appendChild(edit);
}
}
} // doc_keyUp(e)
console.log('The program has started!!!');
// register the handler
document.addEventListener('keyup', doc_keyUp, false);
function getSelectionText() {
var text = "";
text = window.getSelection().toString();
if (window.getSelection) {
text = window.getSelection().toString();
}
else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
manifest.json
{
"name": "",
"description": "",
"version": "1.0",
"manifest_version": 3,
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
],
"permissions": ["tabs"]
}
Now I have a window which pops up, but I want to have that window inside the current page. For example see the below image:
See the “B” is the current page, and “A” is another part that will remain same even if you scroll “B”. I want to show in box like “A”.
What is the name of such things? How can I do that?
