• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3(function () {
4  var random_count = 0;
5  var random_count_threshold = 25;
6  var random_seed = 0.462;
7  Math.random = function() {
8    random_count++;
9    if (random_count > random_count_threshold){
10     random_seed += 0.1;
11     random_count = 1;
12    }
13    return (random_seed % 1);
14  };
15  if (typeof(crypto) == 'object' &&
16      typeof(crypto.getRandomValues) == 'function') {
17    crypto.getRandomValues = function(arr) {
18      var scale = Math.pow(256, arr.BYTES_PER_ELEMENT);
19      for (var i = 0; i < arr.length; i++) {
20        arr[i] = Math.floor(Math.random() * scale);
21      }
22      return arr;
23    };
24  }
25})();
26(function () {
27  var date_count = 0;
28  var date_count_threshold = 25;
29  var orig_date = Date;
30  // This should be replaced by web page replay by corresponding date
31  // (usually the date when the recording was done)
32  var time_seed = {{WPR_TIME_SEED_TIMESTAMP}};
33  Date = function() {
34    if (this instanceof Date) {
35      date_count++;
36      if (date_count > date_count_threshold){
37        time_seed += 50;
38        date_count = 1;
39      }
40      switch (arguments.length) {
41      case 0: return new orig_date(time_seed);
42      case 1: return new orig_date(arguments[0]);
43      default: return new orig_date(arguments[0], arguments[1],
44         arguments.length >= 3 ? arguments[2] : 1,
45         arguments.length >= 4 ? arguments[3] : 0,
46         arguments.length >= 5 ? arguments[4] : 0,
47         arguments.length >= 6 ? arguments[5] : 0,
48         arguments.length >= 7 ? arguments[6] : 0);
49      }
50    }
51    return new Date().toString();
52  };
53  Date.__proto__ = orig_date;
54  Date.prototype = orig_date.prototype;
55  Date.prototype.constructor = Date;
56  orig_date.now = function() {
57    return new Date().getTime();
58  };
59  orig_date.prototype.getTimezoneOffset = function() {
60    var dst2010Start = 1268560800000;
61    var dst2010End = 1289120400000;
62    if (this.getTime() >= dst2010Start && this.getTime() < dst2010End)
63      return 420;
64    return 480;
65  };
66})();
67