diff options
Diffstat (limited to 'src/content/console-frames.ts')
-rw-r--r-- | src/content/console-frames.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/content/console-frames.ts b/src/content/console-frames.ts new file mode 100644 index 0000000..ecb5a87 --- /dev/null +++ b/src/content/console-frames.ts @@ -0,0 +1,38 @@ +import messages from 'shared/messages'; + +const initialize = (doc) => { + let iframe = doc.createElement('iframe'); + iframe.src = browser.runtime.getURL('build/console.html'); + iframe.id = 'vimvixen-console-frame'; + iframe.className = 'vimvixen-console-frame'; + doc.body.append(iframe); + + return iframe; +}; + +const blur = (doc) => { + let iframe = doc.getElementById('vimvixen-console-frame'); + iframe.blur(); +}; + +const postError = (text) => { + browser.runtime.sendMessage({ + type: messages.CONSOLE_FRAME_MESSAGE, + message: { + type: messages.CONSOLE_SHOW_ERROR, + text, + }, + }); +}; + +const postInfo = (text) => { + browser.runtime.sendMessage({ + type: messages.CONSOLE_FRAME_MESSAGE, + message: { + type: messages.CONSOLE_SHOW_INFO, + text, + }, + }); +}; + +export { initialize, blur, postError, postInfo }; |