Discourse程序的新特性感觉把大多数的不是最高版本浏览器用户都拦截掉了。

Discourse程序的更新到新版后,这个新特性,其实拦截了大部分浏览器。


而未登录用户还勉强可以看


事实上,我在长期ESR支持频道,还在支持LTS期,也是被Discourse程序的这个新特性拦截的了。


可以直接注入css,让页面强制显示,而不用升级浏览器。

// ==UserScript==
// @name         nodeloc old Browser
// @namespace    http://tampermonkey.net/
// @version      3.0
// @author       human
// @match        https://6waed6lo6phn6.pages.dev/*
// @run-at       document-start
// @grant        none
// @updateURL    
// @downloadURL  
// ==/UserScript==

(function() {
    'use strict';
    const originalSupports = CSS.supports;
    const spoofTargets = new Set([
        "aspect-ratio: 1",
        "(aspect-ratio: 1)",
        "aspect-ratio",
        "(color: hsl(from white h s l))",
        "color: hsl(from white h s l)",
        "(color: hsl(from red h s l))",
        "color: hsl(from red h s l)",
        "(color: rgb(from white r g b))",
        "color: rgb(from white r g b)",
        "(color: oklch(from white l c h))",
        "color: oklch(from white l c h)",
        "(grid-template-rows: subgrid)",
        "grid-template-rows: subgrid",
        "(grid-template-columns: subgrid)",
        "grid-template-columns: subgrid",
        "grid-template: subgrid",
        "(grid-template: subgrid)"
    ]);
    const spoofProperties = new Map([
        ["aspect-ratio", ["1", "auto", "16/9", "4/3"]],
        ["grid-template-rows", ["subgrid"]],
        ["grid-template-columns", ["subgrid"]],
        ["grid-template", ["subgrid"]],
        ["color", [
            "hsl(from white h s l)",
            "hsl(from red h s l)", 
            "rgb(from white r g b)",
            "oklch(from white l c h)"
        ]]
    ]);
    function normalizeCondition(condition) {
        if (typeof condition !== 'string') return condition;
        let normalized = condition.trim().toLowerCase();
        if (!normalized.startsWith('(') && !normalized.endsWith(')')) {
            if (normalized.includes(':')) {
                normalized = `(${normalized})`;
            }
        }
        
        return normalized;
    }

    function shouldSpoof(conditionText, property = null, value = null) {
        const normalized = normalizeCondition(conditionText);

        if (spoofTargets.has(normalized)) {
            return true;
        }
        
        if (property && value && spoofProperties.has(property.toLowerCase())) {
            const allowedValues = spoofProperties.get(property.toLowerCase());
            return allowedValues.some(allowedValue => 
                value.toLowerCase().includes(allowedValue.toLowerCase())
            );
        }
        

        if (normalized.includes('from') && normalized.includes('hsl')) {
            return true;
        }
        if (normalized.includes('from') && normalized.includes('rgb')) {
            return true;
        }
        if (normalized.includes('from') && normalized.includes('oklch')) {
            return true;
        }
        if (normalized.includes('subgrid')) {
            return true;
        }
        if (normalized.includes('aspect-ratio')) {
            return true;
        }
        
        return false;
    }

    CSS.supports = function(...args) {
        let conditionText, property, value;
        
        try {
            if (args.length === 1) {
                conditionText = args[0];
                
                if (shouldSpoof(conditionText)) {
                    console.log(`[Enhanced CSS Spoof] ✅ Spoofed single-arg: "${conditionText}"`);
                    return true;
                }
                
            } else if (args.length === 2) {
                // 双参数形式:CSS.supports("color", "hsl(from white h s l)")
                property = args[0];
                value = args[1];
                conditionText = `(${property}: ${value})`;
                
                if (shouldSpoof(conditionText, property, value)) {
                    console.log(`[Enhanced CSS Spoof] ✅ Spoofed dual-arg: "${property}" : "${value}"`);
                    return true;
                }
                
            } else {
                // 参数数量不正确,调用原始函数
                return originalSupports.apply(this, args);
            }
            
            // 如果不是目标特性,调用原始函数获取真实结果
            return originalSupports.apply(this, args);
            
        } catch (error) {
            // 发生错误时,回退到原始函数
            console.warn('[Enhanced CSS Spoof] Error in spoof logic, falling back to original:', error);
            return originalSupports.apply(this, args);
        }
    };

    // 额外的兼容性处理:确保CSS对象存在
    if (typeof CSS === 'undefined') {
        window.CSS = {
            supports: function() {
                // 对于非常老的浏览器,直接欺骗
                return shouldSpoof(arguments[0], arguments[1], arguments[2]);
            }
        };
        console.log('[Enhanced CSS Spoof] ⚠️  Created CSS object for legacy browser');
    }

    console.log('[Enhanced CSS Spoof] 🚀 Script loaded successfully');
    console.log('[Enhanced CSS Spoof] 📋 Spoofing targets:', Array.from(spoofTargets));

})();

事实上,部分用户打不开,其实就直接不看了,升级浏览器比较对他们来说比较麻烦。

7 个赞

我手机因为系统版本太低,没法装最新的浏览器。
所以我都不用手机浏览器登陆论坛了。都是用电脑。

可以安装火狐,火狐兼容性强些

我是通过油猴直接注入css,让页面显示而上来的。

我在ESXI里装了WIN10,这也是24小时不关机。

需要的话就直接远程连接就可以了。
还是挂一些别的东西

确实是这样,感觉新特性限制的有点太高了

毕竟要做兼容性的话,包袱太重了。本身Discourse性能和饿兼容性就不算好的

我们 iPhone 7 用户是最惨的了,Discourse 现在已经淘汰 iOS 15 及以下版本的设备了,浏览器版本跟系统版本挂钩的,苹果不让升级系统,浏览器都是 Safari 套壳,油猴脚本也用不了

安卓可能行,苹果装火狐还是 Safari 套壳

1 个赞

感谢大佬分享解决方法

:hand_with_index_finger_and_thumb_crossed:

这方法是“绝招”,收藏了!

是啊 有好几个浏览器都不显示了

我用via浏览没有问题

我才125

看看谢谢

感谢大佬的分享

非常感谢,解决我的问题!

虽然我用不到,但是支持支持(兼容性确实砍的太狠了,这样干win7用户原地爆炸ing)

可能就是没考虑兼容

感谢大佬