Skip to content

Instantly share code, notes, and snippets.

@k0ta0uchi
Last active June 29, 2017 00:07
Show Gist options
  • Save k0ta0uchi/03f5ca5a3d2eae8fac03f6f61a56e400 to your computer and use it in GitHub Desktop.
Save k0ta0uchi/03f5ca5a3d2eae8fac03f6f61a56e400 to your computer and use it in GitHub Desktop.
Tweetdeck like shortcut for Mastodon
// ==UserScript==
// @name TootDeck Shortcut Alternative
// @namespace k0ta0uchi
// @version 0.1
// @description Add shortcut keys like TweetDeck to Mastodon
// @author k0ta0uchi
// @match https://*/web/*
// @downloadURL https://gist.githubusercontent.com/k0ta0uchi/03f5ca5a3d2eae8fac03f6f61a56e400/raw/3fa111403799376bf5b7dcb0d222cc2c8862270c/TootDeckShortcutAlternative.js
// @grant none
// ==/UserScript==
(() => {
'use strict';
const KEY_N = 78,
KEY_S = 83,
doc = document;
doc.onkeyup = (e) => {
let activeTag = document.activeElement.tagName;
if (activeTag != "INPUT" && activeTag != "TEXTAREA") {
switch (e.keyCode) {
case KEY_N:
// Key: n - prepare to post New toot
doc.querySelector(".autosuggest-textarea__textarea").focus();
doc.querySelector(".autosuggest-textarea__textarea").value="";
break;
case KEY_S:
// key: s - prepare to Search
doc.querySelector(".search__input").focus();
doc.querySelector(".search__input").value="";
break;
}
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment