From 27cdd9f9a562e88da90f8e0644ad13ced7c6ae2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Tue, 11 Oct 2022 19:48:57 +0200 Subject: [PATCH] code fixes --- src/discordpage.cpp | 12 +++++++----- src/discordpage.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/discordpage.cpp b/src/discordpage.cpp index 325dd37..d3a8008 100644 --- a/src/discordpage.cpp +++ b/src/discordpage.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,8 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) { setUrl(QUrl("https://discord.com/app")); injectScriptFile("userscript.js", ":/assets/userscript.js"); + injectScriptUrl("vencord.js", "https://github.com/Vendicated/Vencord/" + "releases/download/devbuild/browser.js"); injectScriptText("version.js", QString("window.discordScreenaudioVersion = '%1';") @@ -128,14 +131,13 @@ void DiscordPage::injectScriptText(QString name, QString content) { } void DiscordPage::injectScriptFile(QString name, QString source) { - QFile userscript(source); + QFile file(source); - if (!userscript.open(QIODevice::ReadOnly)) { + if (!file.open(QIODevice::ReadOnly)) { qFatal("Failed to load %s with error: %s", source.toLatin1().constData(), - userscript.errorString().toLatin1().constData()); + file.errorString().toLatin1().constData()); } else { - QByteArray userscriptJs = userscript.readAll(); - injectScriptText(name, userscriptJs); + injectScriptText(name, file.readAll()); } } diff --git a/src/discordpage.h b/src/discordpage.h index 071f744..ee1b2ba 100644 --- a/src/discordpage.h +++ b/src/discordpage.h @@ -37,8 +37,8 @@ private: javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override; - void injectScriptText(QString name, QString source); - void injectScriptFile(QString name, QString content); + void injectScriptText(QString name, QString content); + void injectScriptFile(QString name, QString source); void stopVirtmic(); void startVirtmic(QString target); void toggleMute();