title: Writing to local file system in Chrome extension
body: <pre><code>chrome.tabs.onUpdated.addListener(checkForValidUrl);
  function checkForValidUrl(tabId, changeInfo, tab) {
      if (tab.url.indexOf('https') &gt; -1) {
          var tabURL = tab.url;
          console.log("\n&lt;TimeStamp&gt;" + getTimestamp() + "&lt;/TimeStamp&gt;&lt;Browser&gt;Chrome&lt;/Browser&gt;&lt;URL&gt;" + tabURL + "&lt;/URL&gt;\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&lt;TimeStamp&gt;" + getTimestamp() + "&lt;/TimeStamp&gt;&lt;Browser&gt;Chrome&lt;/Browser&gt;&lt;URL&gt;" + tabURL + "&lt;/URL&gt;\n");
                      fileWriter.write(bb.getBlob('text/plain'));
                  });
              });
          }
      }
  }
  </code></pre>