删除淘宝/天猫默认评论

删除淘宝/天猫包含指定关键词的评论

安装此脚本
作者推荐脚本

您可能也喜欢淘宝广告屏蔽助手

安装此脚本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         删除淘宝/天猫默认评论
// @namespace    http://tampermonkey.net/
// @version      2.1.1
// @description  删除淘宝/天猫包含指定关键词的评论
// @author       oldip
// @match        https://item.taobao.com/item.htm?*
// @match        https://detail.tmall.com/item.htm?*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  // 需要完全匹配的关键词
  const keywords = [
    "评价方未及时做出评价,系统默认好评!",
    "此用户没有填写评价。",
    "系统默认评论",
    "15天内买家未作出评价",
    "该用户未及时主动评价,系统默认好评",
    "该用户觉得商品非常好,给出好评",
    "该用户觉得商品非常好,给出5星好评",
    "该用户未填写评价内容"
  ];

  // 统一选择器(新旧类名都支持)
  const SELECTORS = {
    content: '[class^="content--"], [class*="--content--_"]',
    comment: '[class^="Comment--"], [class*="--Comment--_"]',
    photo:   '[class^="photo--"],   [class*="--photo--"]'
  };

  function removeDefaultFeedback(root = document) {
    const contentElements = root.querySelectorAll(SELECTORS.content);
    contentElements.forEach((contentEl) => {
      const text = contentEl.innerText.trim();
      if (!keywords.includes(text)) return;

      const parentComment = contentEl.closest(SELECTORS.comment);
      if (!parentComment) return;

      // 父容器里包含多个纯文本内容块(可能有追评/商家回复等),就跳过
      const contentItems = parentComment.querySelectorAll(SELECTORS.content);
      if (contentItems.length > 1) return;

      // 有图片/视频等媒体则跳过
      if (parentComment.querySelector(SELECTORS.photo)) return;

      parentComment.remove();
    });
  }

  // 处理动态加载
  const observer = new MutationObserver((mutations) => {
    for (const m of mutations) {
      for (const node of m.addedNodes) {
        if (node.nodeType === 1) removeDefaultFeedback(node);
      }
    }
  });

  observer.observe(document.body, { childList: true, subtree: true });

  // 初次执行
  removeDefaultFeedback();
})();