I'm trying to figure out how to insert a predefined string on right clicking a input field (editable), usually i would use the document get element by id. However, since i have no way to determine what element a user clicks, on any website how do i go about doing this?
so far i have my manifest file
"permissions": [
"contextMenus",
"background",
"https://ajax.googleapis.com/"
],
"background": {
"scripts": ["scrippy.js"]
}
}
(i have the rest of the required info as well.)
And my script file
// Create context menu and set to only on inputs
var type = ["editable"];
var scrippyMenu = chrome.contextMenus.create({"title": "Scrippy",
"contexts": type});
// menu context
var menuContext = chrome.contextMenus.create({"title": "blabla",
"parentId": scrippyMenu, "contexts": type});
var menuChild1 = chrome.contextMenus.create(
{"title": "time", "parentId": menuContext, "contexts": type, "onclick":
genericOnClick});
function genericOnClick(info, tab) {
document.getElementById("Theunknownelement").textContent = 'This is added text';
}