Forwarded from 공남은 합니다
기존에 쓰던 Nado 스크립트 안먹히길래 새로 만들었음
딜레이 2초
딜레이 2초
console.log("🚀 무한 반복 시작 (ESC 누르면 중단)");
let running = true;
document.addEventListener("keydown", e => { if (e.key === "Escape") running = false; });
const FIXED_DELAY = 2000; // 2초
function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
function getByXPath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
function centerCoordinates(el) {
const r = el.getBoundingClientRect();
return { x: Math.round(r.left + r.width/2), y: Math.round(r.top + r.height/2) };
}
function synthMouse(el, clientX, clientY) {
["pointerover","mouseover","pointerdown","mousedown","mouseup","pointerup","click"].forEach(type => {
el.dispatchEvent(new MouseEvent(type, { view: window, bubbles: true, cancelable: true, clientX, clientY }));
});
}
function forceClick(el) {
if(!el) return false;
try {
const old = { pointerEvents: el.style.pointerEvents, zIndex: el.style.zIndex, visibility: el.style.visibility };
el.style.pointerEvents = "auto";
el.style.zIndex = "9999999";
el.style.visibility = "visible";
el.scrollIntoView({ block: "center", inline: "center", behavior: "auto" });
const { x, y } = centerCoordinates(el);
synthMouse(el, x, y);
try { el.click(); } catch(e){}
el.style.pointerEvents = old.pointerEvents;
el.style.zIndex = old.zIndex;
el.style.visibility = old.visibility;
return true;
} catch(e) { return false; }
}
function findBuy() {
return [...document.querySelectorAll("button")]
.find(b => b.textContent?.trim() === "Buy/Long BTC");
}
function findAllCloseAll() {
return [...document.querySelectorAll("button")]
.filter(b => b.textContent?.trim() === "Close All");
}
async function clickSecondCloseAll() {
let closeBtns = findAllCloseAll();
if (closeBtns.length >= 2) {
for (let attempt=0; attempt<3; attempt++) {
if (!running) return false;
forceClick(closeBtns[1]);
await sleep(500);
const after = findAllCloseAll();
if (after.length < closeBtns.length) return true;
closeBtns = findAllCloseAll();
}
}
const cssSel = "#radix-_r_1f_ > div > div > button.inline-flex.items-center.justify-center.whitespace-nowrap.cursor-pointer.bg-surface-2.rounded-sm.font-medium.text-negative.relative.before\\:absolute.before\\:inset-0.before\\:pointer-events-none.hover\\:before\\:bg-overlay-hover.before\\:rounded-sm.px-5.py-2.text-sm";
const cssNode = document.querySelector(cssSel);
if (cssNode) {
for (let i=0;i<3;i++) {
forceClick(cssNode);
await sleep(500);
if (!document.contains(cssNode)) return true;
}
}
const xpath = "/html/body/div[5]/div/div/div/button[1]";
const xp = getByXPath(xpath);
if (xp) {
for (let i=0;i<3;i++) {
forceClick(xp);
await sleep(500);
if (!document.contains(xp)) return true;
}
}
return false;
}
async function loop() {
while (running) {
console.log("▶️ BUY");
const buy = findBuy();
if (buy) forceClick(buy);
await sleep(FIXED_DELAY); // 2초
console.log("▶️ Close All 1");
const close1 = findAllCloseAll()[0];
if (close1) forceClick(close1);
await sleep(FIXED_DELAY); // 2초
console.log("▶️ Close All 2");
await clickSecondCloseAll();
console.log("⏳ 사이클 완료, 다음 사이클까지 2초 대기");
await sleep(FIXED_DELAY); // 2초
}
console.log("🛑 ESC로 종료됨");
}
loop();
❤2