Last active
May 24, 2026 04:47
-
-
Save indexzero/d6d4801def0c643c2e8671faf20a1f1d to your computer and use it in GitHub Desktop.
Brave history scroller to force downloads to local sqlite3 database
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
| window.harvesterConfig = { | |
| throttleDelayMs: 100, | |
| // SELF-HEALING ENGINE: Finds the container dynamically if the global variable is missing | |
| getContainer: function() { | |
| if (window.discoveredContainer && document.contains(window.discoveredContainer)) { | |
| return window.discoveredContainer; | |
| } | |
| // Deep search crawler to safely locate the scroll box past Shadow roots | |
| let found = null; | |
| function findContainerDeep(node) { | |
| if (!node || found) return; | |
| if (node.id === 'tabsScrollContainer') { | |
| found = node; | |
| return; | |
| } | |
| if (node.shadowRoot) { | |
| let child = node.shadowRoot.firstChild; | |
| while (child) { findContainerDeep(child); child = child.nextSibling; } | |
| } | |
| let lightChild = node.firstChild; | |
| while (lightChild) { findContainerDeep(lightChild); lightChild = lightChild.nextSibling; } | |
| } | |
| findContainerDeep(document.documentElement); | |
| window.discoveredContainer = found; | |
| return found; | |
| }, | |
| // Direct index targeting for zero layout overhead | |
| getLastItem: function() { | |
| const app = document.querySelector('history-app'); | |
| const historyList = app?.shadowRoot?.querySelector('#history-list'); | |
| const items = historyList?.shadowRoot?.querySelectorAll('history-item'); | |
| if (items && items.length > 0) { | |
| return items[items.length - 1]; | |
| } | |
| return null; | |
| } | |
| }; | |
| /** | |
| * 1. Isolated High-Velocity Step Function | |
| */ | |
| async function stepScroll() { | |
| const config = window.harvesterConfig; | |
| const container = config.getContainer(); | |
| if (!container) { | |
| console.error("❌ Execution halted: Container reference missing. Are you viewing brave://history?"); | |
| return false; | |
| } | |
| const startHeight = container.scrollHeight; | |
| const lowestChild = config.getLastItem(); | |
| if (lowestChild) { | |
| lowestChild.scrollIntoView({ behavior: 'auto', block: 'end' }); | |
| } else { | |
| container.scrollTop = container.scrollHeight; | |
| } | |
| await new Promise(resolve => setTimeout(resolve, config.throttleDelayMs)); | |
| return container.scrollHeight > startHeight; | |
| } | |
| /** | |
| * 2. Automated Loop Function | |
| */ | |
| async function startInfiniteScroll() { | |
| console.log("%c⚡ High-velocity automated loop engaged (100ms cadence)...", "color: #ff5555; font-weight: bold;"); | |
| const config = window.harvesterConfig; | |
| const container = config.getContainer(); | |
| if (!container) { | |
| console.error("❌ Automation aborted: Lost track of the layout container."); | |
| return; | |
| } | |
| let baselineCheck = 0; | |
| const maxSettlingRetries = 40; | |
| let lastScrollHeight = container.scrollHeight; | |
| while (baselineCheck < maxSettlingRetries) { | |
| const lowestChild = config.getLastItem(); | |
| if (lowestChild) { | |
| lowestChild.scrollIntoView({ behavior: 'auto', block: 'end' }); | |
| } else { | |
| container.scrollTop = container.scrollHeight; | |
| } | |
| await new Promise(resolve => setTimeout(resolve, config.throttleDelayMs)); | |
| if (container.scrollHeight === lastScrollHeight) { | |
| baselineCheck++; | |
| if (baselineCheck % 8 === 0 && baselineCheck < maxSettlingRetries) { | |
| console.log(`⏳ Stream buffering... Applying jitter nudge (Check ${baselineCheck}/${maxSettlingRetries})...`); | |
| container.scrollBy({ top: -200, behavior: 'auto' }); | |
| await new Promise(resolve => setTimeout(resolve, 50)); | |
| const currentLowest = config.getLastItem(); | |
| if (currentLowest) currentLowest.scrollIntoView({ behavior: 'auto', block: 'end' }); | |
| await new Promise(resolve => setTimeout(resolve, 100)); | |
| } | |
| } else { | |
| baselineCheck = 0; | |
| lastScrollHeight = container.scrollHeight; | |
| } | |
| } | |
| console.log(`%c🏁 Loop complete. Terminal boundary verified at ${container.scrollHeight}px.`, "color: #3584e4; font-weight: bold;"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment