Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
First version that adds realtime filtering of middlecoin addresses.
// ==UserScript==
// @name Middlecoin utilities
// @namespace http://middlecoin.com/
// @version 0.1
// @description Some extras for middlecoin, i.e. table search filter
// @match http://middlecoin.com/
// @copyright 2012+, KamiNuvini
// @run-at document-end
// @require http://code.jquery.com/jquery-2.0.3.min.js
// ==/UserScript==
// Realtime address search
$('table').before('<div id="searchbox"><b>Search address: </b><input id="search" type="search"></div>');
// Search snippet, thanks to dfsq at StackOverflow - http://stackoverflow.com/questions/9127498/how-to-perform-a-real-time-search-and-filter-on-a-html-table
var $rows = $('table tbody tr');
$('#search').keyup(function() {
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$rows.show().filter(function() {
var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
// End of realtime address search
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.