以下 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?
收到来自bugzilla
的答复您可以将代码更改为:
let urlFinaly = "potplayer:" + url; instead?
这应该创建一个看起来像
potplayer:https://www.youtube.com/watch?v=Qo_cAmJMPx4
的 URL,并且应该可以将 URL 传递给外部程序。
现在可以了