我正在嘗試在 Firefox 擴展中重定向用戶,如下所示:browser.webRequest.onBeforeRequest.addListener( ({ url }) => { const [fullMatch, type, identifier] = url.match( /open\.spotify\.com\/(track|album|artist|playlist|concert|episode|show|user)\/([^\&\#\/\?]+)/i ) || []; return { redirectUrl: `spotify:${type}:${identifier}` }; }, { urls: ["*://open.spotify.com/track/*", "*://open.spotify.com/album/*", "*://open.spotify.com/artist/*", "*://open.spotify.com/playlist/*", "*://open.spotify.com/concert/*", "*://open.spotify.com/episode/*", "*://open.spotify.com/show/*", "*://open.spotify.com/user/*"], types: ["xmlhttprequest"], }, ["blocking"]);我已在清單中添加了 webRequest 和 webRequestBlocking 權限。在調試器中,我看到我到達了正確設置了redirectUrl 的return 語句,但網頁沒有重定向。我認為這應該根據webRequest 文檔進行重定向,但是臨時擴展似乎沒有重定向。關于如何使擴展程序重定向有什么想法嗎?例如,將 url 更改為https://www.google.com也不起作用,因此問題似乎不在于 URL。
Firefox 擴展中的 BlockingResponse
叮當貓咪
2023-11-02 22:48:40