Greasy Fork

来自缓存

Greasy Fork is available in English.

Steam Community Ignore

Hides posts from specific users.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Steam Community Ignore
// @namespace    http://greasyfork.icu/users/5097-aemony
// @version      0.3
// @description  Hides posts from specific users.
// @author       Aemony
// @match        *://steamcommunity.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // SteamID3 of profiles to hide, comma delimited, use https://steamid.xyz/ to look one up.
    // Only use the last numbers of the ID, so if the SteamID3 is 'U:1:12345678' you should only add '12345678' in the array.
    let profilesToIgnore = []; // example: let profilesToIgnore = ['12345678', '23456789']
    
    // ==code past this point==
    
    // detects if we're on a page with a comment thread or not
    var target = document.getElementsByClassName('commentthread_comments');
    
    if(target.length > 0)
    {
        // add an observer to the comment thread
        var config = { childList: true };
        var observer = new MutationObserver(function() {
            // runs the function when the comment thread changes
            hideProfiles();
        });
        observer.observe(target[0], config);

        // runs the function once when the page initially loads
        hideProfiles();
    }
    
    function hideProfiles() {
        profilesToIgnore.forEach(function(profile) {
            
            // add '.forum_op a[data-miniprofile="${profile}"]' to the call below to filter out the opening post in a forum thread as well
            let matches = document.querySelectorAll(`.commentthread_comments a[data-miniprofile="${profile}"]:not(.commentthread_author_link)`);
            
            if(matches.length > 0) {
                // logs the number of posts that were hidden in the console
                console.log(`Found ${matches.length} posts to hide from ${profile}.`);
                matches.forEach(function(element) {
                    element.parentElement.parentElement.style.display = 'none';
                });
            }
        });
    }
})();