webhistory.js 950 B

12345678910111213141516171819202122232425262728293031
  1. const { URL } = require('url')
  2. module.exports.name = 'webhistory'
  3. module.exports.description = 'List all web history'
  4. // Specify this reporter requires a backup.
  5. // The second parameter to func() is now a backup instead of the path to one.
  6. module.exports.requiresBackup = true
  7. // Specify this reporter supports the promises API for allowing chaining of reports.
  8. module.exports.usesPromises = true
  9. // Specify this only works for iOS 9+
  10. module.exports.supportedVersions = '>=9.0'
  11. module.exports.func = function (program, backup, resolve, reject) {
  12. backup.getWebHistory(program.dump)
  13. .then((history) => {
  14. var result = program.formatter.format(history, {
  15. program: program,
  16. columns: {
  17. 'Time': el => el.XFORMATTEDDATESTRING,
  18. 'URL': el => new URL(el.url || '').origin || '',
  19. 'Title': el => (el.title || '').substring(0, 64)
  20. }
  21. })
  22. resolve(result)
  23. })
  24. .catch(reject)
  25. }