mirror of
https://github.com/vale981/tridactyl
synced 2025-03-10 12:46:38 -04:00

* prev tab ('#') isn't always the previously selected tab, i.e., even if you remotely close the previously selected tab, since we determine based on time of last access, we always have a previous tab as long as there is more than one tab in the window. * related, displayed prev tab could be wrong if user unfocuses commandline, switches tabs via other means and returns to the already opened :buffer. Possible solution could be to share the variable so it is only set when tabs are listed. * Sometimes favicons initially fail to load but reappear in the commandline when you switch to the tab. Appears unrelated to whether the tab is discarded (unloaded in memory). * Unsuccessfully adding rules for <a> tags. Beside incompetence, Firefox might be overriding?
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
/** 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.
|
|
*/
|
|
|
|
// inject the commandline iframe into a content page
|
|
|
|
let cmdline_iframe: HTMLIFrameElement = undefined
|
|
|
|
function init(){
|
|
cmdline_iframe = window.document.createElement("iframe")
|
|
cmdline_iframe.setAttribute("src", browser.extension.getURL("static/commandline.html"))
|
|
hide()
|
|
window.document.body.appendChild(cmdline_iframe)
|
|
}
|
|
|
|
// TODO: Propagate awaits back through messaging system or resend
|
|
// commandline_frame messages from excmd_content if you want to avoid init'ing
|
|
// every time.
|
|
init()
|
|
|
|
export function show(){
|
|
cmdline_iframe.setAttribute("style", "position: fixed; bottom: 0; left: 0; z-index: 10000; width: 100%; height: 36px; border: 0; padding: 0; margin: 1;");
|
|
}
|
|
|
|
export function resize() {
|
|
const height = cmdline_iframe.contentWindow.document.body.offsetHeight + 'px'
|
|
cmdline_iframe.setAttribute("style", `position: fixed; bottom: 0; left: 0; z-index: 10000; width: 100%; height: ${height}; border: 0; padding: 0; margin: 1;`);
|
|
}
|
|
|
|
export function hide(){
|
|
cmdline_iframe.setAttribute("style", "display: none")
|
|
}
|
|
|
|
export function focus(){
|
|
show()
|
|
cmdline_iframe.focus()
|
|
}
|