IMVU Product Minimal Revision Viewer

Adds a simple CFL revision dropdown next to "Try it On" for IMVU products, showing only real revisions.

当前为 2025-04-13 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         IMVU Product Minimal Revision Viewer
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a simple CFL revision dropdown next to "Try it On" for IMVU products, showing only real revisions.
// @author       heapsofjoy
// @match        *://*.imvu.com/shop/product.php?products_id=*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Step 1: Get product ID
    const urlParams = new URLSearchParams(window.location.search);
    const productId = urlParams.get('products_id');
    if (!productId) return;

    const baseUrl = `https://userimages-akm.imvu.com/productdata/${productId}`;

    // Step 2: Locate "Try it On" button
    const tryOnLink = document.getElementById('try-on-link');
    if (!tryOnLink) return;

    // Step 3: Create a wrapper span to contain both buttons
    const wrapper = document.createElement('span');
    wrapper.style.display = 'inline-flex';
    wrapper.style.alignItems = 'center';
    wrapper.style.gap = '6px';
    tryOnLink.parentNode.insertBefore(wrapper, tryOnLink);

    // Step 4: Create CFL button
    const toggleButton = document.createElement('button');
    toggleButton.textContent = 'contents.json';
    toggleButton.style.background = '#eee';
    toggleButton.style.border = '1px solid #ccc';
    toggleButton.style.borderRadius = '3px';
    toggleButton.style.padding = '2px 6px';
    toggleButton.style.fontSize = '12px';
    toggleButton.style.cursor = 'pointer';

    // Step 5: Create dropdown container
    const dropdown = document.createElement('div');
    dropdown.style.display = 'none';
    dropdown.style.position = 'absolute';
    dropdown.style.background = '#fff';
    dropdown.style.border = '1px solid #ccc';
    dropdown.style.padding = '6px';
    dropdown.style.borderRadius = '4px';
    dropdown.style.boxShadow = '0 2px 5px rgba(0,0,0,0.1)';
    dropdown.style.maxHeight = '180px';
    dropdown.style.overflowY = 'auto';
    dropdown.style.fontSize = '12px';
    dropdown.style.zIndex = '999';

    // Step 6: Toggle visibility
    toggleButton.addEventListener('click', () => {
        dropdown.style.display = dropdown.style.display === 'block' ? 'none' : 'block';
    });

    // Step 7: Load revisions dynamically
    const maxRevs = 50;
    let foundAny = false;

    for (let rev = 1; rev <= maxRevs; rev++) {
        const url = `${baseUrl}/${rev}/_contents.json`;
        fetch(url, { method: 'HEAD' }).then(res => {
            if (res.ok) {
                const link = document.createElement('a');
                link.href = url;
                link.textContent = `Revision ${rev}`;
                link.target = '_blank';
                link.style.display = 'block';
                link.style.color = '#007bff';
                link.style.textDecoration = 'none';
                link.style.margin = '3px 0';
                dropdown.appendChild(link);
                foundAny = true;
            }
        });
    }

    // Step 8: Optional fallback if no revisions found
    setTimeout(() => {
        if (!foundAny && dropdown.children.length === 0) {
            const msg = document.createElement('div');
            msg.textContent = 'No revisions found.';
            msg.style.color = '#666';
            dropdown.appendChild(msg);
        }
    }, 2000);

    // Step 9: Insert everything
    const container = document.createElement('div');
    container.style.position = 'relative';
    container.appendChild(toggleButton);
    container.appendChild(dropdown);

    wrapper.appendChild(container);
    wrapper.appendChild(tryOnLink);
})();