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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Date.now vs Date.prototype.getTime</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Iterating over collections of elements</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Iterating with Dates #jsbench #jsperf</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Mapping over collections of elements</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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 withMutations(records) { | |
records.forEach(function (record) { | |
var target = record.target; | |
if (extensionContains(target)) { | |
var children = target.querySelectorAll('*'); | |
Array.prototype.forEach.call(children, fixBackgroundImage); | |
} | |
}); | |
} |
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 onExtensionImgError(e) { | |
var img = e.target; | |
var tagName = img.tagName.toLowerCase(); | |
var wasReattempted = img.dataset.myExtensionReattempted; | |
var reattempt = (!wasReattempted && tagName === 'img' && isHttpUrl(img.src) && extensionContains(img)); | |
if (reattempt) { | |
img.dataset.myExtensionReattempted = true; | |
api.port.emit('load_image', img.src, function onRespond(data) { | |
var err = data.error; | |
if (!err) { |
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 onCspCheckLoaded(isCspBlocking) { | |
extension_module.csp = isCspBlocking; // cache the check value | |
if (isCspBlocking) { | |
// Capture error events triggered by img tags | |
document.addEventListener('error', onExtensionImgError, true); | |
// Check for background images | |
var observer = new MutationObserver(withMutations); | |
var whatToObserve = { childList: true, subtree: true }; | |
observer.observe(document, whatToObserve); | |
} |
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
/* ... */ | |
// Loads an image on the host page to check for a CSP | |
function loadCspCheck(cb) { | |
var CSP_CHECK_URL = '//d34db33f.cloudfront.net/assets/tiny.png'; | |
var cspCheckImage = new Image(); | |
cspCheckImage.addEventListener('load', cb.bind(null, false)); | |
cspCheckImage.addEventListener('error', cb.bind(null, true)); | |
cspCheckImage.src = CSP_CHECK_URL; | |
} | |
/* ... */ |
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
/* A map of functions listening for messages from the content scripts */ | |
var listeners = { | |
/* ... */ | |
load_image: function (path, respond, tab) { | |
// The Firefox worker XHR dislikes protocol-less URLs, so prefix with the tab's protocol. | |
path = (path.indexOf('//') === 0 ? tab.url.slice(0, tab.url.indexOf(':') + 1) + path : path); | |
var imageType = path.slice(path.lastIndexOf('.') + 1); | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', path, true); | |
xhr.responseType = 'arraybuffer'; |
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
for i in $(seq 1 20); do | |
curl -sIL http://en.wikipedia.org/wiki/Special:Random | perl -n -e '/^Location: (.*)$/ && print "$1\n"' | tail -n 1 | |
done |
NewerOlder