2017-09-29 18:29:36 +01:00
|
|
|
/** Inject an input element into unsuspecting webpages and provide an API for interaction with tridactyl */
|
|
|
|
|
|
|
|
/* TODO:
|
|
|
|
CSS
|
|
|
|
Friendliest-to-webpage way of injecting commandline bar?
|
|
|
|
Security: how to prevent other people's JS from seeing or accessing the bar or its output?
|
|
|
|
- Method here is isolation via iframe
|
|
|
|
- Web content can replace the iframe, but can't view or edit its content.
|
|
|
|
- see doc/escalating-privilege.md for other approaches.
|
|
|
|
*/
|
|
|
|
|
2017-10-02 00:59:51 +01:00
|
|
|
// inject the commandline iframe into a content page
|
2017-09-29 18:29:36 +01:00
|
|
|
|
2017-10-05 12:34:18 +01:00
|
|
|
export let COMMANDLINE = null
|
|
|
|
|
|
|
|
export function show(){
|
|
|
|
COMMANDLINE = window.document.createElement("iframe")
|
|
|
|
COMMANDLINE.setAttribute("src", browser.extension.getURL("static/commandline.html"))
|
|
|
|
COMMANDLINE.setAttribute("style", "position: fixed; top: 0; left: 0; z-index: 10000; width: 100%; height: 36px; border: 0; padding: 0; margin: 0;");
|
|
|
|
window.document.body.appendChild(COMMANDLINE)
|
2017-09-29 18:29:36 +01:00
|
|
|
|
2017-10-04 21:35:52 +01:00
|
|
|
/** Focus the commandline input: not required **/
|
2017-10-05 12:34:18 +01:00
|
|
|
// let focus = ():void => COMMANDLINE.focus()
|
2017-10-04 21:35:52 +01:00
|
|
|
// line below doesn't work
|
2017-10-05 12:34:18 +01:00
|
|
|
COMMANDLINE.addEventListener("blur",COMMANDLINE.remove)
|
2017-10-04 21:35:52 +01:00
|
|
|
// Why were we returning focus? It's a void, surely?
|
|
|
|
// return focus
|
|
|
|
}
|
2017-10-05 12:34:18 +01:00
|
|
|
|
|
|
|
export function focus(){
|
|
|
|
COMMANDLINE.focus()
|
|
|
|
}
|