Steam 评论过滤

移除Steam中与游戏无关的评论

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

// ==UserScript==
// @name         Steam 评论过滤
// @namespace    https://mopokle.github.io
// @version      1.0
// @description  移除Steam中与游戏无关的评论
// @author       Mopokle
// @match        https://store.steampowered.com/app/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to check if a comment contains any of the specified phrases
    function containsUnwantedText(commentElement) {
        const unwantedPhrases = ["我是傻", "朋友口","请奖励这条评论","心中有党","这么多年都是这个价格","这里养了一","摸一下","牛子精灵","坤坤","牛子增加","一个赞封","⣿⠿⠶⠙⣿⡟⠡⣴⣿⣽⣿","⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭",
                                 "牛子加","牛子变","牛子缩","给我点赞","涩涩的头像","想要头像","色色的头像","需要点数","steam点数","Steam点数","STEAM点数","免费摸","赞=","点赞摸","摸赞一次"];
        let commentText = commentElement.textContent || commentElement.innerText;
        return unwantedPhrases.some(phrase => commentText.includes(phrase));
    }

    // Function to remove comments containing unwanted text
    function removeUnwantedComments() {
        const comments = document.querySelectorAll('.review_box');
        comments.forEach(comment => {
            if (containsUnwantedText(comment)) {
                comment.remove();
                //Highlight for debug
                //comment.style.border = '2px solid red';
            }
        });
    }

    // Callback function to execute when mutations are observed
    var callback = function(mutationsList, observer) {
        for(var mutation of mutationsList) {
            if (mutation.type == 'childList') {
                removeUnwantedComments();
            }
        }
    };

    // Create a MutationObserver instance
    var observer = new MutationObserver(callback);

    // Options for the observer
    var config = { childList: true, subtree: true };

    // Start observing the target node for configured mutations
    observer.observe(document.body, config);

    // Initial check
    removeUnwantedComments();
})();