Highlight purchased item on DLsite

購入済みアイテムの背景色を変更します

Verze ze dne 05. 10. 2024. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Highlight purchased item on DLsite
// @namespace    http://tampermonkey.net/
// @version      0.3.2
// @description  購入済みアイテムの背景色を変更します
// @author       PUMPKIN
// @match        https://www.dlsite.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const backgroundColor = "gray";

    // 購入済みアイテムに対して背景色を設定する関数
    function highlightPurchasedItems() {
        document.querySelectorAll('.btn_dl').forEach(btn => {
            // 割引中、サークル情報等:.search_result_img_box_inner
            // サークル情報の割引中作品:.n_worklist_item
            // 検索結果:tr
            const parent = btn.closest('.search_result_img_box_inner, .n_worklist_item, tr');
            if (parent) {
                parent.style.backgroundColor = backgroundColor;
            }
        });
    }

    // 初期ロード時に一度実行
    highlightPurchasedItems();

    // 動的な変更を監視して、追加された要素にも適用する
    const observer = new MutationObserver(() => {
        highlightPurchasedItems(); // DOM に変更があった場合、常に全体を再探索
    });

    observer.observe(document.body, {
        subtree: true,
        childList: true, // 子要素の追加・削除を監視
    });
})();