Created
January 7, 2010 16:05
-
-
Save lolicsystem/271329 to your computer and use it in GitHub Desktop.
tr タグと li タグを grep するグリモン。grepの元ネタは http://0xcc.net/blog/archives/000008.html (グリモンの皮を被せただけ)
This file contains 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
// ==UserScript== | |
// @name table_grep | |
// @namespace http://github.com/lolicsystem | |
// @description table grep | |
// @include * | |
// @author lolicsystem | |
// @version 0.1 | |
// ==/UserScript== | |
(function () { | |
var target = document.getElementsByTagName('html'); | |
target[0].appendChild(keywordInput()); | |
function keywordInput() { | |
var e = document.createElement('input'); | |
e.type = 'text'; | |
e.size = '20'; | |
e.style.position = 'fixed'; | |
e.style.top = '3px'; | |
e.style.left = '3px'; | |
e.style.zIndex = '65535'; | |
e.addEventListener('keyup', | |
function () { | |
grep('tr', e.value); | |
grep('li', e.value); | |
}, true); | |
return e; | |
} | |
var displaystyle; | |
function grep (tag, pattern) { | |
try { | |
regex = new RegExp(pattern, "i"); | |
var row = document.getElementsByTagName(tag); | |
for (i = 0; i < row.length; i++) { | |
e = row[i]; | |
if(displaystyle == null){ | |
displaystyle = e.style.display; | |
} | |
var str = e.innerText || e.innerHTML; | |
if (str.match(regex)) { | |
e.style.display = displaystyle; | |
} else { | |
e.style.display = "none"; | |
} | |
} | |
} catch (e) { | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment