您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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.1
- // @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: Function to handle revision checking
- function checkRevision(revision, misses = 0, maxMisses = 10) {
- const url = `${baseUrl}/${revision}/_contents.json`;
- fetch(url, { method: 'HEAD' })
- .then((response) => {
- if (response.ok) {
- const link = document.createElement('a');
- link.href = url;
- link.textContent = `Revision ${revision}`;
- link.target = '_blank';
- link.style.display = 'block';
- link.style.color = '#007bff';
- link.style.textDecoration = 'none';
- link.style.margin = '3px 0';
- dropdown.appendChild(link);
- checkRevision(revision + 1, 0, maxMisses); // Reset misses on success
- } else {
- if (misses < maxMisses) {
- checkRevision(revision + 1, misses + 1, maxMisses); // Allow up to maxMisses failures
- }
- }
- })
- .catch(() => {
- if (misses < maxMisses) {
- checkRevision(revision + 1, misses + 1, maxMisses); // Handle fetch failure
- }
- });
- }
- // Start checking from revision 1
- checkRevision(1, 0, 10);
- // Step 8: Optional fallback if no revisions found
- setTimeout(() => {
- if (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);
- })();