Skip to content

Instantly share code, notes, and snippets.

@TFWol
Last active July 9, 2024 21:22
Show Gist options
  • Save TFWol/54467198105ff8b531375fc2dcab9a77 to your computer and use it in GitHub Desktop.
Save TFWol/54467198105ff8b531375fc2dcab9a77 to your computer and use it in GitHub Desktop.
See the hidden GitHub Emoji descriptions in popup

image

If an emoji has extra hidden words, they will be appended to the end.
Made just for fun to see what other words I could type.

You can adjust the text color in the script; I made this using Dark Theme.

// ==UserScript==
// @name Emoji Suggester Data-Text Appender
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Appends data-text to emoji suggestions on GitHub
// @match https://github.com/*
// @icon https://icons.duckduckgo.com/ip2/github.com.ico
// @grant none
// ==/UserScript==
/*
Changelog:
v1.2:
- Made all the matching text bold
v1.1:
- Make matching characters bold
v1.0 (2024-07-09):
- Original script to append data-text to emoji suggestions
*/
(function() {
'use strict';
let debounceTimer;
function appendDataText() {
const suggestionList = document.querySelector('.emoji-suggestions');
if (!suggestionList) return;
const input = document.querySelector('textarea:focus, input[type="text"]:focus');
const searchText = input ? input.value.split(':').pop().toLowerCase() : '';
suggestionList.querySelectorAll('li[role="option"]').forEach(item => {
const dataText = item.getAttribute('data-text');
if (!dataText) return;
// Update emoji name
let emojiNameSpan = item.querySelector('.emoji-name-text');
if (!emojiNameSpan) {
const emojiNameText = Array.from(item.childNodes).find(node => node.nodeType === Node.TEXT_NODE && node.textContent.trim());
if (emojiNameText) {
emojiNameSpan = document.createElement('span');
emojiNameSpan.className = 'emoji-name-text';
emojiNameText.replaceWith(emojiNameSpan);
}
}
if (emojiNameSpan) {
const emojiName = item.getAttribute('data-emoji-name');
emojiNameSpan.innerHTML = emojiName.replace(new RegExp(searchText, 'gi'), match => `<strong>${match}</strong>`);
}
// Update data-text
let enhancedSpan = item.querySelector('.enhanced-data-text');
if (!enhancedSpan) {
enhancedSpan = document.createElement('span');
enhancedSpan.className = 'enhanced-data-text';
enhancedSpan.style.color = '#666';
enhancedSpan.style.fontSize = '0.8em';
item.appendChild(enhancedSpan);
}
const boldDataText = dataText.replace(new RegExp(searchText, 'gi'), match => `<strong>${match}</strong>`);
enhancedSpan.innerHTML = ` (${boldDataText})`;
});
}
const observer = new MutationObserver(() => {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(appendDataText, 100);
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment