gpt4 book ai didi

javascript - 在 Chrome 扩展中写入本地文件系统

转载 作者:数据小太阳 更新时间:2023-10-29 05:43:01 32 4
gpt4 key购买 nike

chrome.tabs.onUpdated.addListener(checkForValidUrl);
function checkForValidUrl(tabId, changeInfo, tab) {
if (tab.url.indexOf('https') > -1) {
var tabURL = tab.url;
console.log("\n<TimeStamp>" + getTimestamp() + "</TimeStamp><Browser>Chrome</Browser><URL>" + tabURL + "</URL>\n");
window.requestFileSystem(window.PERSISTENT, 5 * 1024 * 1024, initFs);

function initFs(fs) {
fs.root.getFile
('log.txt', { create: true, exclusive: true }, function (fileEntry) {
fileEntry.isFile = true;
fileEntry.name = 'log.txt';
fileEntry.fullPath = '/log.txt';
fileEntry.createWriter(function (fileWriter) {
fileWriter.seek(fileWriter.length);
var bb = new BlobBuilder();
bb.append("\n<TimeStamp>" + getTimestamp() + "</TimeStamp><Browser>Chrome</Browser><URL>" + tabURL + "</URL>\n");
fileWriter.write(bb.getBlob('text/plain'));
});
});
}
}
}

最佳答案

基于此:

At the time of writing this article, Google Chrome 9+ has the only working implementation of the FileSystem API. Since a dedicated browser UI does not yet exist for file/quota management, the API cannot be used without running Chrome with the --unlimited-quota-for-files flag (Note: if you're building an app or extension for the Chrome Web Store, the unlimitedStorage manifest file permission will suffice).

发现于 http://www.html5rocks.com/tutorials/file/filesystem/#toc-support

我假设您使用的是 Chrome,并且您没有设置 --unlimited-quota-for-files 标志

关于javascript - 在 Chrome 扩展中写入本地文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5429513/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com