Skip to content

Instantly share code, notes, and snippets.

@decadecity
Created November 13, 2012 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save decadecity/4065324 to your computer and use it in GitHub Desktop.
Save decadecity/4065324 to your computer and use it in GitHub Desktop.
Categorizr cross-check data JSONifer
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Categorizr cross-check JSONifer
</head>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/zepto.min.js "></script>
<script>
// This is VERY rough and ready and incredibly fragile.
(function ($) {
var uas = []; // Extracted user agent data.
$('body').html('<p>Loading data, please wait.</p>');
$('body').load('http://brettjankord.com/categorizr/categorizr-user-agents.php #categorizr-results-container', function() {
$('table').each(function () {
$(this).find('tr').each(function () {
var ua = [];
$(this).find('td').each(function () {
if ($(this).hasClass('ua-column') && !$(this).attr('width')) {
// This is a user agent row.
ua.push($(this).text().replace(/\n/g, " "));
} else if (ua.length) {
// We've had a UA so this should be the category.
ua.push($(this).text());
ua.push("s"); // We don't want to alter the case when checking.
uas.push(ua);
}
});
});
// Output the extracted user agent data as JSON for copy/paste.
$('body').html('<pre>' + JSON.stringify(uas, null, 2) + '</pre>');
});
});
}(window.Zepto))
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment