You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firefox 122.0扩展中chrome.scripting.executeScript丢失URL冒号问题修复咨询

Firefox 122+ 修复Steam协议链接冒号丢失问题

问题原因

Firefox 122版本对chrome.scripting.executeScript的参数传递逻辑做了调整,当传递包含多冒号的协议链接(如steam://https://xxx)时,内部解析机制会错误移除第二个冒号,导致Windows程序收到的链接缺失冒号。

修复方案

方案1:直接用后台API打开协议链接(推荐)

不需要注入内容脚本,直接在后台页调用chrome.tabs.update加载Steam协议链接,绕过参数传递的解析问题:

function play(url) {
    let urlFinaly = "steam://" + url;
    if (devMode) console.log(urlFinaly);
    // 直接更新当前标签页URL为Steam协议链接
    chrome.tabs.update({url: urlFinaly});
}

方案2:修改内容脚本参数传递方式

如果必须保留内容脚本逻辑,不要传递完整的协议链接,改为传递URL部分,在内容脚本内拼接完整链接:

function play(url) {
    chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
        if (devMode) console.log("steam://" + url);
        chrome.scripting.executeScript({
            target: {tabId: tabs[0].id},
            func: (urlPart) => {
                window.open(`steam://${urlPart}`, '_self');
            },
            args: [url]
        });
    });
}

两种方案都能避免Firefox对参数的异常解析,保证Steam协议链接完整传递给Windows程序,且兼容Firefox 122+、旧版Firefox及Chrome。

内容的提问来源于stack exchange,提问作者user924

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 18:44:57