Last active
September 7, 2024 03:15
-
-
Save azyu/e72d6a4ff0da23876ab95a5be7d18490 to your computer and use it in GitHub Desktop.
Bluesky Keyboard Shortcut (for Tampermonkey)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Bluesky Keyboard Shortcut | |
// @namespace https://bsky.app/profile/azyu.bsky.social | |
// @version 0.13 | |
// @description Bluesky Keyboard Shortcut | |
// @author Azyu (azyu.bsky.social) | |
// @match https://bsky.app/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=bsky.app | |
// @grant none | |
// @updateURL https://gist.github.com/azyu/e72d6a4ff0da23876ab95a5be7d18490/raw/43fe4e703be2c7253973244e1996399f52ff7282/bsky_keyboard_shortcut.user.js | |
// @downloadURL https://gist.github.com/azyu/e72d6a4ff0da23876ab95a5be7d18490/raw/43fe4e703be2c7253973244e1996399f52ff7282/bsky_keyboard_shortcut.user.js | |
// @supportURL https://gist.github.com/azyu/e72d6a4ff0da23876ab95a5be7d18490#new_comment_field | |
// @require https://code.jquery.com/jquery-3.7.0.min.js | |
// ==/UserScript== | |
window.onload = function () { | |
'use strict'; | |
addEventListener('keyup', (event) => { | |
if (event.isComposing || event.key === 'n') { | |
var $focused = $(':focus'); | |
if ($focused.length > 0) | |
return; | |
var $composePostView = $('div[data-testid="composePostView"]'); | |
if ($composePostView.length > 0) | |
return; | |
var $el1 = $('[data-testid="composeFAB"]'); | |
if ($el1.length > 0) { | |
$el1[0].click(); | |
} | |
var $el2 = $('[aria-label="Compose post"]') | |
if ($el2.length > 0) { | |
$el2[0].click(); | |
} | |
}; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment