Pixiv Favorite Key

Enables pressing the F key to favorite/bookmark a post.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Pixiv Favorite Key
// @namespace    pixiv-favorite-key-e18f7be2ab0ba7d160427dd69d313fe7819819b830dde89b544f1c169ad20225
// @description  Enables pressing the F key to favorite/bookmark a post.
// @author       Pwalpac
// @version      0.1
// @icon         https://www.pixiv.net/favicon.ico
// @match        https://www.pixiv.net/*
// @license MIT
// @noframes
// ==/UserScript==


(function() {
    'use strict';

    function setupKeyPressHandler() {
        const mouseClickEvent = new MouseEvent("click", {
            bubbles: true,
        })

        function handleKeyPress(event) {
            if (event.key === 'f') {
                document.getElementsByClassName("gtm-main-bookmark")[0].dispatchEvent(mouseClickEvent)
            }
        }

        document.addEventListener('keydown', handleKeyPress)
    }

    setupKeyPressHandler()
})();