Show not checked content

Shows content hidden by Valve's automated content check system

目前为 2020-08-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         Show not checked content
// @namespace    https://gf.qytechs.cn/users/2205
// @version      0.2
// @description  Shows content hidden by Valve's automated content check system
// @author       Ryzhehvost
// @license      Apache-2.0
// @match        https://steamcommunity.com/groups/*/discussions/*
// @match        https://steamcommunity.com/discussions/forum/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
/* global g_rgForumTopicCommentThreads */
/* global g_rgForumTopics*/
function GetText( gidTopic, gidComment )
{
	var CommentThread = g_rgForumTopicCommentThreads[gidTopic];
	var rgRawComment;
	if ( gidComment && gidComment != -1 )
	{
		rgRawComment = CommentThread.GetRawComment( gidComment );
	}
	else
	{
		// topic quoting
		rgRawComment = g_rgForumTopics[gidTopic].m_rgRawData;
	}
    return rgRawComment.text;
}

function FormatBBCode(text){
    console.log(text);
    let re = /[noparse](.*)[/noparse]/g;
    let noparse = text.match(re);
    re = /\[h1\](.*?)\[\/h1\]/g;
    text = text.replace(re, '<div class="bb_h1">$1</div>');
    console.log(text);
    re = /\[b\](.*?)\[\/b\]/g;
    text = text.replace(re, '<b>$1</b>');
    console.log(text);
    re = /\[u\](.*?)\[\/u\]/g;
    text = text.replace(re, '<u>$1</u>');
    console.log(text);
    re = /\[i\](.*?)\[\/i\]/g;
    text = text.replace(re, '<i>$1</i>');
    console.log(text);
    re = /\[strike\](.*?)\[\/strike\]/g;
    text = text.replace(re, '<span class="bb_strike">$1</span>');
    console.log(text);
    re = /\[spoiler\](.*)\[\/spoiler\]/g;
    text = text.replace(re, '<span class="bb_spoiler"><span>$1</span></span>');
    console.log(text);
    re = /\[url=(.*?)\](.*?)\[\/url\]/g;
    text = text.replace(re, '<a class="bb_link" href="$1" target="_blank" rel="noreferrer">$2</a>');
    console.log(text);
    re = /([^>"]|^)(http|https|ftp)(:\/\/[^\s]*)/g;
    text = text.replace(re, '$1<a class="bb_link" href="$1" target="_blank" rel="noreferrer">$2$3</a>');
    console.log(text);
    re = /\[quote=([^;]*?)\](.*?)\[\/quote\]/g;;
    text = text.replace(re, '<blockquote class="bb_blockquote with_author"><div class="bb_quoteauthor"><b>$1</b>:</div>$2</blockquote>');
    console.log(text);
    re = /\[quote=([^;]*?);(\d*)\](.*?)\[\/quote\]/g;;
    text = text.replace(re, '<blockquote class="bb_blockquote with_author"><div class="bb_quoteauthor"><b><a href="#c$2">$1</a></b>:</div>$3</blockquote>');
    console.log(text);
    re = /\[quote\](.*?)\[\/quote\]/g;;
    text = text.replace(re, '<blockquote class="bb_blockquote"><div class="bb_quoteauthor"><b>$1</b>:</div>$2</blockquote>');
    console.log(text);
    re = /\[code\](.*?)\[\/code\]/g;
    text = text.replace(re, '<div class="bb_code">$1</div>');
/*
    we still miss:
    - steam store widgets;
    - user content widgets;
    - youtube widgets;
    - numbered lists;
    - not numbered lists;
*/
    let index = 0;
    re = /\[noparse\](.*?)\[\/noparse\]/g;
    text = text.replace(re,() => noparse[index++]);
    console.log(text);
    return text;
}

function FixComments (comments){
    for (let i=comments.length-1; i>=0; i--) {
        let parent = comments[i].parentNode;
        let gidComment = parent.id.split('_')[2];
        parent.innerHTML = FormatBBCode(GetText( gidTopic, gidComment));
    }
}

    let re = /.*discussions\/\d+\/(\d+)/g;
    let res = re.exec(document.URL);
    if (res===null){
        re = /.*forum\/\d+\/(\d+)/g;
        res = re.exec(document.URL);
    }
    let gidTopic = res[1];
    let comments = document.getElementsByClassName('needs_content_check');
    FixComments(comments);

    let mutationObserver = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            mutation.addedNodes.forEach( function(currentValue, currentIndex, listObj) {
                if (currentValue.nodeType == Node.ELEMENT_NODE) {
                    let comments = currentValue.querySelectorAll("div[class^='needs_content_check']");
                    FixComments(comments);
                }
            });
        });
    });
    mutationObserver.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址