Created
April 14, 2019 22:02
-
-
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.
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
(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