code fixes

This commit is contained in:
Malte Jürgens 2022-10-11 19:48:57 +02:00
parent d184823ee9
commit 27cdd9f9a5
No known key found for this signature in database
GPG key ID: D29FBD5F93C0CFC3
2 changed files with 9 additions and 7 deletions

View file

@ -20,6 +20,7 @@
#include <QDesktopServices>
#include <QFile>
#include <QMessageBox>
#include <QNetworkReply>
#include <QTimer>
#include <QWebChannel>
#include <QWebEngineScript>
@ -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());
}
}

View file

@ -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();