Skip to content

Instantly share code, notes, and snippets.

@popdemtech
Created February 23, 2023 03:52
Show Gist options
  • Select an option

  • Save popdemtech/3953cc2763375e5c1be56c810c66e21d to your computer and use it in GitHub Desktop.

Select an option

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
// 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