Google Meet Reaction Hotkeys

Hotkeys 1-9 for Google Meet reactions with hover hints

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Google Meet Reaction Hotkeys
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Hotkeys 1-9 for Google Meet reactions with hover hints
// @author       You
// @match        https://meet.google.com/*
// @grant        none
// @license MIT 
// ==/UserScript==

(function() {
    'use strict';

    const SELECTOR = '[role="toolbar"] button[data-emoji]';
    let buttons = [];

    // Inject CSS for hover overlay
    const style = document.createElement('style');
    style.textContent = `
        .rhk-btn { position: relative; }
        .rhk-overlay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(60, 64, 67, 1);
            color: #fff;
            font: 600 20px 'Google Sans', Roboto, sans-serif;
            border-radius: 50%;
            opacity: 0;
            transition: opacity 0.15s;
            pointer-events: none;
        }
        .rhk-btn:hover .rhk-overlay { opacity: 1; }
    `;
    document.head.appendChild(style);

    // Find reaction buttons and add overlays
    function update() {
        buttons = [...document.querySelectorAll(SELECTOR)].slice(0, 9);
        buttons.forEach((btn, i) => {
            if (btn.dataset.rhk) return;
            btn.dataset.rhk = '1';
            btn.classList.add('rhk-btn');
            const overlay = document.createElement('div');
            overlay.className = 'rhk-overlay';
            overlay.textContent = i + 1;
            btn.appendChild(overlay);
        });
    }

    // Handle hotkeys
    document.addEventListener('keydown', e => {
        if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.isContentEditable) return;
        if (e.ctrlKey || e.altKey || e.metaKey) return;
        if (e.key >= '1' && e.key <= '9') {
            e.preventDefault();
            e.stopPropagation();
            buttons[+e.key - 1]?.click();
        }
    }, true);

    // Poll for buttons
    setInterval(update, 1000);
    setTimeout(update, 500);
})();