Created
August 19, 2026 14:05
-
-
Save parsibox/fb86e50aea1bb5692b98c73d623f1f36 to your computer and use it in GitHub Desktop.
github auto click "Accept incoming change"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (async function() { | |
| const targetText = "Accept incoming change"; | |
| const x = window.innerWidth - 100; | |
| const y = window.innerHeight - 100; | |
| let acceptCount = 0; | |
| // --- ساخت نوتیفیکیشن --- | |
| const toast = document.createElement('div'); | |
| toast.style.cssText = "position:fixed; bottom:20px; left:20px; background:#007acc; color:white; padding:10px 15px; border-radius:5px; z-index:999999; font-family:tahoma, sans-serif; direction:rtl; box-shadow:0 4px 6px rgba(0,0,0,0.3); transition: all 0.3s;"; | |
| toast.innerText = "شروع جستجو..."; | |
| document.body.appendChild(toast); | |
| const showToast = (msg, isEnd = false) => { | |
| toast.style.background = isEnd ? "#28a745" : "#007acc"; | |
| toast.innerText = msg; | |
| }; | |
| const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms)); | |
| // --- پیدا کردن دکمهای که در لایه رویی تب فعلی کاملاً قابل رویت باشد --- | |
| const getVisibleAcceptButton = () => { | |
| const elements = Array.from(document.querySelectorAll('a, button, span, [role="button"]')); | |
| for (let el of elements) { | |
| if (el.textContent && el.textContent.includes(targetText) && el.children.length === 0) { | |
| const rect = el.getBoundingClientRect(); | |
| if (rect.width > 0 && rect.height > 0 && rect.top >= 0 && rect.bottom <= window.innerHeight) { | |
| const cx = rect.left + (rect.width / 2); | |
| const cy = rect.top + (rect.height / 2); | |
| // آیا این المان در بالاترین لایه قرار دارد؟ (برای جلوگیری از کلیک روی تبهای بسته شده) | |
| const topEl = document.elementFromPoint(cx, cy); | |
| if (topEl && (topEl === el || el.contains(topEl) || topEl.contains(el))) { | |
| return el.closest('button') || el.closest('a') || el; | |
| } | |
| } | |
| } | |
| } | |
| return null; | |
| }; | |
| // --- شبیهسازی کلیک با کنترل خطای حذف شدن DOM --- | |
| const simulateRealClick = (el) => { | |
| const rect = el.getBoundingClientRect(); | |
| const cx = rect.left + (rect.width / 2); | |
| const cy = rect.top + (rect.height / 2); | |
| const opts = { bubbles: true, cancelable: true, clientX: cx, clientY: cy, view: window }; | |
| // ارسال mousedown | |
| try { | |
| el.dispatchEvent(new MouseEvent('mousedown', opts)); | |
| } catch (e) { /* نادیده گرفتن ارور داخلی مرورگر */ } | |
| // اگر کانفلیکت اعمال شود، دکمه از صفحه حذف میشود. | |
| // چک میکنیم اگر حذف شده بود، رویدادهای بعدی را نفرستد تا ارور parentElement ندهد! | |
| if (!document.body.contains(el)) return; | |
| // ارسال mouseup | |
| try { | |
| el.dispatchEvent(new MouseEvent('mouseup', opts)); | |
| } catch (e) {} | |
| if (!document.body.contains(el)) return; | |
| // ارسال click | |
| try { | |
| el.dispatchEvent(new MouseEvent('click', opts)); | |
| } catch (e) {} | |
| }; | |
| let noScrollProgressCount = 0; | |
| // --- چرخه اصلی --- | |
| while (true) { | |
| try { | |
| let btn = getVisibleAcceptButton(); | |
| if (btn) { | |
| simulateRealClick(btn); | |
| acceptCount++; | |
| showToast(`تغییر تایید شد! مجموع: ${acceptCount}`); | |
| await sleep(800); | |
| continue; | |
| } | |
| // اسکرول به پایین در صورت نبودن دکمه | |
| let targetEl = document.elementFromPoint(x, y); | |
| if (targetEl) { | |
| targetEl.dispatchEvent(new WheelEvent('wheel', { bubbles: true, deltaY: 250, clientX: x, clientY: y })); | |
| } | |
| let scroller = document.querySelector('.monaco-scrollable-element, .CodeMirror-scroll'); | |
| let oldScrollTop = -1; | |
| if (scroller) { | |
| oldScrollTop = scroller.scrollTop; | |
| scroller.scrollTop += 250; | |
| } | |
| await sleep(400); | |
| if (scroller) { | |
| if (scroller.scrollTop === oldScrollTop) { | |
| noScrollProgressCount++; | |
| } else { | |
| noScrollProgressCount = 0; | |
| } | |
| } else { | |
| noScrollProgressCount++; | |
| } | |
| if (noScrollProgressCount > 4) { | |
| break; | |
| } | |
| } catch (globalErr) { | |
| console.warn("خطایی رخ داد اما حلقه ادامه پیدا میکند:", globalErr); | |
| await sleep(500); | |
| } | |
| } | |
| // --- پایان --- | |
| showToast(`پایان! ${acceptCount} تغییر اعمال شد.`, true); | |
| console.log(`%c عملیات پایان یافت. مجموع: ${acceptCount} `, 'background: #222; color: #bada55; font-size: 14px;'); | |
| setTimeout(() => { toast.remove(); }, 5000); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment