webhistory.js 1.1 KB

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