Adds a simple CFL revision dropdown next to "Try it On" for IMVU products, showing only real revisions.
当前为
// ==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);
})();