[userscript] [Mastodon] You can use enter key to toot in Mastodon (add custom include URL)
// ==UserScript==
// @name [Mastodon] mastodon-use-enter-to-toot
// @namespace https://gist.github.com/tkrkt
// @version 1
// @grant none
// ==/UserScript==
document.addEventListener('keypress', event => {
const isEnter = event.keyCode === 13 && !event.shiftKey && !event.ctrlKey && !event.metaKey;
const isTextarea = event.target.tagName === 'TEXTAREA' && event.target.classList.contains('autosuggest-textarea__textarea');
if (isEnter && isTextarea) {
const button = Array.from(document.querySelectorAll('button.button')).find(elem => elem.textContent === 'トゥート!');
if (button) {
event.preventDefault();
event.stopPropagation();
button.click();
}
}
}, false);