From 2350000cfb89803a74b2d6b463d743014d4a188e Mon Sep 17 00:00:00 2001 From: Thomas Buckley-Houston Date: Sat, 23 Jun 2018 18:51:14 +0800 Subject: [PATCH] Add time stamp to HTML raw text --- webext/src/dom/serialise_mixin.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/webext/src/dom/serialise_mixin.js b/webext/src/dom/serialise_mixin.js index 403354a..7a34e48 100644 --- a/webext/src/dom/serialise_mixin.js +++ b/webext/src/dom/serialise_mixin.js @@ -42,7 +42,8 @@ export default (MixinBase) => class extends MixinBase { raw_text += "\n"; } const head = `${document.title}
`
-    info += "\n\n" + 'Built by Browsh'
+    const date_time = this._getCurrentDataTime();
+    info += "\n\n" + `Built by Browsh on ${date_time}`
     if (this.dimensions.is_page_truncated) {
       info += '\nBrowsh parser: the page was too large, some text may have been truncated.';
     }
@@ -50,6 +51,21 @@ export default (MixinBase) => class extends MixinBase {
     return head + raw_text + foot;
   }
 
+  _getCurrentDataTime() {
+    let current_date = new Date();
+    const offset = -(new Date().getTimezoneOffset() / 60);
+    const sign = offset > 0 ? "+" : "-";
+    let date_time = current_date.getDate() + "/"
+      + (current_date.getMonth()+1)  + "/"
+      + current_date.getFullYear() + "@"
+      + current_date.getHours() + ":"
+      + current_date.getMinutes() + ":"
+      + current_date.getSeconds() + " "
+      + "UTC" + sign + offset + " ("
+      + Intl.DateTimeFormat().resolvedOptions().timeZone +")";
+    return date_time;
+  }
+
   // TODO: Ultimately we're going to need to know exactly which parts of the input
   //       box are obscured. This is partly possible using the element's computed
   //       styles, however this isn't comprehensive - think partially obscuring.