Skip to content

Instantly share code, notes, and snippets.

@ernix
Created April 18, 2017 08:22
Show Gist options
  • Save ernix/81404ec312eef1b5b34323aea65a333f to your computer and use it in GitHub Desktop.
Save ernix/81404ec312eef1b5b34323aea65a333f to your computer and use it in GitHub Desktop.
Add regex filter button for Public/Federated TimeLines
(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