Created
November 28, 2025 16:17
-
-
Save blicksky/a0ac02c4ccbedf81140a8814e1a77dd0 to your computer and use it in GitHub Desktop.
An Arc Boost for adding reimbursement search buttons to the YNAB transactions page
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
| (function () { | |
| const buttons = [ | |
| { | |
| label: 'All Reimbursements', | |
| searchText: 'Flag: ππ Reimbursement Needed (Orange), Flag: πβ³ Reimbursement Submitted (Yellow), Flag: πβ Reimbursement Complete (Green), ', | |
| buttonId: 'ynab-all-reimbursements-search-button' | |
| }, | |
| { | |
| label: 'Outstanding Reimbursements', | |
| searchText: 'Flag: ππ Reimbursement Needed (Orange), Flag: πβ³ Reimbursement Submitted (Yellow), ', | |
| buttonId: 'ynab-outstanding-reimbursements-search-button' | |
| } | |
| ] | |
| function insertButtonsIfOnAccountsPage() { | |
| const isAccountsPage = window.location.pathname.includes('/accounts'); | |
| buttons.forEach(({label, searchText, buttonId}) => { | |
| if (!isAccountsPage) { | |
| document.getElementById(buttonId)?.remove(); | |
| return; | |
| } | |
| const accountHeaderBalancesEl = document.querySelector(".accounts-header-balances"); | |
| if (!accountHeaderBalancesEl || document.getElementById(buttonId)) { | |
| return; | |
| } | |
| const button = document.createElement('button'); | |
| button.id = buttonId; | |
| button.textContent = label; | |
| button.className = 'button button-primary'; | |
| Object.assign(button.style, { | |
| marginLeft: '10px', | |
| }); | |
| button.onclick = () => { | |
| const input = document.querySelector('input.transaction-search-input'); | |
| if (!input) { | |
| console.warn('No input found with class "transaction-search-input"'); | |
| return; | |
| } | |
| input.value = searchText; | |
| input.dispatchEvent(new Event('input', { bubbles: true })); | |
| input.dispatchEvent(new KeyboardEvent('keydown', { | |
| bubbles: true, | |
| cancelable: true, | |
| key: 'Enter', | |
| code: 'Enter', | |
| keyCode: 13, | |
| which: 13 | |
| })); | |
| }; | |
| accountHeaderBalancesEl.appendChild(button); | |
| }); | |
| } | |
| function startObserver() { | |
| // Observe changes in the body (DOM mutations from Ember route transitions) | |
| const observer = new MutationObserver(() => { | |
| insertButtonsIfOnAccountsPage(); | |
| }); | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| // Run once initially | |
| insertButtonsIfOnAccountsPage(); | |
| } | |
| // Wait until the document is fully ready | |
| if (document.readyState === 'loading') { | |
| document.addEventListener('DOMContentLoaded', startObserver); | |
| } else { | |
| startObserver(); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment