Remove Favorite Hotkey

Allows you to press g (or another key) to remove favorites from the post page.

ของเมื่อวันที่ 04-08-2024 ดู เวอร์ชันล่าสุด

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

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

คุณจะต้องติดตั้งส่วนขยาย เช่น 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         Remove Favorite Hotkey
// @version      1
// @description  Allows you to press g (or another key) to remove favorites from the post page.
// @author       Yoboies
// @match        https://rule34.xxx/index.php?page=post&s=view&id=*
// @match        https://rule34.xxx/index.php?page=favorites&s=view&id=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rule34.xxx
// @grant        GM.getValue
// @grant        GM.setValue
// @license      MIT
// @namespace https://greasyfork.org/users/1345312
// ==/UserScript==

(async function() {
    'use strict';
    if(location.href.indexOf('https://rule34.xxx/index.php?page=post') == 0){
        var hotkey = "KeyG";  //REPLACE WITH WHATEVER KEY WORKS FOR YOU

        document.addEventListener('keydown', keyPress);

        function keyPress(e) {
            if(e.code==hotkey){
                var oldURL = location.href;
                var newURL = oldURL.replace('page=post&s=view','page=favorites&s=delete');
                GM.setValue('id',Date.now() + '\n' + oldURL);
                document.location.href = newURL;
            }
        }

    } else if (location.href.indexOf('https://rule34.xxx/index.php?page=favorites') == 0){
        var ID = await GM.getValue('id', '');
        if(ID && Date.now() - ID.split('\n')[0] < 1*1000){
            ID = ID.split('\n')[1];
            document.location.href = ID;
        }
    }
})();