Rule34 Favorite Button

Adds a more convenient favorite button to rule34.xxx

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Rule34 Favorite Button
// @version      1.0
// @description  Adds a more convenient favorite button to rule34.xxx
// @author       littlesmella
// @namespace    littlesmella
// @match        https://rule34.xxx/index.php?page=post&s=view&id=*
// @license      MIT
// @grant        none
// ==/UserScript==

(() => {
    'use strict';

    function getIdFromUrl() {
        const searchParams = new URLSearchParams(window.location.search);
        const paramValue = searchParams.get('id');
        return paramValue;
    }

    const sidebar = document.querySelector('.postViewSidebarRight');
    if (sidebar) {
        const id = getIdFromUrl();
        const favButton = document.createElement('a');

        favButton.href = '#';
        favButton.textContent = "♥";
        favButton.setAttribute('onclick', `post_vote('${id}', 'up'); addFav('${id}'); return false;`);
        favButton.setAttribute('style', `font-size: 300px; text-align: center; display: block;`);

        sidebar.prepend(favButton);
        sidebar.setAttribute('class', `postViewSidebarRight verticalFlexWithMargins tag-type-artist`);
    } else {
        console.log('Sidebar not found');
    }
})();