Skip to content

Instantly share code, notes, and snippets.

@mbhutton
Last active May 19, 2024 14:00
Show Gist options
  • Save mbhutton/bacd4af6eb4f8100658894a0efd9d397 to your computer and use it in GitHub Desktop.
Save mbhutton/bacd4af6eb4f8100658894a0efd9d397 to your computer and use it in GitHub Desktop.
Tampermonkey script for searching using a popup dialog, as an alternative to find-as-you-type
// ==UserScript==
// @name Workflowy: Search shortcut
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Workflowy customisations
// @author Matt Hutton
// @match https://workflowy.com*
// @grant none
// @run-at document-end
// ==/UserScript==
// This script binds ctrl-shift-F to a function which pops up a search box.
// Pressing ENTER will then do the search. It's only useful when the built-in
// search-as-you-type behaviour is too slow.
(function() {
'use strict';
document.addEventListener ("keydown", function (zEvent) {
var consumed = false;
if (zEvent.ctrlKey && zEvent.shiftKey && !zEvent.altKey && !zEvent.metaKey) {
switch(zEvent.code) {
case "KeyF": // Search
$("#searchBox").val(prompt("WorkFlowy search: ", $("#searchBox").val()));
$("#searchBox").focus();
$("#searchBox").trigger(jQuery.Event( 'keydown', { which: $.ui.keyCode.ENTER } ));
consumed = true;
break;
default:
break;
}
}
if (consumed) {
zEvent.stopPropagation();
zEvent.preventDefault();
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment