Skip to content

Instantly share code, notes, and snippets.

@oresh
Created January 10, 2019 13:17
Show Gist options
  • Save oresh/16590afb600a832102337602b05c47a8 to your computer and use it in GitHub Desktop.
Save oresh/16590afb600a832102337602b05c47a8 to your computer and use it in GitHub Desktop.
Save chat messages from Facebook
var messages = document.getElementsByClassName('_3058 _ui9')
var name = document.getElementsByClassName('_673w')[0].getElementsByClassName('_3oh-')[0].innerText;
[...messages].map( (message) => {
var out = '';
out += message.classList.contains('_43by') ? 'Me: ' : name+': ';
var text = message.getElementsByClassName('_58nk');
if (text.length) return out + text[0].innerText;
}).filter(message => !!message).join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment