From 76a63a57dc03ac82f4d525a5b8b57a86f85ca680 Mon Sep 17 00:00:00 2001 From: Tee Date: Fri, 4 Feb 2022 22:56:01 +0100 Subject: [PATCH] reload feature --- discord rpc/html/settings.html | 2 +- discord rpc/js/index-noload.js | 10 +--------- discord rpc/js/index-other.js | 2 +- discord rpc/js/index.js | 3 ++- discord rpc/js/main.js | 24 ++++++++++++------------ discord rpc/js/settings.js | 4 ++++ discord rpc/package.json | 2 +- discord rpc/package.json.bak | 19 +++++++++++++++++++ 8 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 discord rpc/package.json.bak diff --git a/discord rpc/html/settings.html b/discord rpc/html/settings.html index 58320ca..c1c1504 100644 --- a/discord rpc/html/settings.html +++ b/discord rpc/html/settings.html @@ -20,7 +20,7 @@

RPC Settings

- +

Update Extension

Loading...

diff --git a/discord rpc/js/index-noload.js b/discord rpc/js/index-noload.js index 1c9a8ef..9f98291 100644 --- a/discord rpc/js/index-noload.js +++ b/discord rpc/js/index-noload.js @@ -22,14 +22,6 @@ var smallImage_enable = true; var timestamp_enable = true; var enabled_enable = true; -function loadJSX(fileName) { - var csInterface = new CSInterface(); - var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/host/"; - csInterface.evalScript('$.evalFile("' + extensionRoot + fileName + '")'); - console.log(fileName); - console.log(extensionRoot); -} - client.on('ready', () => { send(); }) @@ -40,7 +32,7 @@ client.login({ getData(); -csInterface.addEventListener('com.tee.discordrpc.restart', function(){ +csInterface.addEventListener('com.discordrpc.restart', function(){ window.location.reload(); }); diff --git a/discord rpc/js/index-other.js b/discord rpc/js/index-other.js index b7af005..92921be 100644 --- a/discord rpc/js/index-other.js +++ b/discord rpc/js/index-other.js @@ -41,7 +41,7 @@ client.login({ loadJSX(appID + ".jsx"); getData(); -csInterface.addEventListener('com.tee.discordrpc.restart', function(){ +csInterface.addEventListener('com.discordrpc.restart', function(){ window.location.reload(); }); diff --git a/discord rpc/js/index.js b/discord rpc/js/index.js index d5f92ba..e19af90 100644 --- a/discord rpc/js/index.js +++ b/discord rpc/js/index.js @@ -41,7 +41,8 @@ client.login({ loadJSX(appID + ".jsx"); getData(); -csInterface.addEventListener('com.tee.discordrpc.restart', function(){ +csInterface.addEventListener('com.discordrpc.restart', function(){ + client.destroy(); window.location.reload(); }); diff --git a/discord rpc/js/main.js b/discord rpc/js/main.js index fe9f7d4..15b8bd1 100644 --- a/discord rpc/js/main.js +++ b/discord rpc/js/main.js @@ -1,14 +1,14 @@ -var csInterface = new CSInterface(); - -if(csInterface.getApplicationID() === "DRWV"){ - csInterface.requestOpenExtension("com.tee.discordrpc.other.dreamweaver"); -} +// gonna rewrite this sphagetti in future -console.log(csInterface.getApplicationID()) +var csInterface = new CSInterface(); -if(csInterface.getApplicationID() === "FLPR"){ - console.log("request open") - csInterface.requestOpenExtension("com.tee.discordrpc.other.animate"); +switch(csInterface.getApplicationID()){ + case "DRWV": + csInterface.requestOpenExtension("com.tee.discordrpc.other.dreamweaver"); + break; + case "FLPR": + csInterface.requestOpenExtension("com.tee.discordrpc.other.animate"); + break; } var i = 0 @@ -31,7 +31,7 @@ document.getElementById("settings").onclick = function () { csInterface.requestOpenExtension("com.tee.discordrpc.settings"); } -csInterface.addEventListener('com.tee.discordrpc.restart', function(){ +csInterface.addEventListener('com.discordrpc.restart', function(){ window.location.reload(); }); @@ -92,7 +92,7 @@ $(document).ready(function () { document.getElementById("_details").style.display = "block" document.getElementById("_state").style.display = "block" document.getElementById("_timestamp").style.display = "block" - } catch (err) { + } catch { } }); @@ -105,7 +105,7 @@ $(document).ready(function () { setInterval(() => { try { document.getElementById("_timestamp").innerHTML = `${format(i++)} elapsed` - } catch (err) { + } catch { } diff --git a/discord rpc/js/settings.js b/discord rpc/js/settings.js index b93a208..e2d2b0d 100644 --- a/discord rpc/js/settings.js +++ b/discord rpc/js/settings.js @@ -4,6 +4,10 @@ const Shell = require('node-powershell'); var restart_event = new CSEvent("com.discordrpc.restart", "APPLICATION"); +csInterface.addEventListener('com.discordrpc.restart', function(){ + window.location.reload(); +}); + function restart(){ csInterface.dispatchEvent(restart_event); window.location.reload(); diff --git a/discord rpc/package.json b/discord rpc/package.json index 6a5a37c..19b8d13 100644 --- a/discord rpc/package.json +++ b/discord rpc/package.json @@ -1,6 +1,6 @@ { "name": "discord-rpc", - "version": "v0.0.4.1-beta", + "version": "v0.0.4.2-beta", "description": "", "main": "index.js", "directories": { diff --git a/discord rpc/package.json.bak b/discord rpc/package.json.bak new file mode 100644 index 0000000..6a5a37c --- /dev/null +++ b/discord rpc/package.json.bak @@ -0,0 +1,19 @@ +{ + "name": "discord-rpc", + "version": "v0.0.4.1-beta", + "description": "", + "main": "index.js", + "directories": { + "lib": "lib" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Tee", + "license": "ISC", + "dependencies": { + "axios": "^0.21.1", + "discord-rpc": "^3.1.4", + "node-powershell": "^4.0.0" + } +}