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 <QDesktopServices>
#include <QFile> #include <QFile>
#include <QMessageBox> #include <QMessageBox>
#include <QNetworkReply>
#include <QTimer> #include <QTimer>
#include <QWebChannel> #include <QWebChannel>
#include <QWebEngineScript> #include <QWebEngineScript>
@ -53,6 +54,8 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
setUrl(QUrl("https://discord.com/app")); setUrl(QUrl("https://discord.com/app"));
injectScriptFile("userscript.js", ":/assets/userscript.js"); injectScriptFile("userscript.js", ":/assets/userscript.js");
injectScriptUrl("vencord.js", "https://github.com/Vendicated/Vencord/"
"releases/download/devbuild/browser.js");
injectScriptText("version.js", injectScriptText("version.js",
QString("window.discordScreenaudioVersion = '%1';") QString("window.discordScreenaudioVersion = '%1';")
@ -128,14 +131,13 @@ void DiscordPage::injectScriptText(QString name, QString content) {
} }
void DiscordPage::injectScriptFile(QString name, QString source) { 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(), qFatal("Failed to load %s with error: %s", source.toLatin1().constData(),
userscript.errorString().toLatin1().constData()); file.errorString().toLatin1().constData());
} else { } else {
QByteArray userscriptJs = userscript.readAll(); injectScriptText(name, file.readAll());
injectScriptText(name, userscriptJs);
} }
} }

View File

@ -37,8 +37,8 @@ private:
javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level,
const QString &message, int lineNumber, const QString &message, int lineNumber,
const QString &sourceID) override; const QString &sourceID) override;
void injectScriptText(QString name, QString source); void injectScriptText(QString name, QString content);
void injectScriptFile(QString name, QString content); void injectScriptFile(QString name, QString source);
void stopVirtmic(); void stopVirtmic();
void startVirtmic(QString target); void startVirtmic(QString target);
void toggleMute(); void toggleMute();