platform-codebase/features/dating-autopilot/codegen/controls.ts

28 lines
944 B
TypeScript
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Stop/pause control helpers for browser scripts
* Generates JavaScript code strings for script control
*/
export function generateControlHelpers(storageKey: string): string {
return `
// ============== STOP CONTROL ==============
window.STOP_SCRIPT = false;
window.PAUSE_SCRIPT = false;
console.log('%c⏹ To stop: window.STOP_SCRIPT = true', 'color: orange');
console.log('%c⏸ To pause: window.PAUSE_SCRIPT = true', 'color: orange');
console.log('%c🗑 To reset: localStorage.removeItem("${storageKey}")', 'color: orange');
async function checkStopPoints() {
if (window.STOP_SCRIPT) {
console.log('%c🛑 Stopped', 'color: red');
return true;
}
while (window.PAUSE_SCRIPT) {
console.log('%c⏸ Paused...', 'color: yellow');
await sleep(1000);
if (window.STOP_SCRIPT) return true;
}
return false;
}
// ==========================================`;
}