Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Categorizr cross-check data JSONifer
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Categorizr cross-check JSONifer
<script src="// "></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(' #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("s"); // We don't want to alter the case when checking.
// Output the extracted user agent data as JSON for copy/paste.
$('body').html('<pre>' + JSON.stringify(uas, null, 2) + '</pre>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment