Skip to content

Instantly share code, notes, and snippets.

@scomma
Created March 12, 2019 09:38
Show Gist options
  • Save scomma/d57a4c2b526cb4c623f1dfa0e66b707f to your computer and use it in GitHub Desktop.
Save scomma/d57a4c2b526cb4c623f1dfa0e66b707f to your computer and use it in GitHub Desktop.
Quick Triage
// ==UserScript==
// @name Quick Triage
// @namespace https://softbaked.co/
// @version 0.1
// @description Quickly triage Maniphest tasks
// @author You
// @match https://softbaked.co/*
// @require https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.1/mousetrap.js
// @require https://raw.githubusercontent.com/ccampbell/mousetrap/master/plugins/global-bind/mousetrap-global-bind.js
// ==/UserScript==
(function() {
'use strict';
var option = document.querySelector("option[value='+']");
if (!option) return; // not maniphest task
var action = option.parentElement,
form = action.parentElement.parentElement.parentElement,
change = document.createEvent('HTMLEvents');
change.initEvent('change', false, true);
var focusLast = function() {
var inputs = form.getElementsByClassName('aphront-form-input'),
lastInput = inputs[inputs.length - 3];
setTimeout(function() {
var textInput = lastInput.querySelector('input[type=text]');
if (textInput) { textInput.focus(); }
else { lastInput.firstChild.focus(); }
}, 0);
};
var bindQuickAction = function(shortcut, a) {
Mousetrap.bindGlobal(shortcut, function(e) {
action.value = a;
action.dispatchEvent(change);
focusLast();
return false;
});
};
bindQuickAction('ctrl+o', 'owner');
bindQuickAction('ctrl+s', 'status');
bindQuickAction('ctrl+p', 'priority');
bindQuickAction('ctrl+x', 'points');
bindQuickAction('ctrl+t', 'projectPHIDs');
bindQuickAction('ctrl+m', 'column');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment