diff --git a/browser_ext/background.js b/browser_ext/background.js index 0de07011..f4523055 100644 --- a/browser_ext/background.js +++ b/browser_ext/background.js @@ -10,6 +10,8 @@ const ignoredPages = { const appName = "com.chatterino.chatterino"; +let port; + function matchUrl(url) { if (!url) return; @@ -25,24 +27,21 @@ function matchUrl(url) { } } -var port = chrome.runtime.connectNative("com.chatterino.chatterino"); +function connectPort() { + let port = chrome.runtime.connectNative("com.chatterino.chatterino"); -port.onMessage.addListener(function(msg) { - console.log(msg); -}); -port.onDisconnect.addListener(function() { - console.log("Disconnected"); -}); -port.postMessage({ text: "Hello, my_application" }); + port.onMessage.addListener(function(msg) { + console.log(msg); + }); + port.onDisconnect.addListener(function() { + console.log("Disconnected"); + }); +} function selectChannel(channelName) { console.log(channelName); port.postMessage({channelName: channelName}); - - // chrome.runtime.sendNativeMessage(appName, { "xd": true }, (resp) => { - // console.log(resp); - // }) } /// add listeners diff --git a/src/singletons/nativemessagingmanager.cpp b/src/singletons/nativemessagingmanager.cpp index 742e306c..b674326b 100644 --- a/src/singletons/nativemessagingmanager.cpp +++ b/src/singletons/nativemessagingmanager.cpp @@ -10,6 +10,8 @@ #ifdef BOOSTLIBS #include + +namespace ipc = boost::interprocess; #endif #ifdef Q_OS_WIN @@ -21,8 +23,6 @@ #define EXTENSION_ID "aeicjepmjkgmbeohnchmpfjbpchogmjn" #define MESSAGE_SIZE 1024 -namespace ipc = boost::interprocess; - namespace chatterino { namespace singletons {