// ==UserScript== // @name Amazon Keyword Frequency Tool // @namespace http://tampermonkey.net/ // @version 2.0 // @description Analyze keyword frequency, select high-frequency words, and generate "+" prefixed content // @author Your Name // @match https://www.amazon.com/* // @grant GM_setClipboard // @downloadURL none // ==/UserScript== (function () { 'use strict'; const excludedWords = [ "and", "or", "not", "but", "nor", "so", "yet", "for", "in", "on", "at", "by", "to", "of", "with", "about", "as", "from", "into", "over", "under", "after", "before", "around", "through", "between", "sets", "set", "pack", "pcs", "dozen", "pair", "unit", "kg", "g", "lb", "oz", "cm", "mm", "m", "km", "in", "ft", "ml", "l", "box", "bottle", "jar", "can", "tray" ]; const excludedSymbols = /^[!@#$%^&*(),.?":{}|<>+=/\\~`;'\[\]-]+$/; // Create a floating button const button = document.createElement("div"); button.textContent = "+"; button.style.position = "fixed"; button.style.bottom = "20px"; button.style.left = "20px"; button.style.width = "50px"; button.style.height = "50px"; button.style.borderRadius = "50%"; button.style.backgroundColor = "#007bff"; button.style.color = "white"; button.style.fontSize = "24px"; button.style.textAlign = "center"; button.style.lineHeight = "50px"; button.style.cursor = "pointer"; button.style.boxShadow = "0 4px 8px rgba(0, 0, 0, 0.2)"; document.body.appendChild(button); // Create a popup const popup = document.createElement("div"); popup.style.position = "fixed"; popup.style.bottom = "80px"; popup.style.left = "20px"; popup.style.width = "600px"; popup.style.padding = "20px"; popup.style.backgroundColor = "white"; popup.style.border = "1px solid #ccc"; popup.style.boxShadow = "0 4px 8px rgba(0, 0, 0, 0.2)"; popup.style.display = "none"; popup.style.zIndex = "1000"; document.body.appendChild(popup); // Left text area for input const inputArea = document.createElement("textarea"); inputArea.style.width = "48%"; inputArea.style.height = "150px"; inputArea.style.marginRight = "2%"; inputArea.style.float = "left"; inputArea.placeholder = "Enter keywords here (one per line)..."; popup.appendChild(inputArea); // Right area for frequency analysis const frequencyArea = document.createElement("div"); frequencyArea.style.width = "48%"; frequencyArea.style.height = "150px"; frequencyArea.style.float = "right"; frequencyArea.style.border = "1px solid #ccc"; frequencyArea.style.overflowY = "auto"; frequencyArea.style.padding = "5px"; frequencyArea.style.backgroundColor = "#f9f9f9"; popup.appendChild(frequencyArea); // Add button container const buttonContainer = document.createElement("div"); buttonContainer.style.clear = "both"; buttonContainer.style.margin = "10px 0"; buttonContainer.style.display = "flex"; buttonContainer.style.justifyContent = "space-between"; popup.appendChild(buttonContainer); // Add buttons const analyzeButton = document.createElement("button"); analyzeButton.textContent = "Analyze Frequency"; buttonContainer.appendChild(analyzeButton); const generateButton = document.createElement("button"); generateButton.textContent = "Generate +"; buttonContainer.appendChild(generateButton); const copyButton = document.createElement("button"); copyButton.textContent = "Copy"; buttonContainer.appendChild(copyButton); const clearButton = document.createElement("button"); clearButton.textContent = "Clear"; buttonContainer.appendChild(clearButton); const closeButton = document.createElement("button"); closeButton.textContent = "Close"; buttonContainer.appendChild(closeButton); // Output box for generated content const outputArea = document.createElement("textarea"); outputArea.style.width = "100%"; outputArea.style.height = "80px"; outputArea.style.marginTop = "10px"; outputArea.style.backgroundColor = "#f9f9f9"; outputArea.style.border = "1px solid #ccc"; outputArea.readOnly = true; popup.appendChild(outputArea); // Show/hide popup button.addEventListener("click", () => { popup.style.display = popup.style.display === "none" ? "block" : "none"; }); // Analyze word frequency analyzeButton.addEventListener("click", () => { const text = inputArea.value; const words = text.split(/\s+/).filter(word => word && !excludedWords.includes(word.toLowerCase()) && !excludedSymbols.test(word)); const frequency = words.reduce((freq, word) => { word = word.toLowerCase(); freq[word] = (freq[word] || 0) + 1; return freq; }, {}); // Populate frequency area frequencyArea.innerHTML = ""; Object.keys(frequency) .sort((a, b) => frequency[b] - frequency[a]) .forEach(word => { const checkbox = document.createElement("input"); checkbox.type = "checkbox"; checkbox.value = word; checkbox.style.marginRight = "5px"; const label = document.createElement("label"); label.textContent = `${word} (${frequency[word]})`; const div = document.createElement("div"); div.appendChild(checkbox); div.appendChild(label); frequencyArea.appendChild(div); }); }); // Generate "+" keywords generateButton.addEventListener("click", () => { const selectedWords = Array.from(frequencyArea.querySelectorAll("input[type=checkbox]:checked")).map(input => input.value); outputArea.value = selectedWords.map(word => `+${word}`).join(" "); }); // Copy to clipboard copyButton.addEventListener("click", () => { if (outputArea.value.trim() !== "") { GM_setClipboard(outputArea.value); alert("Copied to clipboard!"); } else { alert("No content to copy!"); } }); // Clear all fields clearButton.addEventListener("click", () => { inputArea.value = ""; frequencyArea.innerHTML = ""; outputArea.value = ""; }); // Close popup closeButton.addEventListener("click", () => { popup.style.display = "none"; }); })();