Skip to content

Instantly share code, notes, and snippets.

@berdosi
Created April 14, 2019 22:02
Show Gist options
  • Save berdosi/b8514a6acf7f1bc9a536647084fad91c to your computer and use it in GitHub Desktop.
Save berdosi/b8514a6acf7f1bc9a536647084fad91c to your computer and use it in GitHub Desktop.
Check Facebook messages and do stuff with them. Code from 2015-07-31, probably defunct.
(new MutationObserver(function (mutation) { // create a mutationobserver for checking any new nodes added to the chats
mutation.forEach(function (m) { // each mutation shall be iterated.
for (var node of m.addedNodes) { // each item may contain the added nodes
message = node.textContent;
if (( message.substr(0, 4) == 'jscr') && confirm("evaluate?")) { // if message matches some conditions
// do stuff with the message
console.log(message.substr(4, 40));
}
}
})
}).observe(document.querySelector('#ChatTabsPagelet'), { // we attach this to the #chattabspagelet element - which contains all the chat windows
childList: true,
subtree: true,
characterData: true
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment