火狐浏览器122.0。扩展。当与协议 url 一起使用时,“chrome.scripting.executeScript”会从 url 中删除“:”(冒号)

问题描述 投票:0回答:1

以下 Firefox 扩展(插件)代码在 Firefox 122.0 版本之前都可以正常运行:

background.js:

function openUrl(url) {
    window.open(url, '_self');
}

function play(url) {
    chrome.tabs.query( {currentWindow: true, active : true}, function(tabs) {
        let urlFinaly = "potplayer://" + url;
        if (devMode) console.log(urlFinaly);
        chrome.scripting.executeScript({target: {tabId: tabs[0].id}, func: openUrl, args: [urlFinaly]});
    });
}

在 Firefox 控制台中打印:

potplayer://https://www.youtube.com/watch?v=Qo_cAmJMPx4

但是在 PotPlayer(Windows 的外部视频播放器)中我得到

https//
而不是
https://
:

对于 Firefox 121.* 及更早版本,它可以正常工作,并且对于最新的 Google Chrome 浏览器也可以正常工作 - 链接可以成功正确地传递到 PotPlayer

如何修复新版本的 Firefox?

firefox google-chrome-extension firefox-addon chrome-extension-manifest-v3
1个回答
0
投票

收到来自bugzilla

的答复

您可以将代码更改为:

let urlFinaly = "potplayer:" + url; instead?

这应该创建一个看起来像

potplayer:https://www.youtube.com/watch?v=Qo_cAmJMPx4
的 URL,并且应该可以将 URL 传递给外部程序。

https://jsdom.github.io/whatwg-url/#url=cG90cGxheWVyOmh0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9UW9fY0FtSk1QeDQ=&base=YWJvdXQ6Ymxhbms=

现在可以了

© www.soinside.com 2019 - 2024. All rights reserved.