-
-
Save AndreLion/5353669 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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, | |
time: 60, | |
runs: 1, | |
fvonly: 1, | |
url: 'http://jsperf.com' + location.pathname + '#run' | |
}; | |
Object | |
.keys(params) | |
.forEach(function(key) { | |
wpt += key + '=' + encodeURIComponent(params[key]) + '&'; | |
}); | |
var locations = localStorage.wpt_locations && localStorage.wpt_locations.split(','); | |
if (!locations) { | |
locations = ['Sydney:Chrome', 'Sydney:Firefox', 'Stockholm:Safari', 'Dulles_iOS', 'Dulles_Android']; | |
} | |
// 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