Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active February 27, 2019 09:12
Show Gist options
  • Save kopiro/96ee6f19a82850beca48 to your computer and use it in GitHub Desktop.
Save kopiro/96ee6f19a82850beca48 to your computer and use it in GitHub Desktop.
Filter Facebook ticker stories with a RegEx
(function() {
var filterName = new RegExp(prompt("Insert the regex"), 'i');
if (!filterName) {
return alert('Invalid regex');
}
var MAX_ITERATIONS = 500;
var $profileNode = document.querySelector('[title="Profile"] > span');
var yourName = $profileNode.innerText;
var $ts = document.querySelector('.ticker_stream');
var $tsw = $ts.parentNode.parentNode.parentNode;
var i = 0;
function hideUselessStories() {
var els = [].slice.call( document.querySelectorAll('.fbFeedTickerStory') );
els.forEach(function(e) {
try {
var name = e.querySelector('.tickerFeedMessage .fwb').innerText;
if (filterName.test(name)) e.className += ' fbFeedTickerStoryShow';
} catch (ex) {
console.error(ex);
}
});
var st = document.createElement('style');
st.innerHTML = '.fbFeedTickerStory { display: none !important; } .fbFeedTickerStory.fbFeedTickerStoryShow { display: block !important; }';
document.body.appendChild(st);
}
function scrollTicker() {
$profileNode.innerText = yourName + ' (' + Math.floor( 100 * i / MAX_ITERATIONS ) + '%)';
if (i++ > MAX_ITERATIONS) {
$profileNode.innerText = yourName;
return hideUselessStories();
}
$tsw.scrollTop = $ts.clientHeight;
setTimeout(scrollTicker, 250);
}
scrollTicker();
})();
@zoran15
Copy link

zoran15 commented Mar 22, 2017

This won't work for users which don't use English as their language in Facebook, if "Profile" is different in that language. Check my fork for a version which will work even in other languages.

@ReelVibes
Copy link

Pardon my ignorance but what do I need to do with this code so I am able to filter my ticker? Google isn't being my friend right now. Even pointing me in the right direction would be great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment