Created
April 18, 2017 08:22
-
-
Save ernix/81404ec312eef1b5b34323aea65a333f to your computer and use it in GitHub Desktop.
Add regex filter button for Public/Federated TimeLines
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
(function (g) { | |
var d = g.document | |
filter = prompt('Feed me a filtering regex:'), | |
regex = new RegExp(filter, 'gi'); | |
display = function (value) { | |
[].forEach.call(d.querySelectorAll('.status'), function (n) { | |
var c, t; | |
if (value !== 'block') { | |
c = n.querySelector('.status__content'); | |
t = c.innerText || c.textContent; | |
if (t.search(regex) < 0) return; | |
} | |
n.style.display = value; | |
}); | |
}; | |
if ((g || {}).__ob) { | |
g.__ob.disconnect(); | |
display('block'); | |
} | |
if (filter === '') return; | |
g.__ob = new MutationObserver(function () { | |
display('none'); | |
}); | |
g.__ob.observe(d.body, { | |
attributes: true, | |
childList: true, | |
characterData: true, | |
subtree: true | |
}); | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment