Skip to content

Instantly share code, notes, and snippets.

@BoYanZh
Last active July 2, 2025 04:47
Show Gist options
  • Select an option

  • Save BoYanZh/6f0acf14af33c363eba96fba6c85679f to your computer and use it in GitHub Desktop.

Select an option

Save BoYanZh/6f0acf14af33c363eba96fba6c85679f to your computer and use it in GitHub Desktop.
Injector for RevengeOnGoldDiggers.exe
// Modified from: https://www.52pojie.cn/thread-2040975-1-1.html
// To use it, replace the content of this file: RevengeOnGoldDiggers/resources/app/src/main.loader.js
// Change the last line to `require(path.join(__dirname, './bin/main-darwin-' + arch + '.jsc'));` if you are using MacOS
// Shortcut keys: Z = Switch preset speed, X/C = -/+ 1.0x speed, V = 2x speed, ←/→ = rewind/forward
require('bytenode');
const path = require('node:path');
const arch = process.arch;
const { app } = require('electron');
app.commandLine.appendSwitch('remote-debugging-port', '9222');
app.commandLine.appendSwitch('remote-allow-origins', '*');
const injectionScript = `(${function () {
(function () {
let rateList = [1.0, 2.0, 3.0, 4.0, 5.0];
let currentRateIndex = 0;
let currentRate = rateList[currentRateIndex];
const infoPanel = document.createElement('div');
infoPanel.style.position = 'fixed';
infoPanel.style.top = '10px';
infoPanel.style.right = '10px';
infoPanel.style.background = 'rgba(0, 0, 0, 0.5)';
infoPanel.style.color = 'white';
infoPanel.style.padding = '6px 12px';
infoPanel.style.borderRadius = '6px';
infoPanel.style.fontSize = '14px';
infoPanel.style.fontFamily = 'monospace';
infoPanel.style.zIndex = 999999;
infoPanel.style.whiteSpace = 'pre';
document.body.appendChild(infoPanel);
function formatTime(seconds) {
if (isNaN(seconds) || !isFinite(seconds)) return '--:--';
const m = Math.floor(seconds / 60).toString().padStart(2, '0');
const s = Math.floor(seconds % 60).toString().padStart(2, '0');
return `${m}:${s}`;
}
const toast = document.createElement('div');
toast.style.position = 'fixed';
toast.style.top = '10px';
toast.style.left = '50%';
toast.style.transform = 'translateX(-50%)';
toast.style.background = 'rgba(0, 0, 0, 0.5)';
toast.style.color = 'white';
toast.style.padding = '6px 12px';
toast.style.borderRadius = '6px';
toast.style.fontSize = '14px';
toast.style.fontFamily = 'monospace';
toast.style.zIndex = 999999;
toast.style.transition = 'opacity 0.3s ease';
toast.style.opacity = '0';
toast.innerText = '';
document.body.appendChild(toast);
function showToast(message) {
toast.innerText = message;
toast.style.opacity = '1';
clearTimeout(toast._timeout);
toast._timeout = setTimeout(() => {
toast.style.opacity = '0';
}, 1500);
}
function getPlayingVideo() {
const videos = document.querySelectorAll('.--player-video-root video');
for (const video of videos) {
const style = getComputedStyle(video);
if (style.opacity === '1' && style.zIndex === '-10000') {
return video;
}
}
return null;
}
setInterval(() => {
const video = getPlayingVideo();
if (video) {
if (video.playbackRate !== currentRate) {
video.playbackRate = currentRate;
}
infoPanel.innerText = `${formatTime(video.currentTime)} / ${formatTime(video.duration)}\n${currentRate.toFixed(1)}x`;
} else {
infoPanel.innerText = ``;
}
}, 1000);
document.addEventListener('keydown', (e) => {
const video = getPlayingVideo();
if (!video) return;
const key = e.key.toLowerCase();
if (key === 'arrowleft') {
video.currentTime = Math.max(0, video.currentTime - 5);
showToast(`⏪ 5s:${formatTime(video.currentTime)}`);
} else if (key === 'arrowright') {
video.currentTime = Math.min(video.duration, video.currentTime + 5);
showToast(`⏩ 5s:${formatTime(video.currentTime)}`);
} else if (key === 'z') {
currentRateIndex = (currentRateIndex + 1) % rateList.length;
currentRate = rateList[currentRateIndex];
video.playbackRate = currentRate;
showToast(`${currentRate.toFixed(1)}x`);
} else if (key === 'x') {
let newRate = Math.max(1.0, parseFloat((currentRate - 1.0).toFixed(1)));
currentRate = newRate;
video.playbackRate = currentRate;
showToast(`${currentRate.toFixed(1)}x`);
} else if (key === 'c') {
let newRate = Math.min(16, parseFloat((currentRate + 1.0).toFixed(1)));
currentRate = newRate;
video.playbackRate = currentRate;
showToast(`${currentRate.toFixed(1)}x`);
} else if (key === 'v') {
currentRate = 2.0;
video.playbackRate = currentRate;
showToast(`${currentRate.toFixed(1)}x`);
}
});
})();
}})()`;
app.on('web-contents-created', (event, contents) => {
contents.on('did-finish-load', () => {
contents.executeJavaScript(injectionScript)
.then(() => console.log('[injector] successful'))
.catch(err => console.error('[injector] failed', err));
});
});
require(path.join(__dirname, './bin/main-win32-' + arch + '.jsc'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment