您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Check for prohibited words, invalid length, punctuation, and emojis in Amazon five-point descriptions and display specific errors in Chinese
当前为
// ==UserScript== // @name Amazon Five Point Description Checker by Snoopy // @namespace http://tampermonkey.net/ // @version 2.10 // @description Check for prohibited words, invalid length, punctuation, and emojis in Amazon five-point descriptions and display specific errors in Chinese // @author Snoopy // @match https://www.amazon.com/* // @match https://www.amazon.cn/* // @match https://www.amazon.co.uk/* // @match https://www.amazon.de/* // @match https://www.amazon.co.jp/* // @match https://www.amazon.fr/* // @match https://www.amazon.ca/* // @match https://www.amazon.com.au/* // @match https://www.amazon.com.br/* // @match https://www.amazon.in/* // @match https://www.amazon.com.mx/* // @grant none // ==/UserScript== (function() { 'use strict'; // Prohibited words, phrases, and emojis const prohibitedWords = [ "™", "®", "€", "…", "†", "‡", "¢", "£", "¥", "©", "±", "~", "â", "ASIN", "not applicable", "NA", "n/a", "N/A", "not eligible", "yet to decide", "to be decided", "TBD", "COPY PENDING", "eco-friendly", "environmentally friendly", "ecologically friendly", "anti-microbial", "anti-bacterial", "Made from Bamboo", "contains Bamboo", "Made from Soy", "contains Soy", "Full refund", "If not satisfied, send it back", "Unconditional guarantee with no limit", "Free", "Gift", "Warranty", "Perfect" ]; // Emoji characters (Unicode ranges) const emojiRegex = /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2300}-\u{23FF}\u{2B50}\u{2934}-\u{2935}\u{25AA}-\u{25AB}\u{2B06}\u{2194}-\u{21AA}]/u; // Quality point writing guidelines const minLength = 10; const maxLength = 255; const minPoints = 3; const prohibitedEndPunctuation = [".", ",", ";", ":", "-", "!", "?", "(", ")", "[", "]", "{", "}"]; // Function to check descriptions function checkDescriptions() { console.log("Checking descriptions..."); // Get all unordered lists that might contain five-point descriptions const descriptionLists = document.querySelectorAll('ul.a-unordered-list.a-vertical.a-spacing-small'); // Initialize an array to hold all description items let descriptions = []; // Iterate through each list and collect all li elements descriptionLists.forEach(list => { let listItems = list.querySelectorAll('li'); listItems.forEach(item => { let description = item.innerText.trim(); descriptions.push({text: description, element: item}); }); }); // If no descriptions are found, exit the function if (descriptions.length === 0) { console.log("No five-point descriptions found."); return; } console.log(`Found ${descriptions.length} descriptions.`); // Check overall point count if (descriptions.length < minPoints) { console.warn(`要点数量不足: 仅找到 ${descriptions.length} 个要点,预期至少 ${minPoints} 个。`); } // Check each description descriptions.forEach(descriptionObj => { let text = descriptionObj.text; let element = descriptionObj.element; // Check for prohibited words let foundProhibitedWords = prohibitedWords.filter(word => { if (text.toLowerCase().includes(word.toLowerCase())) { console.log(`检测到禁止词或短语 "${word}" 在文本中: "${text}"`); } return text.toLowerCase().includes(word.toLowerCase()); }); let hasProhibitedWord = foundProhibitedWords.length > 0; // Check for emojis let hasEmojis = emojiRegex.test(text); if (hasEmojis) { console.log(`检测到表情符号在文本中: "${text}"`); } // Check character length let isValidLength = text.length >= minLength && text.length <= maxLength; // Check if it starts with a capital letter let startsWithCapital = text.charAt(0) === text.charAt(0).toUpperCase(); // Check for ending punctuation let endsWithPunctuation = prohibitedEndPunctuation.some(punctuation => text.endsWith(punctuation)); // Add highlight and detailed error info if (hasProhibitedWord || hasEmojis || !isValidLength || !startsWithCapital || endsWithPunctuation) { let span = document.createElement('span'); span.style.backgroundColor = 'yellow'; span.style.display = 'block'; // Ensure it takes up the full width let errors = []; if (hasProhibitedWord) { errors.push(`包含禁止词: ${foundProhibitedWords.join(', ')}`); } if (hasEmojis) { errors.push("包含表情符号"); } if (!isValidLength) { errors.push(`字符长度无效: ${text.length} (预期在 ${minLength} 到 ${maxLength} 之间)`); } if (!startsWithCapital) { errors.push("未以大写字母开头"); } if (endsWithPunctuation) { errors.push("以禁止的标点符号结尾"); } span.textContent = ` [检测到错误: ${errors.join('; ')}]`; element.appendChild(span); } }); } // Delay execution of the function to ensure the page is fully loaded setTimeout(checkDescriptions, 5000); // Increased to 5 seconds })();