Convert Value to Link by ID

Convert value attributes to clickable links for elements with a specific ID on https://cab.meest.cn

// ==UserScript==
// @name         Convert Value to Link by ID
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Convert value attributes to clickable links for elements with a specific ID on https://cab.meest.cn
// @author       max5555
// @match        https://cab.meest.cn/*
// @grant        none
// @license  	MIT

// ==/UserScript==

(function() {
    'use strict';

    function convertValueToLink() {
        const elements = document.querySelectorAll('#photo-product');
        for (const element of elements) {
            const url = element.getAttribute('value');
            if (url && !element.nextElementSibling?.classList.contains('converted-link')) {
                const anchor = document.createElement('a');
                anchor.href = url;
                anchor.target = '_blank';
                anchor.textContent = url;
                anchor.classList.add('converted-link');  // To avoid adding the same link multiple times
                element.insertAdjacentElement('afterend', anchor);
            }
        }
    }

    // Use a MutationObserver to detect dynamic content changes
    const observer = new MutationObserver(mutations => {
        convertValueToLink();
    });
    observer.observe(document.body, { childList: true, subtree: true });

    // Convert existing elements on page load
    convertValueToLink();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址