Steam 评论过滤

移除Steam商店和社区评论中与游戏无关的评论元素(领导人画像,索要点数等)

目前为 2023-12-03 提交的版本。查看 最新版本

// ==UserScript==
// @name         Steam 评论过滤
// @namespace    mopokle
// @version      1.2
// @description  移除Steam商店和社区评论中与游戏无关的评论元素(领导人画像,索要点数等)
// @author       Mopokle
// @match        https://store.steampowered.com/app/*
// @match        https://steamcommunity.com/app/*/reviews/*
// @grant        none
// @license      MIT
// @homepage     https://greasyfork.org/zh-CN/scripts/481301
// ==/UserScript==

(function() {
    'use strict';
    // 匹配的短语列表
    const unwantedPhrases = ["我是傻", "口了一","领导人画像","请奖励这条评论","心中有党","这么多年都是这个价格","这里养了一","免费的赞","摸一下","牛子精灵","牛子牛子","坤坤","牛子增加","一个赞封","⣿⠿⠶⠙⣿⡟⠡⣴⣿⣽⣿","⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭","⣿⣿⣿⢛⣵⠇⡇⣿⣿⣿",
                                 "牛子加","牛子变","点赞牛纸","牛子节","牛子缩","给我点赞","涩涩的头像","想要头像","色色的头像","需要点数","我要点数","steam点数","Steam点数","STEAM点数","点数奖励","免费摸","赞=","点赞摸","摸赞一次"];

    // 检查评论是否包含不需要的短语
    function containsUnwantedText(commentElement) {
        let commentText = commentElement.textContent || commentElement.innerText;
        return unwantedPhrases.some(phrase => commentText.includes(phrase));
    }

    // 移除函数
    function removeUnwantedComments() {
        // 选择 Steam 商店和社区的选择器
        const storeComments = document.querySelectorAll('.review_box');
        const communityComments = document.querySelectorAll('.apphub_Card');
        const allComments = [...storeComments, ...communityComments];

        allComments.forEach(comment => {
            if (containsUnwantedText(comment)) {
                comment.remove();
                //comment.style.border = '2px solid red'; //Debug用高亮
            }
        });
    }

    // 当 DOM 发生变化时执行回调函数
    var callback = function(mutationsList, observer) {
        for(var mutation of mutationsList) {
            if (mutation.type == 'childList') {
                removeUnwantedComments();
            }
        }
    };

    // 创建 MutationObserver 实例以观察 DOM 变化
    var observer = new MutationObserver(callback);
    var config = { childList: true, subtree: true };
    observer.observe(document.body, config);

    removeUnwantedComments();
})();