![](/img/trans.png)
[英]Google Extension HostEquals for chrome.history.deleteUrl or chrome.browsingData.remove
[英]Using chrome.browsingData.remove() in incognito mode
我的擴展程序在我的后台頁面中使用以下代碼行刪除了在Google Chrome中進行的下載:
chrome.browsingData.remove({ "since": 0 }, { "downloads": true });
當下載處於正常窗口時,無論何時在隱身Chrome窗口中進行下載,都不會將其刪除。 我的擴展程序在隱身模式下激活,后台頁面可以檢測隱身頁面中的下載何時完成,方法是:
chrome.downloads.onChanged.addListener(function(download) {
if (download.state && download.state.current == "complete") {
// The code here is fired even if the download has been completed in incognito mode
}
}
有沒有辦法從背景頁面中刪除隱身窗口中的瀏覽數據?
您遇到的問題是您的擴展程序正在spanning
隱身模式運行 。 這意味着擴展程序在連接到安裝擴展程序的配置文件(即不是隱身窗口)的單個進程下運行。 在這種情況下, chrome.downloads
API會在隱身和普通配置文件中觸發onChanged
事件以進行下載,但chrome.browsingData
API僅適用於普通配置文件。
相反,您想要使用split
隱身模式。 這意味着擴展程序在使用它的每個配置文件中單獨運行(即隱身窗口獲得其自己的擴展運行副本)。 這意味着當您調用chrome.browsingData
API時,它將應用於觸發事件的窗口。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.