Skip to content

Instantly share code, notes, and snippets.

@StephenBrown
Forked from stoyan/jsperf-bookmarklet.js
Last active March 25, 2020 18:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save StephenBrown/4954367 to your computer and use it in GitHub Desktop.
Save StephenBrown/4954367 to your computer and use it in GitHub Desktop.
Bookmarklet for one click webpagetest. Dulles, Chrome, DSL, captures video, tcpdump, and a repeat view.
(function(){
var key = localStorage.wpt_key;
if (!key) {
var prompt = window.__proto__.prompt;
key = prompt('Your WebPagetest API key, please?');
if (!key) {
return gameOver();
}
localStorage.wpt_key = key;
}
// base params
var wpt = 'http://www.webpagetest.org/runtest.php?';
var params = {
k: key,
runs: 1,
video: 1,
tcpdump: 1,
url: location.href
};
Object
.keys(params)
.forEach(function(key) {
wpt += key + '=' + encodeURIComponent(params[key]) + '&';
});
var locations = localStorage.wpt_locations;
if (!locations) {
locations = ['Dulles:Chrome.DSL'];
}
// pop some windows up
var open = window.__proto__.open;
locations.forEach(function(loco){
open(wpt + 'location=' + encodeURIComponent(loco));
});
gameOver();
function gameOver() {
console.log('JSPerf bookmarklet help: http://phpied.com/jsperf-bookmarklet');
console.log('If broken, check your localStorage.wpt_key and wpt_locations');
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment