Adjust startY to account for scrolling

This commit is contained in:
Idrees Hassan committed 2025-10-22 22:33:27 -04:00
1 parent 2767caeb84
commit bae44cc98c
4 files changed
+14 -5

No files matched your search

+4 -1
View File
@@ -1071,13 +1071,16 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
} }
if (focusedElement === null) { if (focusedElement === null) {
if (Date.now() - lastActionTimestamp > AFK_TIME && !isMenuOpen()) { if (currentState === States.IDLE && Date.now() - lastActionTimestamp > AFK_TIME && !isMenuOpen()) {
// Fly to an element if the user is AFK // Fly to an element if the user is AFK
focusOnElement(); focusOnElement();
lastActionTimestamp = Date.now(); lastActionTimestamp = Date.now();
} }
} else if (focusedElement !== null) { } else if (focusedElement !== null) {
const oldTargetY = targetY;
targetY = getFocusedElementY(); targetY = getFocusedElementY();
// Adjust startY to account for scrolling of the focused element
startY += targetY - oldTargetY;
if (targetY < 0 || targetY > window.innerHeight) { if (targetY < 0 || targetY > window.innerHeight) {
// Fly to ground if the focused element moves out of bounds // Fly to ground if the focused element moves out of bounds
focusOnGround(); focusOnGround();
+1 -1
View File
@@ -24,7 +24,7 @@ const userScriptHeader =
`// ==UserScript== `// ==UserScript==
// @name Pocket Bird // @name Pocket Bird
// @namespace https://idreesinc.com // @namespace https://idreesinc.com
// @version 2025-10-22-02 // @version 2025-10-22-03
// @description birb // @description birb
// @author Idrees // @author Idrees
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/birb.user.js // @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/birb.user.js
+4 -1
View File
@@ -1410,13 +1410,16 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
} }
if (focusedElement === null) { if (focusedElement === null) {
if (Date.now() - lastActionTimestamp > AFK_TIME && !isMenuOpen()) { if (currentState === States.IDLE && Date.now() - lastActionTimestamp > AFK_TIME && !isMenuOpen()) {
// Fly to an element if the user is AFK // Fly to an element if the user is AFK
focusOnElement(); focusOnElement();
lastActionTimestamp = Date.now(); lastActionTimestamp = Date.now();
} }
} else if (focusedElement !== null) { } else if (focusedElement !== null) {
const oldTargetY = targetY;
targetY = getFocusedElementY(); targetY = getFocusedElementY();
// Adjust startY to account for scrolling of the focused element
startY += targetY - oldTargetY;
if (targetY < 0 || targetY > window.innerHeight) { if (targetY < 0 || targetY > window.innerHeight) {
// Fly to ground if the focused element moves out of bounds // Fly to ground if the focused element moves out of bounds
focusOnGround(); focusOnGround();
+5 -2
View File
@@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Pocket Bird // @name Pocket Bird
// @namespace https://idreesinc.com // @namespace https://idreesinc.com
// @version 2025-10-22-02 // @version 2025-10-22-03
// @description birb // @description birb
// @author Idrees // @author Idrees
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/birb.user.js // @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/birb.user.js
@@ -1424,13 +1424,16 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
} }
if (focusedElement === null) { if (focusedElement === null) {
if (Date.now() - lastActionTimestamp > AFK_TIME && !isMenuOpen()) { if (currentState === States.IDLE && Date.now() - lastActionTimestamp > AFK_TIME && !isMenuOpen()) {
// Fly to an element if the user is AFK // Fly to an element if the user is AFK
focusOnElement(); focusOnElement();
lastActionTimestamp = Date.now(); lastActionTimestamp = Date.now();
} }
} else if (focusedElement !== null) { } else if (focusedElement !== null) {
const oldTargetY = targetY;
targetY = getFocusedElementY(); targetY = getFocusedElementY();
// Adjust startY to account for scrolling of the focused element
startY += targetY - oldTargetY;
if (targetY < 0 || targetY > window.innerHeight) { if (targetY < 0 || targetY > window.innerHeight) {
// Fly to ground if the focused element moves out of bounds // Fly to ground if the focused element moves out of bounds
focusOnGround(); focusOnGround();