Last active
January 2, 2016 00:29
-
-
Save bmamlin/8223822 to your computer and use it in GitHub Desktop.
IRCCloud Bookmarklet to load all unread messages in the current channel (continuously loads history for up to one minute).
This file contains 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
javascript:(function() { | |
if (!cbv && !cbv.scroll) | |
return; | |
var THREE_SECONDS = 3000; | |
var ONE_MINUTE = 20 * THREE_SECONDS; | |
var backlogTimer; | |
var backlogTimerNotice = $('<div style="position:absolute;top:50px;left:50px;padding:20px;border:thick solid black;background-color:white;">Loading unread messages... </div>'); | |
var cancelBacklogTimer = function() { | |
clearTimeout(backlogTimer); | |
backlogTimerNotice.remove(); | |
}; | |
var cancelLink = $('<a href="#">(cancel)</a>').click(cancelBacklogTimer); | |
backlogTimerNotice.append(cancelLink); | |
loadBacklog = function() { | |
if (!cbv().scroll.isLastSeenMessageRendered()) { | |
cbv().scroll.loadBacklog(); | |
} else { | |
cbv().scroll.scrollTo(10); | |
backlogTimerNotice.remove(); | |
if (backlogTimer) | |
clearTimeout(backlogTimer); | |
} | |
}; | |
$('body').append(backlogTimerNotice); | |
loadBacklog(); | |
backlogTimer = setInterval(loadBacklog, THREE_SECONDS); | |
setTimeout(cancelBacklogTimer, ONE_MINUTE); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment