LP Messenger Hotkeys

Various messenger.com hotkeys for pure keyboard navigation.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        LP Messenger Hotkeys
// @namespace   Violentmonkey Scripts
// @match       https://www.messenger.com/*
// @license     MIT
// @grant       none
// @version     0.1
// @author      Sadist
// @description Various messenger.com hotkeys for pure keyboard navigation.
// ==/UserScript==


document.addEventListener("keydown", (event) => {
  if ( (event.key === "x") && (event.ctrlKey) ) {
    tbox = document.querySelector('[aria-label="Message"]');
    console.log('here');
    tbox.focus();
  }
})

document.addEventListener("keydown", (event) => {
  if ( !event.altKey ) {
    return;
  }
  keyList = ['1','2','3','4','5','6','7','8','9','0','l','g','i','e','t'];
  if ( !keyList.includes(event.key) ) {
    return;
  }
  if (event.key === 'l') {
    document.querySelector('[aria-label^="Send a"]').click();
    return;
  }
  if (event.key === 'g') {
    document.querySelector('[aria-label="Choose a GIF"]').click();
    document.querySelector('[aria-label="GIF Search"]').click();
    return;
  }
  if (event.key === 'i') {
    document.querySelector('[aria-label^="Attach a file"]').click();
    return;
  }
  if (event.key === 'e') {
    event.preventDefault();
    document.querySelector('[aria-label="Choose an emoji"]').click();
    document.querySelector('[aria-label="Search emoji"]').click();
    return;
  }
  if (event.key === 't') {
    event.preventDefault();
    document.querySelector('[aria-label="Choose a sticker"]').click();
    return;
  }
  groupIndex = parseInt(event.key);
  focusGroup = document.querySelectorAll('[href^="/t"],[href^="/e2ee/t"]')[groupIndex];
  focusGroup.click();
})