2026-10-30 14:31:15 +08:00

22 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var report={startedAt:new Date().toISOString(),stopped:[]};
var output='/sdcard/Download/douyin-watch-budget-restart.json';
function save(){files.write(output,JSON.stringify(report));}
try {
var others=engines.all().filter(function(e){return e.id!==engines.myEngine().id;});
if(others.some(function(e){return !/\/douyin-lite\.js$/.test(String(e.getSource()));}))throw new Error('其他应用脚本仍在运行');
others.forEach(function(e){report.stopped.push({id:e.id,source:String(e.getSource())});e.forceStop();});save();
var deadline=Date.now()+7000;
while(engines.all().some(function(e){return report.stopped.some(function(o){return o.id===e.id;});})&&Date.now()<deadline)sleep(100);
if(engines.all().some(function(e){return report.stopped.some(function(o){return o.id===e.id;});}))throw new Error('旧抖音脚本尚未退出');
eval(files.read('/sdcard/脚本/抖音极速/douyin-lite.js').split('// MAIN:')[0]);
if(!files.exists(CONFIG.videoBatchPath)) {
var seed=JSON.parse(files.read('/sdcard/Download/douyin-video-batch-migration.json'));
if(seed.day!==videoTaskDay())throw new Error('迁移的观看计划已经跨日,取消迁移');
saveVideoBatchState(seed);report.migrated=true;
}else report.reusedExistingBudget=true;
var state=readVideoBatchState();
report.batch=state.batch;report.msPerCoin=state.msPerCoin;save();
engines.execScriptFile('/sdcard/脚本/抖音极速/douyin-lite.js',{path:'/sdcard/脚本/抖音极速/'});
report.restartedAt=new Date().toISOString();save();
}catch(e){report.error=String(e);report.stack=String(e.stack);save();throw e;}