Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion extension/devtools/views/SitemapScrapeConfig.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<input type="text" class="form-control" name="requestInterval" id="requestInterval" placeholder="Request interval" value="2000">
</div>
</div>
<div class="form-group">
<label for="requestIntervalRandomness" class="col-lg-1 control-label">Request interval randomness (ms)</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="requestIntervalRandomness" id="requestIntervalRandomness" placeholder="Request interval randomness" value="0">
</div>
</div>
<div class="form-group">
<label for="pageLoadDelay" class="col-lg-1 control-label">Page load delay (ms)</label>
<div class="col-lg-10">
Expand All @@ -23,4 +29,4 @@
</div>
</div>
</form>
</div>
</div>
14 changes: 12 additions & 2 deletions extension/scripts/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,16 @@ SitemapController.prototype = {
}
}
},
"requestIntervalRandomness": {
validators: {
notEmpty: {
message: 'The request interval randomness is required and cannot be empty'
},
numeric: {
message: 'The request interval randomness must be numeric'
},
}
},
"pageLoadDelay": {
validators: {
notEmpty: {
Expand Down Expand Up @@ -1042,7 +1052,7 @@ SitemapController.prototype = {
$("#viewport").html(dataPanel);

// display data
// Doing this the long way so there aren't xss vulnerubilites
// Doing this the long way so there aren't xss vulnerubilites
// while working with data or with the selector titles
var $tbody = $("#sitemap-data tbody");
data.forEach(function (row) {
Expand Down Expand Up @@ -1407,7 +1417,7 @@ SitemapController.prototype = {
// remove from validator
var validator = this.getFormValidator();
validator.removeField($block.find("input"));

$block.remove();
}
}
Expand Down
5 changes: 3 additions & 2 deletions extension/scripts/Scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Scraper = function (options) {
this.browser = options.browser;
this.resultWriter = null; // db instance for scraped data writing
this.requestInterval = parseInt(options.requestInterval);
this.requestIntervalRandomness = parseInt(options.requestIntervalRandomness);
this.pageLoadDelay = parseInt(options.pageLoadDelay);
};

Expand Down Expand Up @@ -187,7 +188,7 @@ Scraper.prototype = {

var now = (new Date()).getTime();
// delay next job if needed
this._timeNextScrapeAvailable = now + this.requestInterval;
this._timeNextScrapeAvailable = now + this.requestInterval + Math.random()*this.requestIntervalRandomness;
if(now >= this._timeNextScrapeAvailable) {
this._run();
}
Expand All @@ -202,4 +203,4 @@ Scraper.prototype = {

}.bind(this));
}
};
};