Merge branch 'arrpc'
This commit is contained in:
commit
4b782133ae
|
@ -1,2 +1,3 @@
|
|||
/build
|
||||
.vscode
|
||||
/submodules/arrpc
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,8 @@
|
|||
<RCC>
|
||||
<qresource>
|
||||
<file>assets/userscript.js</file>
|
||||
<file>assets/bridge_mod.js</file>
|
||||
<file>assets/arrpc_bridge_mod.js</file>
|
||||
<file>assets/arrpc.js</file>
|
||||
<file>assets/de.shorsh.discord-screenaudio.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/bash
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/../submodules"
|
||||
|
||||
echo_status() {
|
||||
echo
|
||||
echo
|
||||
echo "-> $1..."
|
||||
}
|
||||
|
||||
if [ ! -d "arrpc" ]; then
|
||||
echo_status "Cloning arRPC"
|
||||
git clone https://github.com/OpenAsar/arrpc.git
|
||||
cd arrpc
|
||||
else
|
||||
echo_status "Fetching arRPC changes"
|
||||
cd arrpc
|
||||
git fetch
|
||||
fi
|
||||
|
||||
echo_status "Checking out latest commit"
|
||||
git reset --hard HEAD
|
||||
git checkout main
|
||||
|
||||
echo_status "Installing dependencies"
|
||||
pnpm i -D @vercel/ncc
|
||||
|
||||
echo_status "Patching arRPC"
|
||||
sed -i 's/"type": "module",//' package.json
|
||||
|
||||
echo_status "Building arRPC"
|
||||
pnpm exec ncc build src/index.js
|
||||
|
||||
echo_status "Copying built file"
|
||||
cp -v ./dist/index.js ../../assets/arrpc.js
|
|
@ -9,6 +9,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkReply>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTimer>
|
||||
#include <QWebChannel>
|
||||
#include <QWebEngineScript>
|
||||
|
@ -36,10 +37,8 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
|
|||
injectFile(&DiscordPage::injectScript, "userscript.js",
|
||||
":/assets/userscript.js");
|
||||
|
||||
injectFile(&DiscordPage::injectScript, "bridge_mod.js",
|
||||
":/assets/bridge_mod.js");
|
||||
|
||||
setupUserStyles();
|
||||
setupArrpc();
|
||||
}
|
||||
|
||||
void DiscordPage::setupPermissions() {
|
||||
|
@ -294,3 +293,19 @@ void DiscordPage::javaScriptConsoleMessage(
|
|||
}
|
||||
|
||||
UserScript *DiscordPage::userScript() { return &m_userScript; }
|
||||
|
||||
void DiscordPage::setupArrpc() {
|
||||
QFile nodejs("/usr/bin/node");
|
||||
if (nodejs.exists()) {
|
||||
auto arrpcSource = QTemporaryFile::createNativeFile(":/assets/arrpc.js");
|
||||
qDebug(mainLog).noquote()
|
||||
<< "NodeJS found, starting arRPC located at" << arrpcSource->fileName();
|
||||
m_arrpcProcess.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
m_arrpcProcess.setProgram(nodejs.fileName());
|
||||
m_arrpcProcess.setArguments(QStringList{arrpcSource->fileName()});
|
||||
m_arrpcProcess.start();
|
||||
|
||||
injectFile(&DiscordPage::injectScript, "arrpc_bridge_mod.js",
|
||||
":/assets/arrpc_bridge_mod.js");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QWebEngineFullScreenRequest>
|
||||
#include <QWebEnginePage>
|
||||
|
@ -22,10 +23,12 @@ private:
|
|||
QFile *m_userStylesFile;
|
||||
QString m_userStylesContent;
|
||||
QNetworkAccessManager m_networkAccessManager;
|
||||
QProcess m_arrpcProcess;
|
||||
const QDir m_configLocation =
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
void setupPermissions();
|
||||
void setupUserStyles();
|
||||
void setupArrpc();
|
||||
void fetchUserStyles();
|
||||
bool acceptNavigationRequest(const QUrl &url,
|
||||
QWebEnginePage::NavigationType type,
|
||||
|
|
Loading…
Reference in New Issue