From a7f48c528dd90b65c8fad3a786815c451315109d Mon Sep 17 00:00:00 2001 From: Masaki Kobayashi Date: Wed, 13 Sep 2023 19:03:32 +0900 Subject: [PATCH] `Ctrl+E` for viewing post engagements --- dist/twitter-shortcuts.user.js | 9 ++++++++- src/userscripts/meta/index.ts | 2 +- src/userscripts/twitter-shortcuts.user.ts | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dist/twitter-shortcuts.user.js b/dist/twitter-shortcuts.user.js index 385ea80..c75f719 100644 --- a/dist/twitter-shortcuts.user.js +++ b/dist/twitter-shortcuts.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Twitter - Shortcuts // @namespace mkobayashime -// @version 0.2.0 +// @version 0.3.0 // @description Refined shortcuts in Twitter for web // @author mkobayashime // @homepage https://github.com/mkobayashime/userscripts @@ -63,5 +63,12 @@ const config = {}; tabs[indexOfTabToClick].click(); } } + if (e.ctrlKey && e.key === "e") { + const normalizedURL = `${window.location.origin}${window.location.pathname}`; + if (/^https:\/\/twitter\.com\/\S+\/status\/\d+$/.test(normalizedURL)) { + e.preventDefault(); + window.location.href = `${normalizedURL}/likes`; + } + } }); })(config); diff --git a/src/userscripts/meta/index.ts b/src/userscripts/meta/index.ts index 50352d8..22c2cb1 100644 --- a/src/userscripts/meta/index.ts +++ b/src/userscripts/meta/index.ts @@ -200,7 +200,7 @@ export const meta: { [name: string]: UserScriptMeta | undefined } = { icon: "https://www.google.com/s2/favicons?domain=twitter.com", match: "https://twitter.com/*", name: "Twitter - Shortcuts", - version: "0.2.0", + version: "0.3.0", }, "zoom-web-shortcuts": { description: "Google Meet-like Ctrl-d/e shortcuts in Zoom", diff --git a/src/userscripts/twitter-shortcuts.user.ts b/src/userscripts/twitter-shortcuts.user.ts index 4316ab1..e877bc4 100644 --- a/src/userscripts/twitter-shortcuts.user.ts +++ b/src/userscripts/twitter-shortcuts.user.ts @@ -53,6 +53,14 @@ const config = {}; tabs[indexOfTabToClick].click(); } } + + if (e.ctrlKey && e.key === "e") { + const normalizedURL = `${window.location.origin}${window.location.pathname}`; + if (/^https:\/\/twitter\.com\/\S+\/status\/\d+$/.test(normalizedURL)) { + e.preventDefault(); + window.location.href = `${normalizedURL}/likes`; + } + } }); })(config);