Skip to content

Commit

Permalink
fix: wip move to crowser
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Oct 20, 2024
1 parent f994142 commit e80ee91
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 667 deletions.
430 changes: 342 additions & 88 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ strip = "debuginfo"

[dependencies]
chrono = { version = "0.4.34", no-default-features = true }
crowser = "0.4.0"
dialog = "0.3.0"
dirs = "5.0.1"
notify-rust = { version = "4.10.0", no-default-features = true }
phf = { version = "0.11.2", features = [ "macros" ] }
reqwest = { version = "0.11.24", features = [ "blocking" ] }
rsrpc = { git = "https://github.com/SpikeHD/rsRPC.git", branch = "0.11.0"}
rsrpc = { git = "https://github.com/SpikeHD/rsRPC.git", tag = "v0.16.4"}
serde = { version = "1.0.196", features = [ "derive" ] }
serde_json = "1.0.113"
simple-websockets = "0.1.6"
sysinfo = "0.30.5"
webui-rs = { git = "https://github.com/SpikeHD/rust-webui", branch = "ext" }
window_titles = { git = "https://github.com/SpikeHD/window_titles.git" }
7 changes: 0 additions & 7 deletions build.rs

This file was deleted.

59 changes: 4 additions & 55 deletions ext/mv2/flooed.js → ext/flooed.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
class FlooedApi {
ws = null;
version = null;
commandsWaiting = {};
commandIdx = 0;
shouldShowUnreadBadge = false;

util = {
Expand All @@ -26,50 +23,10 @@ class FlooedApi {
applyNotificationCount: () => {}
}

constructor() {
this.ws = new WebSocket("ws://127.0.0.1:10102");

this.ws.onmessage = (event) => {
try {
const data = JSON.parse(event.data);
console.log('[Flooed] Received message: ', data)

if (data.command === 'response') {
if (this.commandsWaiting[data.id]) {
try {
// For compat reasons, config must stay a string
if (!JSON.parse(data.data).client_type) {
data.data = JSON.parse(data.data)
}
} catch (e) {}

this.commandsWaiting[data.id](data.data);
delete this.commandsWaiting[data.id];
}
}
} catch (e) {
console.error('[Flooed] Command failed: ', e)
}
}
}
constructor() {}

async invoke(command, data) {
// Ensure we wait for WS to be open
while (this.ws.readyState !== WebSocket.OPEN) {
console.log('[Flooed] Waiting for WS to be open...')
await new Promise(setTimeout);
}

const idx = this.commandIdx++

console.log('[Flooed] Sending command: ', command)

this.ws.send(JSON.stringify({ command, data, id: idx }));

// Wait for response
return await new Promise((resolve) => {
this.commandsWaiting[idx] = resolve;
});
return window.__CROWSER.ipc.invoke(command, data)
}
}

Expand Down Expand Up @@ -113,14 +70,14 @@ async function init() {
console.log('[Flooed] Injecting...')

// Then we define window.Flooed
scriptTagExec(`
eval(`
${FlooedApi.toString()}
;(${init.toString()})()
`)

// Recreate localStorage
console.log('[Create LocalStorage] Injecting...')
scriptTagExec(`
eval(`
const iframe = document.createElement('iframe')
// Wait for document.head to exist, then append the iframe
Expand All @@ -143,11 +100,3 @@ async function init() {

await ensurePlugins();
})()

async function scriptTagExec(script) {
const scriptTag = document.createElement("script");
scriptTag.textContent = script;

while (!document.head) await new Promise(setTimeout);
document.head.append(scriptTag);
}
18 changes: 0 additions & 18 deletions ext/mv2/background.js

This file was deleted.

39 changes: 0 additions & 39 deletions ext/mv2/content.js

This file was deleted.

40 changes: 0 additions & 40 deletions ext/mv2/flooed_after.js

This file was deleted.

36 changes: 0 additions & 36 deletions ext/mv2/manifest.json

This file was deleted.

5 changes: 0 additions & 5 deletions ext/mv2/package.json

This file was deleted.

8 changes: 6 additions & 2 deletions src/extra/client_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ pub struct ClientMod {
}

pub static CLIENT_MODS: phf::Map<&'static str, ClientMod> = phf_map! {
"Shelter" => ClientMod {
script: "https://raw.githubusercontent.com/uwu/shelter-builds/main/shelter.js",
styles: "https://raw.githubusercontent.com/uwu/shelter-builds/main/shelter.css",
},
"Vencord" => ClientMod {
script: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js",
styles: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.css",
script: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js",
styles: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.css",
},
};

Expand Down
Loading

0 comments on commit e80ee91

Please sign in to comment.