// ==UserScript== // @name 惠州佰斯特Temu运营-辅助插件-店小秘上架货号SKU同步增减/上新界面精简/标题轻松清除 // @namespace http://tampermonkey.net/ // @version 1.8 // @description 惠州佰斯特Temu运营-辅助插件-店小秘上架货号SKU同步增减/上新界面精简/标题轻松清除 // @match https://www.dianxiaomi.com/web/temu/quoteEdit?id=* // @grant none // @run-at document-end // ==/UserScript== (function () { 'use strict'; const mainInputSelector = 'input.productNumber'; const skuInputSelector = 'div.flex-y-center input.g-form-component'; function waitForInputs(callback) { const interval = setInterval(() => { const mainInput = document.querySelector(mainInputSelector); const skuInput = document.querySelector(skuInputSelector); console.log('调试信息:', { mainInput, skuInput }); if (mainInput && skuInput) { clearInterval(interval); callback(mainInput, skuInput); } }, 500); } function adjustValue(value, delta) { const match = value.match(/^(\d+)([A-Za-z]*)$/); if (!match) return value; let num = parseInt(match[1], 10); const suffix = match[2] || ''; num += delta; if (num < 0) num = 0; return `${num}${suffix}`; } function addButtonsToInput(input, onChange) { const container = document.createElement('div'); container.style.position = 'relative'; container.style.display = 'inline-block'; container.style.width = input.offsetWidth + 'px'; input.style.paddingRight = '60px'; input.parentNode.insertBefore(container, input); container.appendChild(input); const btnWrapper = document.createElement('div'); btnWrapper.style.position = 'absolute'; btnWrapper.style.right = '5px'; btnWrapper.style.bottom = '3px'; btnWrapper.style.display = 'flex'; btnWrapper.style.gap = '3px'; function makeBtn(symbol, delta) { const btn = document.createElement('button'); btn.textContent = symbol; btn.style.cssText = ` background-color: #1890ff; color: white; border: none; border-radius: 4px; font-size: 14px; width: 22px; height: 22px; cursor: pointer; transition: transform 0.1s ease; `; btn.onmousedown = () => btn.style.transform = 'scale(0.85)'; btn.onmouseup = () => btn.style.transform = 'scale(1)'; btn.onclick = () => onChange(delta); return btn; } btnWrapper.appendChild(makeBtn('-', -1)); btnWrapper.appendChild(makeBtn('+', 1)); container.appendChild(btnWrapper); } waitForInputs((mainInput, skuInput) => { let isSyncing = false; const syncValues = (from, to) => { if (isSyncing) return; isSyncing = true; to.value = from.value; isSyncing = false; }; const updateBoth = (delta) => { const newVal = adjustValue(mainInput.value, delta); mainInput.value = newVal; skuInput.value = newVal; }; addButtonsToInput(mainInput, updateBoth); addButtonsToInput(skuInput, updateBoth); mainInput.addEventListener('input', () => syncValues(mainInput, skuInput)); skuInput.addEventListener('input', () => syncValues(skuInput, mainInput)); }); })();