// ==UserScript== // @name 关键词叠词生成器 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 输入关键词自动生成组合的叠词 // @author You // @match *://*/* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 创建一个简单的界面,输入框和按钮 const container = document.createElement('div'); container.style.position = 'fixed'; container.style.top = '10px'; container.style.right = '10px'; container.style.padding = '10px'; container.style.backgroundColor = '#fff'; container.style.border = '1px solid #ccc'; container.style.zIndex = '9999'; const inputLabel = document.createElement('label'); inputLabel.innerHTML = '输入关键词: '; container.appendChild(inputLabel); const inputBox = document.createElement('input'); inputBox.type = 'text'; inputBox.placeholder = '输入关键词'; container.appendChild(inputBox); const generateButton = document.createElement('button'); generateButton.innerHTML = '生成叠词'; container.appendChild(generateButton); const resultContainer = document.createElement('div'); resultContainer.style.marginTop = '10px'; container.appendChild(resultContainer); document.body.appendChild(container); // 生成叠词组合的函数 function generateCombinations(input) { const result = []; const len = input.length; // 生成ABAB, AABB, ABB, AAB等形式 for (let i = 1; i <= len; i++) { for (let j = 1; j <= len; j++) { const combination = input.substring(0, i) + input.substring(0, j); result.push(combination); } } return result; } // 当点击按钮时,生成叠词并显示 generateButton.addEventListener('click', function() { const input = inputBox.value.trim(); if (!input) { resultContainer.innerHTML = '请输入关键词!'; return; } const combinations = generateCombinations(input); resultContainer.innerHTML = combinations.join('
'); }); })();