chrome.extension.onRequest deprecated已经被弃用了
chrome.extension.onRequest deprecated已经被弃用了
chrome.extension.onRequest deprecated已经被弃用了
以前是这样用:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { console.log('REFERRER', request.ref); });
现在需要这样用:
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { if (message.url) { //console.log(message.url); chrome.downloads.download({ url: message.url.replace("/mw690/", "/large/"), //"http://d2u2.com/get.php?url=" + encodeURIComponent(message.url) conflictAction: 'uniquify', saveAs: false, headers:[ //{ name:"referer", value: "https://photo.weibo.com/"} //{ name:"Authorization", value: "Basic dGsdYnV6eGsdfsdsdFJBVQ=="} ] }); sendResponse({url:url}); return true; } if (message.event == "copy") { //alert("copy detected"); } sendResponse({}); return true; });
Request
was deprecated in favor of 'Message'. So instead of onRequest
you should use onMessage
, and sendMessage
as a replacement for sendRequest
.
本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/web/2022-10-04/1415.html