Skip to content

Instantly share code, notes, and snippets.

@easrng
Created February 15, 2025 07:56
Show Gist options
  • Save easrng/776485b1eb1a1e4e19e637fceba0a155 to your computer and use it in GitHub Desktop.
Save easrng/776485b1eb1a1e4e19e637fceba0a155 to your computer and use it in GitHub Desktop.
load custom css or whatever into signal-desktop
#!/bin/sh
SELF="$(dirname "$(realpath "$0")")"
cc -x c - -shared -o "$SELF/uwu.node" -fPIC -Oz -static -nostdlib <<'EOF'
#include "stddef.h"
int napi_create_string_latin1(void *env, const char *str, size_t length,
void **result);
int napi_run_script(void *env, void *script, void **result);
void uwu_injecting_time(void *ptr) {
void *result;
char js[] = "process.getBuiltinModule('module').createRequire(process.cwd()+'"
"/dummy')(process.env.UWU_INJECT)";
int status = napi_create_string_latin1(ptr, js, sizeof(js) - 1, &result);
if (status) {
// printf("unexpected status creating string: %d\n", status);
return;
}
status = napi_run_script(ptr, result, &result);
if (status) {
// printf("unexpected status running js: %d\n", status);
return;
}
// printf("ran code\n");
}
EOF
cat >"$SELF/uwu.cjs" <<'EOF'
const { app, protocol, net } = require('electron');
app.on('ready', () => {
protocol.handle('file', async (req) => {
const url = req.url;
const real = await net.fetch(url, { bypassCustomProtocolHandlers: true });
if (url.endsWith("/manifest.css")) {
return new Response((await real.text()) + '\nbody{font-family:system-ui,sans-serif!important}', {headers: real.headers});
}
return real;
});
});
EOF
SIGNAL_PATH="$(command -v signal-desktop)"
NIX_SIGNAL_PATH="$(dirname "$(dirname "$(realpath "$(command -v "$SIGNAL_PATH")")")")/lib/Signal/signal-desktop"
if [ -e "$NIX_SIGNAL_PATH" ]; then
SIGNAL_PATH="$NIX_SIGNAL_PATH"
fi
printf 'catch load @signalapp+libsignal-client.node\nrun\nbreak napi_register_module_v1\ncontinue\ncall ((void(*)())uwu_injecting_time)($rdi)\ndelete\ncontinue' | UWU_INJECT="$SELF/uwu.cjs" LD_PRELOAD="$SELF/uwu.node" gdb "$SIGNAL_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment