Compare commits
9 Commits
latest
...
dependency
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e939c4592 | ||
|
|
27faed4a3a | ||
|
|
10fff86ca4 | ||
|
|
87e84dec5c | ||
|
|
4b782133ae | ||
|
|
423884ae0c | ||
|
|
7ea3d0aab1 | ||
|
|
18b15f5cf4 | ||
|
|
3540774c82 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/build
|
/build
|
||||||
.vscode
|
.vscode
|
||||||
|
/submodules/arrpc
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ set(discord-screenaudio_SRC
|
|||||||
src/log.cpp
|
src/log.cpp
|
||||||
src/userscript.cpp
|
src/userscript.cpp
|
||||||
src/centralwidget.cpp
|
src/centralwidget.cpp
|
||||||
|
src/dependencycheck.cpp
|
||||||
resources.qrc
|
resources.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
1
assets/arrpc.js
Normal file
1
assets/arrpc.js
Normal file
File diff suppressed because one or more lines are too long
1
assets/arrpc_bridge_mod.js
Normal file
1
assets/arrpc_bridge_mod.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
setTimeout((i=>{let t,a,s,e={};new WebSocket("ws://127.0.0.1:1337").onmessage=async i=>{if(msg=JSON.parse(i.data),console.log(msg),!t){const i=window.webpackChunkdiscord_app.push([[Symbol()],{},i=>i]),e=i.c;window.webpackChunkdiscord_app.pop();for(const i in e){let a=e[i].exports;if(a=a&&(a.Z??a.ZP),a&&a.register&&a.wait){t=a;break}}const n=i.m;for(const t in n)if(n[t].toString().includes("getAssetImage: size must === [number, number] for Twitch")){const s=i(t),e=Object.values(s).find((i=>"function"==typeof i&&i.toString().includes("apply(")));a=async(i,t)=>(await e(i,[t,void 0]))[0];break}for(const t in n)if(n[t].toString().includes("e.application={")){const a=i(t),e=Object.values(a).find((i=>"function"==typeof i&&i.toString().includes("e.application={")));s=async i=>{let t={};return await e(t,i),t.application};break}}if(msg.activity?.assets?.large_image&&(msg.activity.assets.large_image=await a(msg.activity.application_id,msg.activity.assets.large_image)),msg.activity?.assets?.small_image&&(msg.activity.assets.small_image=await a(msg.activity.application_id,msg.activity.assets.small_image)),msg.activity){const i=msg.activity.application_id;e[i]||(e[i]=await s(i));const t=e[i];msg.activity.name||(msg.activity.name=t.name)}t.dispatch({type:"LOCAL_ACTIVITY_UPDATE",...msg})}}),1e4);
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
setTimeout(e => {
|
|
||||||
let Dispatcher, lookupAsset, lookupApp, apps = {};
|
|
||||||
|
|
||||||
const ws = new WebSocket('ws://127.0.0.1:1337'); // connect to arRPC bridge websocket
|
|
||||||
ws.onmessage = async x => {
|
|
||||||
msg = JSON.parse(x.data);
|
|
||||||
console.log(msg);
|
|
||||||
|
|
||||||
if (!Dispatcher) {
|
|
||||||
const wpRequire = window.webpackChunkdiscord_app.push([[Symbol()], {}, x => x]);
|
|
||||||
const cache = wpRequire.c;
|
|
||||||
window.webpackChunkdiscord_app.pop();
|
|
||||||
|
|
||||||
for (const id in cache) {
|
|
||||||
let mod = cache[id].exports;
|
|
||||||
mod = mod && (mod.Z ?? mod.ZP);
|
|
||||||
|
|
||||||
if (mod && mod.register && mod.wait) {
|
|
||||||
Dispatcher = mod;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const factories = wpRequire.m;
|
|
||||||
for (const id in factories) {
|
|
||||||
if (factories[id].toString().includes('getAssetImage: size must === [number, number] for Twitch')) {
|
|
||||||
const mod = wpRequire(id);
|
|
||||||
|
|
||||||
const _lookupAsset = Object.values(mod).find(e => typeof e === "function" && e.toString().includes("apply("));
|
|
||||||
lookupAsset = async (appId, name) => (await _lookupAsset(appId, [name, undefined]))[0];
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const id in factories) {
|
|
||||||
if (factories[id].toString().includes(`e.application={`)) {
|
|
||||||
const mod = wpRequire(id);
|
|
||||||
|
|
||||||
const _lookupApp = Object.values(mod).find(e => typeof e === "function" && e.toString().includes(`e.application={`));
|
|
||||||
lookupApp = async appId => {
|
|
||||||
let socket = {};
|
|
||||||
await _lookupApp(socket, appId);
|
|
||||||
return socket.application;
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg.activity?.assets?.large_image) msg.activity.assets.large_image = await lookupAsset(msg.activity.application_id, msg.activity.assets.large_image);
|
|
||||||
if (msg.activity?.assets?.small_image) msg.activity.assets.small_image = await lookupAsset(msg.activity.application_id, msg.activity.assets.small_image);
|
|
||||||
|
|
||||||
if (msg.activity) {
|
|
||||||
const appId = msg.activity.application_id;
|
|
||||||
if (!apps[appId]) apps[appId] = await lookupApp(appId);
|
|
||||||
|
|
||||||
const app = apps[appId];
|
|
||||||
if (!msg.activity.name) msg.activity.name = app.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", ...msg }); // set RPC status
|
|
||||||
};
|
|
||||||
}, 10000)
|
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource>
|
<qresource>
|
||||||
<file>assets/userscript.js</file>
|
<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>
|
<file>assets/de.shorsh.discord-screenaudio.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
36
scripts/build_arrpc.sh
Executable file
36
scripts/build_arrpc.sh
Executable file
@@ -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 -m src/index.js
|
||||||
|
|
||||||
|
echo_status "Copying built file"
|
||||||
|
cp -v ./dist/index.js ../../assets/arrpc.js
|
||||||
10
src/dependencycheck.cpp
Normal file
10
src/dependencycheck.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "dependencycheck.h"
|
||||||
|
#include "pipewire-0.3/pipewire/version.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
void checkDependencies() {
|
||||||
|
QString versionPipewire(pw_get_library_version());
|
||||||
|
QMessageBox::information(nullptr, "Dependency Check",
|
||||||
|
QString("Pipewire: v%1").arg(versionPipewire));
|
||||||
|
}
|
||||||
3
src/dependencycheck.h
Normal file
3
src/dependencycheck.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void checkDependencies();
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
#include <QTemporaryFile>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWebChannel>
|
#include <QWebChannel>
|
||||||
#include <QWebEngineScript>
|
#include <QWebEngineScript>
|
||||||
@@ -35,11 +36,9 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
|
|||||||
|
|
||||||
injectFile(&DiscordPage::injectScript, "userscript.js",
|
injectFile(&DiscordPage::injectScript, "userscript.js",
|
||||||
":/assets/userscript.js");
|
":/assets/userscript.js");
|
||||||
|
|
||||||
injectFile(&DiscordPage::injectScript, "bridge_mod.js",
|
|
||||||
":/assets/bridge_mod.js");
|
|
||||||
|
|
||||||
setupUserStyles();
|
setupUserStyles();
|
||||||
|
setupArrpc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiscordPage::setupPermissions() {
|
void DiscordPage::setupPermissions() {
|
||||||
@@ -294,3 +293,19 @@ void DiscordPage::javaScriptConsoleMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
UserScript *DiscordPage::userScript() { return &m_userScript; }
|
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 <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QProcess>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QWebEngineFullScreenRequest>
|
#include <QWebEngineFullScreenRequest>
|
||||||
#include <QWebEnginePage>
|
#include <QWebEnginePage>
|
||||||
@@ -22,10 +23,12 @@ private:
|
|||||||
QFile *m_userStylesFile;
|
QFile *m_userStylesFile;
|
||||||
QString m_userStylesContent;
|
QString m_userStylesContent;
|
||||||
QNetworkAccessManager m_networkAccessManager;
|
QNetworkAccessManager m_networkAccessManager;
|
||||||
|
QProcess m_arrpcProcess;
|
||||||
const QDir m_configLocation =
|
const QDir m_configLocation =
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||||
void setupPermissions();
|
void setupPermissions();
|
||||||
void setupUserStyles();
|
void setupUserStyles();
|
||||||
|
void setupArrpc();
|
||||||
void fetchUserStyles();
|
void fetchUserStyles();
|
||||||
bool acceptNavigationRequest(const QUrl &url,
|
bool acceptNavigationRequest(const QUrl &url,
|
||||||
QWebEnginePage::NavigationType type,
|
QWebEnginePage::NavigationType type,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "dependencycheck.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "virtmic.h"
|
#include "virtmic.h"
|
||||||
|
|
||||||
@@ -49,6 +50,8 @@ int main(int argc, char *argv[]) {
|
|||||||
"--remote-debugging-port=9222 " +
|
"--remote-debugging-port=9222 " +
|
||||||
qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
||||||
|
|
||||||
|
checkDependencies();
|
||||||
|
|
||||||
MainWindow w(parser.isSet(notifySendOption));
|
MainWindow w(parser.isSet(notifySendOption));
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ MainWindow::MainWindow(bool useNotifySend, QWidget *parent)
|
|||||||
m_centralWidget = new CentralWidget(this);
|
m_centralWidget = new CentralWidget(this);
|
||||||
setCentralWidget(m_centralWidget);
|
setCentralWidget(m_centralWidget);
|
||||||
setupTrayIcon();
|
setupTrayIcon();
|
||||||
|
setMinimumSize(800, 300);
|
||||||
if (m_settings->contains("geometry")) {
|
if (m_settings->contains("geometry")) {
|
||||||
restoreGeometry(m_settings->value("geometry").toByteArray());
|
restoreGeometry(m_settings->value("geometry").toByteArray());
|
||||||
} else {
|
} else {
|
||||||
@@ -99,7 +100,8 @@ void MainWindow::cleanTrayIcon() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupSettings() {
|
void MainWindow::setupSettings() {
|
||||||
m_settings = new QSettings("maltejur", "discord-screenaudio", this);
|
m_settings =
|
||||||
|
new QSettings("discord-screenaudio", "discord-screenaudio", this);
|
||||||
m_settings->beginGroup("settings");
|
m_settings->beginGroup("settings");
|
||||||
m_settings->endGroup();
|
m_settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user