挂机方舟加速
本文作者为 @十面基米。
// ==UserScript==// @name 挂机方舟加速// @namespace http://tampermonkey.net/// @version 1.0// @description 对指定网站进行时间加速,默认50倍,可通过控制台 SpeedBoost.set(倍数) 调整// @author Yo...
// ==UserScript==
// @name 挂机方舟加速
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 对指定网站进行时间加速,默认50倍,可通过控制台 SpeedBoost.set(倍数) 调整
// @author You
// @match https://ccw23333-d4gjf2sxb7fd9c273-1252336446.tcloudbaseapp.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 防止重复注入
if (window.__speedBoostCore) {
window.__speedBoostCore.set(50);
return;
}
// 保存原始函数
const orig = {
Date: window.Date,
dateNow: Date.now,
perfNow: window.performance && window.performance.now ? window.performance.now.bind(window.performance) : null,
raf: window.requestAnimationFrame || window.webkitRequestAnimationFrame || null,
setTimeout: window.setTimeout,
setInterval: window.setInterval
};
// 状态
const S = {
speed: 50, // 默认50倍
active: true,
real0: orig.perfNow ? orig.perfNow() : orig.dateNow.call(orig.Date),
virt0: 0
};
S.virt0 = S.real0;
// 获取真实时间
const realNow = () => orig.perfNow ? orig.perfNow() : orig.dateNow.call(orig.Date);
// 计算虚拟时间
const virt = (realTs) => S.active ? S.virt0 + (realTs - S.real0) * S.speed : realTs;
// 计算日期偏移量
const dateOffset = () => {
if (!S.active) return 0;
const r = realNow();
return virt(r) - r;
};
// 设置速度
const setSpeed = (s) => {
const real = realNow();
S.virt0 = S.active ? virt(real) : real;
S.real0 = real;
S.speed = Math.max(0.1, Math.min(5000, s));
S.active = true;
};
// 劫持 performance.now
if (orig.perfNow) {
window.performance.now = () => virt(orig.perfNow());
}
// 劫持 Date
const MockDate = function(...args) {
if (args.length === 0 && S.active) {
return new orig.Date(orig.dateNow.call(orig.Date) + dateOffset());
}
return new orig.Date(...args);
};
MockDate.prototype = orig.Date.prototype;
MockDate.UTC = orig.Date.UTC;
MockDate.parse = orig.Date.parse;
MockDate.now = () => orig.dateNow.call(orig.Date) + dateOffset();
window.Date = MockDate;
// 劫持 requestAnimationFrame
if (orig.raf) {
const rafPolyfill = cb => orig.raf.call(window, realTs => cb(S.active ? virt(realTs) : realTs));
window.requestAnimationFrame = rafPolyfill;
if (window.webkitRequestAnimationFrame) window.webkitRequestAnimationFrame = rafPolyfill;
}
// 劫持 setTimeout / setInterval
window.setTimeout = (cb, delay, ...args) => orig.setTimeout.call(window, cb, S.active ? delay / S.speed : delay, ...args);
window.setInterval = (cb, delay, ...args) => orig.setInterval.call(window, cb, S.active ? delay / S.speed : delay, ...args);
// 暴露控制接口
const api = {
set: setSpeed,
reset: () => setSpeed(1)
};
window.__speedBoostCore = api;
window.SpeedBoost = api;
// 设置默认速度
setSpeed(50);
console.log('[SpeedBoost] 已启用 50x 加速,可通过 SpeedBoost.set(倍数) 调整');
})();











微信打赏支持
支付宝打赏支持