Created
January 10, 2013 14:12
-
-
Save lloydwatkin/4502273 to your computer and use it in GitHub Desktop.
Clean yammer unread messages
This file contains hidden or 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
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes