如何获取所有 chrome 内容设置?

How to get all chrome content settings?

Google Chrome 不同步所有内容设置,特别是 Cookie 规则。 同时 JavaScript 设置同步正常。

我正在尝试查询所有 cookie 阻止域的列表,以便我可以通过扩展使用我自己的存储来同步它们。通配符模式仅在指定 TLD 时才有效。

chrome.contentSettings.cookies.get({
    primaryUrl: 'https://example.com' //---Not working '<all_urls>' or 'https://*/*"'
}, function (details) {
    console.log(details)
});

我可以直接从扩展程序中查询 chrome://settings/content/cookies 作为网页吗? 还有其他想法吗?

Chrome content settings 的文档似乎支持 '<all_urls>',但它仅适用于 'set',不适用于 'get'。

你需要用http://*https://*http://somesite.com/等值指定primaryUrl,然后你会得到details.setting

另请注意我在访问下面函数末尾的信息之前使用的延迟。

 function GetContentSettings(){

 var S='';

 chrome.contentSettings.cookies.get({primaryUrl:'http://*'},function(details){S+='Cookies : '+details.setting+'<br>';});
 chrome.contentSettings.images.get({primaryUrl:'http://*'},function(details){S+='Images : '+details.setting+'<br>';});
 chrome.contentSettings.javascript.get({primaryUrl:'http://*'},function(details){S+='JavaScript : '+details.setting+'<br>';});
 chrome.contentSettings.location.get({primaryUrl:'http://*'},function(details){S+='Location : '+details.setting+'<br>';});
 chrome.contentSettings.plugins.get({primaryUrl:'http://*'},function(details){S+='Plugins : '+details.setting+'<br>';});
 chrome.contentSettings.popups.get({primaryUrl:'http://*'},function(details){S+='Popups : '+details.setting+'<br>';});
 chrome.contentSettings.notifications.get({primaryUrl:'http://*'},function(details){S+='Notifications : '+details.setting+'<br>';});
 // chrome.contentSettings.fullscreen.get({primaryUrl:'http://*'},function(details){S+='Full Screen : '+details.setting+'<br>';});
 // chrome.contentSettings.mouselock.get({primaryUrl:'http://*'},function(details){S+='Mouse Lock : '+details.setting+'<br>';});
 chrome.contentSettings.microphone.get({primaryUrl:'http://*'},function(details){S+='Microphone : '+details.setting+'<br>';});
 chrome.contentSettings.camera.get({primaryUrl:'http://*'},function(details){S+='Camera : '+details.setting+'<br>';});
 chrome.contentSettings.unsandboxedPlugins.get({primaryUrl:'http://*'},function(details){S+='Unsandboxed Plugins : '+details.setting+'<br>';});
 chrome.contentSettings.automaticDownloads.get({primaryUrl:'http://*'},function(details){S+='Automatic Downloads : '+details.setting+'<br>';});

 setTimeout(function(){alert('Content Settings...<br><br>'+S);},1500);
 }

注意:我已经把麻烦的两个注释掉了。