Created
June 17, 2025 17:22
-
-
Save chiliec/45ba56b6b839ca8c251dfb3f936cbca0 to your computer and use it in GitHub Desktop.
Scrolling to any webpage in Safari with Shortcuts
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
tell application "Safari" | |
tell front document | |
do JavaScript " | |
(function() { | |
// Настройки скорости - меняй здесь | |
const SCROLL_SPEED = 1; // пиксели за шаг | |
const SCROLL_DELAY = 80; // миллисекунды между шагами | |
// Удаляем старые элементы | |
document.querySelectorAll('#__scrollTriggerBtn, #__speedControls').forEach(el => el.remove()); | |
// Переменные состояния | |
let scrollInterval = null; | |
let isScrolling = false; | |
// Создаём основную кнопку | |
const btn = document.createElement('button'); | |
btn.id = '__scrollTriggerBtn'; | |
btn.textContent = '▶️ Автоскролл'; | |
btn.style.cssText = ` | |
position: fixed !important; bottom: 20px !important; right: 20px !important; | |
z-index: 999999 !important; padding: 12px 20px !important; border: none !important; | |
border-radius: 25px !important; cursor: pointer !important; font-size: 14px !important; | |
font-weight: bold !important; color: white !important; opacity: 0.9 !important; | |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; | |
box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important; | |
`; | |
btn.onclick = function () { | |
if (isScrolling) { | |
clearInterval(scrollInterval); | |
isScrolling = false; | |
btn.textContent = '▶️ Автоскролл'; | |
btn.style.background = 'linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important'; | |
} else { | |
isScrolling = true; | |
btn.textContent = '⏸️ Стоп'; | |
btn.style.background = 'linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%) !important'; | |
scrollInterval = setInterval(() => { | |
window.scrollBy(0, SCROLL_SPEED); | |
if (window.scrollY >= document.documentElement.scrollHeight - window.innerHeight - 20) { | |
clearInterval(scrollInterval); | |
isScrolling = false; | |
btn.textContent = '✅ Готово'; | |
btn.style.background = 'linear-gradient(135deg, #26de81 0%, #20bf6b 100%) !important'; | |
setTimeout(() => { | |
btn.textContent = '▶️ Автоскролл'; | |
btn.style.background = 'linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important'; | |
}, 2000); | |
} | |
}, SCROLL_DELAY); | |
} | |
}; | |
// Добавляем на страницу | |
document.body.appendChild(btn); | |
})(); | |
" | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment