This commit is contained in:
2025-10-17 20:56:50 +08:00
commit 90094ccd5a
342 changed files with 144988 additions and 0 deletions

40
tampermonkey-emulator.js Normal file
View File

@@ -0,0 +1,40 @@
// tampermonkey-emulator.js
// 模拟 GM_addStyle
window.GM_addStyle = function(css) {
const style = document.createElement('style');
style.textContent = css;
document.head.appendChild(style);
};
// 模拟 GM_xmlhttpRequest
window.GM_xmlhttpRequest = function(opts) {
fetch(opts.url, {
method: opts.method || 'GET',
headers: opts.headers || {},
body: opts.data || null,
mode: 'cors',
credentials: 'include'
}).then(res => res.text()).then(text => {
if (opts.onload) opts.onload({ status: 200, responseText: text });
}).catch(err => {
if (opts.onerror) opts.onerror(err);
});
};
// 模拟 unsafeWindow直接指向 window
window.unsafeWindow = window;
// 模拟 @run-at document-end
function runUserScript1() {
// 这里动态加载原始脚本
const script = document.createElement('script');
script.src = '/auto.js'; // 原始脚本,不改
document.head.appendChild(script);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', runUserScript1);
} else {
runUserScript1();
}