Skip to content

Instantly share code, notes, and snippets.

@lloydwatkin
Created January 10, 2013 14:12
Show Gist options
  • Save lloydwatkin/4502273 to your computer and use it in GitHub Desktop.
Save lloydwatkin/4502273 to your computer and use it in GitHub Desktop.
Clean yammer unread messages
var loadAndClose = function(url) {
var thisUrl = url;
console.log('Opening ' + thisUrl);
var newTab = window.open(thisUrl, '_blank');
setTimeout(function() { newTab.close(); console.log('Closing ' + thisUrl); } , 4000);
};
var process = function(elements, index) {
if (index >= elements.length) return;
var url = document.location.href.substring(0, document.location.href.length-5) + 'show?threadId='+elements[index].getAttribute('data-thread-id');
console.log('Processing ' + index + ' of ' + elements.length + ' ::: ' + url);
loadAndClose(url);
setTimeout(function() { process(elements, index+1); }, 1000);
}
var cleanUnread = function(count) {
count++;
var index;
if (count > 10) {
alert('You\'ll need to run script again!');
return;
};
var moreButton = document.getElementsByClassName('yj-inbox-unread-list')[0].getElementsByClassName('yj-more-button-link')[0];
if (moreButton.parentElement.style.display == '') {
console.log('Loading more...');
moreButton.click();
setTimeout(function() { cleanUnread(count); }, 1500);
return;
};
var elements = document.getElementsByClassName('yj-inbox-list-item');
process(elements, 0);
};
cleanUnread();
@lloydwatkin
Copy link
Author

Notes

  • Only tested on chrome
  • Run from developer/javascript console
  • Browser client - start from inbox page
  • May take a minute or so with large number of unread messages

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