Skip to content

Instantly share code, notes, and snippets.

@SystemDisc
Last active December 18, 2019 02:48
Show Gist options
  • Save SystemDisc/dc0f2745e8b3cf9e7dd7522c0609299d to your computer and use it in GitHub Desktop.
Save SystemDisc/dc0f2745e8b3cf9e7dd7522c0609299d to your computer and use it in GitHub Desktop.
YNAB's new web software is a million times worse than their desktop software was
// ==UserScript==
// @name YNAB Improvements
// @namespace https://zornco.com/
// @version 0.0.7
// @description Improvements to the YNAB web app by Timothy Zorn (SystemDisc)
// @author SystemDisc
// @updateURL https://rawgit.com/SystemDisc/dc0f2745e8b3cf9e7dd7522c0609299d/raw/50c2268551b5f60d593e3a138e8b1bc4b4e048c8/ynab-improvements.user.js
// @downloadURL https://rawgit.com/SystemDisc/dc0f2745e8b3cf9e7dd7522c0609299d/raw/50c2268551b5f60d593e3a138e8b1bc4b4e048c8/ynab-improvements.user.js
// @match https://app.youneedabudget.com/*
// @run-at document-end
// @grant unsafeWindow
// ==/UserScript==
document.addEventListener('keydown', (e) => {
console.log(e);
// edit on enter
if (e.keyCode == "\r".charCodeAt(0) && e.target == document.body) {
let checkedElems = Array.from(document.querySelectorAll('.ynab-grid-body-row.is-checked'));
if (checkedElems.length === 1 && !checkedElems[0].querySelector('input')) {
checkedElems[0].querySelector('.ynab-grid-cell-date').click();
return false;
}
else {
return;
}
}
// Alt+A or Option+A == Approve
else if (e.keyCode == 'A'.charCodeAt(0) && e.altKey && e.target == document.body) {
let buttons = document.querySelectorAll('.modal-account-edit-transaction-list button');
if (buttons.length === 0 || !Array.from(buttons).filter((button) => button.textContent.trim() === 'Approve')[0]) {
document.querySelector('.accounts-toolbar-edit-transaction').click();
}
let waitForMenu;
(waitForMenu = () => {
let buttons = document.querySelectorAll('.modal-account-edit-transaction-list button');
if (buttons.length === 0 || !Array.from(buttons).filter((button) => button.textContent.trim() === 'Approve')[0]) {
window.requestAnimationFrame(waitForMenu);
return;
}
Array.from(buttons).filter((button) => button.textContent.trim() === 'Approve')[0].click();
})();
}
// Alt+R or Option+R == Reject
else if (e.keyCode == 'R'.charCodeAt(0) && e.altKey && e.target == document.body) {
let buttons = document.querySelectorAll('.modal-account-edit-transaction-list button');
if (buttons.length === 0 || !Array.from(buttons).filter((button) => button.textContent.trim() === 'Reject')[0]) {
document.querySelector('.accounts-toolbar-edit-transaction').click();
}
let waitForMenu;
(waitForMenu = () => {
let buttons = document.querySelectorAll('.modal-account-edit-transaction-list button');
if (buttons.length === 0) {
window.requestAnimationFrame(waitForMenu);
return;
}
Array.from(buttons).filter((button) => button.textContent.trim() === 'Reject')[0].click();
})();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment