// ==UserScript== // @name 关键词叠词生成器 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 输入关键词生成组合叠词 // @author You // @match https://www.amazon.com/* // @match https://www.amazon.co.uk/* // @grant GM_addStyle // @downloadURL https://update.greasyfork.icu/scripts/517431/%E5%85%B3%E9%94%AE%E8%AF%8D%E5%8F%A0%E8%AF%8D%E7%94%9F%E6%88%90%E5%99%A8.user.js // @updateURL https://update.greasyfork.icu/scripts/517431/%E5%85%B3%E9%94%AE%E8%AF%8D%E5%8F%A0%E8%AF%8D%E7%94%9F%E6%88%90%E5%99%A8.meta.js // ==/UserScript== (function () { 'use strict'; // 添加样式 GM_addStyle(` #wordGeneratorContainer { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 9999; background-color: #f9f9f9; padding: 20px; border: 2px solid #ccc; border-radius: 15px; box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2); display: none; font-family: 'Arial', sans-serif; width: auto; max-width: 500px; min-width: 300px; } #openGeneratorButton { position: fixed; bottom: 20px; right: 20px; background-color: #0073e6; color: white; padding: 15px 20px; font-size: 20px; border: none; border-radius: 50%; cursor: pointer; z-index: 9999; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); } #outputArea { white-space: pre-wrap; word-wrap: break-word; margin-top: 15px; border: 1px solid #ddd; padding: 15px; background-color: #f4f4f4; min-height: 100px; max-height: 150px; overflow-y: auto; border-radius: 8px; } #wordGeneratorContainer button { margin-top: 10px; margin-right: 5px; padding: 10px; font-size: 14px; border: none; border-radius: 8px; cursor: pointer; } #copyButton { background-color: #0073e6; color: white; } #clearButton { background-color: #ff9800; color: white; } #closeButton { background-color: #ff3b3b; color: white; } #generateButton { background-color: #4caf50; color: white; } #wordGeneratorContainer button:hover { opacity: 0.8; } `); // 创建容器 const container = document.createElement('div'); container.id = 'wordGeneratorContainer'; const inputBox = document.createElement('input'); inputBox.type = 'text'; inputBox.placeholder = '输入关键词'; inputBox.style.width = '100%'; const generateButton = document.createElement('button'); generateButton.id = 'generateButton'; generateButton.textContent = '生成叠词'; const copyButton = document.createElement('button'); copyButton.id = 'copyButton'; copyButton.textContent = '复制'; const clearButton = document.createElement('button'); clearButton.id = 'clearButton'; clearButton.textContent = '清空'; const closeButton = document.createElement('button'); closeButton.id = 'closeButton'; closeButton.textContent = '关闭'; const outputArea = document.createElement('pre'); outputArea.id = 'outputArea'; container.appendChild(inputBox); container.appendChild(generateButton); container.appendChild(copyButton); container.appendChild(clearButton); container.appendChild(closeButton); container.appendChild(outputArea); document.body.appendChild(container); // 显示生成器按钮 const openGeneratorButton = document.createElement('button'); openGeneratorButton.id = 'openGeneratorButton'; openGeneratorButton.textContent = '叠'; document.body.appendChild(openGeneratorButton); // 功能实现 function generateCombinations(input) { const words = input.trim().split(/\s+/); const length = words.length; if (length < 2 || length > 4) { return '请输入 2 到 4 个关键词!'; } const combinations = []; // AB式 if (length === 2) { combinations.push(`${words[0]} ${words[1]} ${words[0]} ${words[1]}`); combinations.push(`${words[0]} ${words[0]} ${words[1]} ${words[1]}`); combinations.push(`${words[0]} ${words[0]} ${words[1]}`); combinations.push(`${words[0]} ${words[1]} ${words[1]}`); } // ABC式 if (length === 3) { combinations.push(`${words[0]} ${words[1]} ${words[2]} ${words[0]} ${words[1]} ${words[2]}`); combinations.push(`${words[0]} ${words[0]} ${words[1]} ${words[1]} ${words[2]} ${words[2]}`); combinations.push(`${words[0]} ${words[0]} ${words[1]} ${words[2]}`); combinations.push(`${words[0]} ${words[1]} ${words[1]} ${words[2]}`); combinations.push(`${words[0]} ${words[1]} ${words[2]} ${words[2]}`); } // ABCD式 if (length === 4) { combinations.push(`${words[0]} ${words[1]} ${words[2]} ${words[3]} ${words[0]} ${words[1]} ${words[2]} ${words[3]}`); combinations.push(`${words[0]} ${words[0]} ${words[1]} ${words[1]} ${words[2]} ${words[2]} ${words[3]} ${words[3]}`); combinations.push(`${words[0]} ${words[0]} ${words[1]} ${words[2]} ${words[3]}`); combinations.push(`${words[0]} ${words[1]} ${words[1]} ${words[2]} ${words[3]}`); combinations.push(`${words[0]} ${words[1]} ${words[2]} ${words[2]} ${words[3]}`); combinations.push(`${words[0]} ${words[1]} ${words[2]} ${words[3]} ${words[3]}`); } return combinations.join('\n'); } generateButton.addEventListener('click', () => { const input = inputBox.value; const output = generateCombinations(input); outputArea.textContent = output; }); copyButton.addEventListener('click', () => { const text = outputArea.textContent; if (text) { navigator.clipboard.writeText(text).then(() => { alert('内容已复制到剪贴板!'); }); } else { alert('没有内容可复制!'); } }); clearButton.addEventListener('click', () => { inputBox.value = ''; outputArea.textContent = ''; }); closeButton.addEventListener('click', () => { container.style.display = 'none'; }); openGeneratorButton.addEventListener('click', () => { container.style.display = 'block'; }); })();