YouTube Q點讚Press Q to like/cancel likes

Press Q to like/cancel likes

// ==UserScript==
// @name         YouTube Q點讚Press Q to like/cancel likes
// @namespace    http://your.namespace.com
// @version      0.3
// @description  Press Q to like/cancel likes
// @author       You
// @match        *://www.youtube.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    document.addEventListener('keydown', function(event) {
        if (event.keyCode === 81 ) {
            triggerLikeButton();
        }
    });

    function triggerLikeButton() {
        var likeButton = document.querySelector('button[title="我喜歡"]');
        if (likeButton) {
            likeButton.click();
        }else {
            var unlikeButton = document.querySelector('button[title="取消喜歡"]');
            if (unlikeButton) {
                unlikeButton.click();
            }
        }
    }
})();