diff --git a/birb.js b/birb.js index 5d0f224..bb028d0 100644 --- a/birb.js +++ b/birb.js @@ -1071,13 +1071,16 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI } 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 focusOnElement(); lastActionTimestamp = Date.now(); } } else if (focusedElement !== null) { + const oldTargetY = targetY; targetY = getFocusedElementY(); + // Adjust startY to account for scrolling of the focused element + startY += targetY - oldTargetY; if (targetY < 0 || targetY > window.innerHeight) { // Fly to ground if the focused element moves out of bounds focusOnGround(); diff --git a/build.js b/build.js index ed4ef67..61f6b40 100644 --- a/build.js +++ b/build.js @@ -24,7 +24,7 @@ const userScriptHeader = `// ==UserScript== // @name Pocket Bird // @namespace https://idreesinc.com -// @version 2025-10-22-02 +// @version 2025-10-22-03 // @description birb // @author Idrees // @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/birb.user.js diff --git a/dist/birb.js b/dist/birb.js index 9298bab..98181e6 100644 --- a/dist/birb.js +++ b/dist/birb.js @@ -1410,13 +1410,16 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI } 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 focusOnElement(); lastActionTimestamp = Date.now(); } } else if (focusedElement !== null) { + const oldTargetY = targetY; targetY = getFocusedElementY(); + // Adjust startY to account for scrolling of the focused element + startY += targetY - oldTargetY; if (targetY < 0 || targetY > window.innerHeight) { // Fly to ground if the focused element moves out of bounds focusOnGround(); diff --git a/dist/birb.user.js b/dist/birb.user.js index 2da0b1b..a0164b4 100644 --- a/dist/birb.user.js +++ b/dist/birb.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Pocket Bird // @namespace https://idreesinc.com -// @version 2025-10-22-02 +// @version 2025-10-22-03 // @description birb // @author Idrees // @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 (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 focusOnElement(); lastActionTimestamp = Date.now(); } } else if (focusedElement !== null) { + const oldTargetY = targetY; targetY = getFocusedElementY(); + // Adjust startY to account for scrolling of the focused element + startY += targetY - oldTargetY; if (targetY < 0 || targetY > window.innerHeight) { // Fly to ground if the focused element moves out of bounds focusOnGround();