Skip to content

Instantly share code, notes, and snippets.

@royalgarter
Last active June 26, 2017 08:37
Show Gist options
  • Save royalgarter/73c4e759b24f296b990c781c51d543be to your computer and use it in GitHub Desktop.
Save royalgarter/73c4e759b24f296b990c781c51d543be to your computer and use it in GitHub Desktop.
Mark red label for finished message thread in facebook
var doSetup = function () {
if (document.querySelector('#q'))
document.querySelector('#q').value = '[ATADI] initializing...';
if (document.readyState != 'complete' || !document.querySelectorAll('._24tx').length)
return setTimeout(doSetup, 1e4);
document.querySelector('._24tx').addEventListener('DOMSubtreeModified', function() {
// console.log('DOMSubtreeModified');
var inboxes = document.querySelectorAll('._24tx li');
inboxes.forEach(function (inbox, idx) {
var flag = inbox.querySelectorAll('._2fp8');
var count = flag[0].innerText.trim();
var html = flag[0].innerHTML.trim();
// console.log(idx, count, html);
if (!count && !~html.indexOf('repliedLast')) {
inbox.setAttribute("style", "background-color:#ffcdd2;");
}
});
}, false);
if (document.querySelector('#q'))
document.querySelector('#q').value = '[ATADI] setup completed';
}
window.onload = function () {
if (document.querySelector('#q'))
document.querySelector('#q').value = '[ATADI] window.onload';
if (~window.location.pathname.indexOf('messages'))
return setTimeout(doSetup, 1e4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment