Highlight purchased item on DLsite

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

2024-10-05 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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         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, // 子要素の追加・削除を監視
    });
})();