Skip to content

Instantly share code, notes, and snippets.

@deecewan
Created May 8, 2019 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deecewan/d43d99ae3b6f018ee5dd6bdfda251674 to your computer and use it in GitHub Desktop.
Save deecewan/d43d99ae3b6f018ee5dd6bdfda251674 to your computer and use it in GitHub Desktop.
Tampermonkey scipt to change chat windows with a keypress
// ==UserScript==
// @name Chat window changer
// @namespace http://deecewan.com
// @version 0.1
// @description try to take over the world!
// @author David Buchan-Swanson
// @match https://tanda.facebook.com/chat/t/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('keyup', e => {
if (!e.ctrlKey) {
// you must press alt
return;
}
if (e.keyCode < 49 || e.keyCode > 57) {
// only handle number keys (1-9)
return;
}
e.preventDefault();
const number = e.keyCode - 49;
const items = document
.querySelector('[aria-label="Conversation List"')
.querySelectorAll('li');
const selected = items[number];
if (!selected) {
// who knows
return;
}
selected.querySelector('a').click();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment