Amazon Keyword Modifier

自动为关键词添加“+”号,跳过数字、量词和介词

目前為 2025-01-17 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Amazon Keyword Modifier
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  自动为关键词添加“+”号,跳过数字、量词和介词
// @author       You
// @match        https://www.amazon.*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 定义要跳过的量词和介词
    const skipWords = [
        "for", "in", "on", "at", "with", "by", "to", "of", "and", "or", "the", "a", "an", 
        "is", "are", "was", "were", "be", "been", "am", "as", "but", "if", "then"
    ];

    // 检查是否为数字
    function isNumber(word) {
        return /^\d+$/.test(word);
    }

    // 处理输入内容
    function processKeywords(input) {
        return input.split(" ").map(word => {
            if (isNumber(word) || skipWords.includes(word.toLowerCase())) {
                return word;
            }
            return "+" + word;
        }).join(" ");
    }

    // 创建输入框和按钮
    function createUI() {
        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.borderRadius = "5px";
        container.style.boxShadow = "0 2px 5px rgba(0, 0, 0, 0.2)";
        container.style.zIndex = "9999";

        const input = document.createElement("input");
        input.type = "text";
        input.placeholder = "输入关键词";
        input.style.width = "300px";
        input.style.marginRight = "10px";

        const button = document.createElement("button");
        button.textContent = "生成";
        button.style.cursor = "pointer";

        const output = document.createElement("div");
        output.style.marginTop = "10px";
        output.style.color = "#333";

        button.addEventListener("click", () => {
            const processed = processKeywords(input.value);
            output.textContent = processed;
        });

        container.appendChild(input);
        container.appendChild(button);
        container.appendChild(output);

        document.body.appendChild(container);
    }

    // 初始化界面
    createUI();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址