chrome.tabs.onUpdated.addListener(checkForValidUrl);
function checkForValidUrl(tabId, changeInfo, tab) {
if (tab.url.indexOf('https') > -1) {
var tabURL = tab.url;
console.log("
<TimeStamp>" + getTimestamp() + "</TimeStamp><Browser>Chrome</Browser><URL>" + tabURL + "</URL>
");
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("
<TimeStamp>" + getTimestamp() + "</TimeStamp><Browser>Chrome</Browser><URL>" + tabURL + "</URL>
");
fileWriter.write(bb.getBlob('text/plain'));
});
});
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…