Created
February 23, 2023 03:52
-
-
Save popdemtech/3953cc2763375e5c1be56c810c66e21d to your computer and use it in GitHub Desktop.
Getting my user-generated content from a social media platform after they revoked API access
This file contains hidden or 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
| // Tweets to JSON | |
| // Capture tweets as they load into a parent container `temp1` | |
| // `temp1` must be set by a human (right-click, inspect, find parent container of the tweets, right click html element, set as global variable) | |
| // var quotes = []; | |
| // temp1.querySelectorAll('[data-testid=tweetText]').forEach((t) => { | |
| // quotes.push(t.firstChild.textContent.trim()); }); | |
| // var observer = new WebKitMutationObserver(function(mutations) { | |
| // mutations.forEach(function(mutation) { | |
| // for(var i = 0; i < mutation.addedNodes.length; i++) { | |
| // const node = mutation.addedNodes[i]; | |
| // quotes.push(node.querySelector('[data-testid=tweetText]').firstChild.textContent.trim()); | |
| // } | |
| // }); | |
| // }); | |
| // observer.observe(temp1, { childList: true }); | |
| // var a = document.createElement('a'); | |
| // var unique = [ ...new Set(quotes) ]; | |
| // var file = new Blob([JSON.stringify(unique, null, 2)], { type: 'application/json' }); | |
| // a.href = URL.createObjectURL(file); | |
| // a.download = 'quotes.json'; | |
| // a.click(); | |
| const quotesJson = require('./quotes.json'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment