Hi,
I have a code that replaces a selected text by the mouse with another text
but I don't know how to get it worked.
my extension.js
_______________________________________
replaceSelectedText("HI");
function replaceSelectedText(replacementText) {
var sel, range;
if (window.getSelection) {
sel = window.getSelection();
if (sel.rangeCount) {
range = sel.getRangeAt(0);
range.deleteContents();
range.insertNode(document.createTextNode(replacementText));
}
} else if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
range.text = replacementText;
}
}
_____________________________________
my Manifest.json
{
"name": "Translator",
"version": "1.0",
"manifest_version": 2,
"description": "This Extention helps you to translate",
"author": "Ayman Ghandour",
"browser_action": {
"default_title": "Translator",
"default_icon": {
"38": "80.png"
}
},
"permissions": [
"
What I have tried:
I have tried to load the extension but when I select any text it's not changed to HI.
please help me ..
thanks a lot
Ayman