Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active February 26, 2021 11:04
Show Gist options
  • Select an option

  • Save kopiro/7431923 to your computer and use it in GitHub Desktop.

Select an option

Save kopiro/7431923 to your computer and use it in GitHub Desktop.
Facebook: scroll in the messages to a particular date
javascript:
(function(){
function _(a) { return document.querySelectorAll(a); }
var to = new Date(prompt('Arrival date', '2013/04/18')).getTime()/1000;
if (!to) return alert('Invalid date');
var thetime = 0;
var sametimes = 0;
function thefoo(){
var time = parseInt(_('.webMessengerMessageGroup')[0].querySelector('[data-utime]').dataset.utime,10);
if (time==thetime) {
sametimes++;
_('[role=main] .uiScrollableAreaWrap')[0].scrollTop=0;
if (sametimes<10) setTimeout(thefoo, 800);
else alert("Can't scroll more!");
} else {
sametimes = 0;
thetime = time;
if (thetime>to) setTimeout(thefoo, 500);
else alert("Done!");
}
} thefoo();
})();
@koky462
Copy link

koky462 commented May 5, 2019

Hi Kopio, where do I install this javascript to use this code? Thank you.

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