From f25e52b2180bc090fcef2e2db75752a05c7720b5 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 7 Oct 2019 20:23:28 +0200 Subject: [PATCH] attach extension to opera/vivaldi or all windows --- src/singletons/Settings.hpp | 2 ++ src/widgets/AttachedWindow.cpp | 18 ++++++++++++------ src/widgets/settingspages/GeneralPage.cpp | 10 ++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index e6da2c291..82233f841 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -214,6 +214,8 @@ public: QStringSetting cachePath = {"/cache/path", ""}; BoolSetting restartOnCrash = {"/misc/restartOnCrash", false}; + BoolSetting attachExtensionToAnyProcess = { + "/misc/attachExtensionToAnyProcess", false}; /// Debug BoolSetting showUnhandledIrcMessages = {"/debug/showUnhandledIrcMessages", diff --git a/src/widgets/AttachedWindow.cpp b/src/widgets/AttachedWindow.cpp index 155741df1..9e10f50dc 100644 --- a/src/widgets/AttachedWindow.cpp +++ b/src/widgets/AttachedWindow.cpp @@ -180,13 +180,19 @@ void AttachedWindow::attachToHwnd(void *_attachedPtr) QString qfilename = QString::fromWCharArray(filename.get(), int(filenameLength)); - if (!qfilename.endsWith("chrome.exe") && - !qfilename.endsWith("firefox.exe")) + if (!getSettings()->attachExtensionToAnyProcess) { - qDebug() << "NM Illegal caller" << qfilename; - this->timer_.stop(); - this->deleteLater(); - return; + // We don't attach to non-browser processes by default. + if (!qfilename.endsWith("chrome.exe") && + !qfilename.endsWith("firefox.exe") && + !qfilename.endsWith("vivaldi.exe") && + !qfilename.endsWith("opera.exe")) + { + qDebug() << "NM Illegal caller" << qfilename; + this->timer_.stop(); + this->deleteLater(); + return; + } } this->validProcessName_ = true; } diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 2a3f5a603..846aad040 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -439,10 +439,16 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addDescription("The browser extension replaces the default " "Twitch.tv chat with chatterino."); - layout.addDescription(formatRichNamedLink(CHROME_EXTENSION_LINK, - "Download for Google Chrome")); + layout.addDescription(formatRichNamedLink( + CHROME_EXTENSION_LINK, + "Download for Google Chrome and similar browsers.")); layout.addDescription( formatRichNamedLink(FIREFOX_EXTENSION_LINK, "Download for Firefox")); + + layout.addDescription("Chatterino only attaches to known browsers to avoid " + "attaching to other windows by accident."); + layout.addCheckbox("Attach to any browser (may cause issues).", + s.attachExtensionToAnyProcess); #endif layout.addTitle("Miscellaneous");