From 63b93ce1ca16e93563453e5caba451886fa3c01d Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 18 Nov 2018 18:47:35 +0900 Subject: Use webextension message to console --- src/content/console-frames.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/content/console-frames.js') diff --git a/src/content/console-frames.js b/src/content/console-frames.js index 0c0ec02..401765c 100644 --- a/src/content/console-frames.js +++ b/src/content/console-frames.js @@ -16,22 +16,23 @@ const blur = (doc) => { iframe.blur(); }; -const postMessage = (doc, message) => { - let iframe = doc.getElementById('vimvixen-console-frame'); - iframe.contentWindow.postMessage(JSON.stringify(message), '*'); -}; - -const postError = (doc, message) => { - return postMessage(doc, { - type: messages.CONSOLE_SHOW_ERROR, - text: message, +const postError = (text) => { + browser.runtime.sendMessage({ + type: messages.CONSOLE_FRAME_MESSAGE, + message: { + type: messages.CONSOLE_SHOW_ERROR, + text, + }, }); }; -const postInfo = (doc, message) => { - return postMessage(doc, { - type: messages.CONSOLE_SHOW_INFO, - text: message, +const postInfo = (text) => { + browser.runtime.sendMessage({ + type: messages.CONSOLE_FRAME_MESSAGE, + message: { + type: messages.CONSOLE_SHOW_INFO, + text, + }, }); }; -- cgit v1.2.3