Gelbooru Favorite Shortcut

Adds a keybind shortcut for adding images to favorites on Gelbooru.com

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Gelbooru Favorite Shortcut
// @namespace    http://tampermonkey.net/
// @license MIT
// @version      0.1
// @description  Adds a keybind shortcut for adding images to favorites on Gelbooru.com
// @author       YourName
// @match        https://gelbooru.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Define the keybind shortcut (you can change this to your preference)
    const shortcutKey = 'f';

    // Function to add an image to favorites
    function addToFavorites() {
        // Identify the anchor element that corresponds to "Add to favorites" and trigger a click event
        const addToFavoritesButton = document.querySelector("a[onclick*='addFav']");
        if (addToFavoritesButton) {
            addToFavoritesButton.click();
        }
    }

    // Listen for keydown events
    document.addEventListener('keydown', function(event) {
        // Check if the pressed key matches the shortcut key and if an input field is not focused
        if (event.key === shortcutKey && document.activeElement.tagName !== 'INPUT') {
            // Prevent default browser behavior for this key
            event.preventDefault();
            // Add the image to favorites
            addToFavorites();
        }
    });
})();