Skip to content

Instantly share code, notes, and snippets.

@miclgael
Created January 31, 2023 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miclgael/29a677cebbe759ded7a6f73b7f128585 to your computer and use it in GitHub Desktop.
Save miclgael/29a677cebbe759ded7a6f73b7f128585 to your computer and use it in GitHub Desktop.
Greasemonkey Formspree Exporter
// ==UserScript==
// @name Formspree Exporter
// @version 0.0.1
// @grant GM_log
// @include https://formspree.io/forms/*/submissions
// @run-at document-end
// ==/UserScript==
console.log('GreaseMonkey: Formspree Exporter by @miclgael');
// Run the `check` script every 300ms
const timer = setInterval(check, 300);
// Counter to keep track of every run
let counter = 0;
function check() {
// Increment counter
counter += 1
console.log('Checking...', counter)
// Check that the submissions table has loaded
if (document.querySelector('#submissions [title="Toggle Row Expanded"]')) {
console.log('Submissions Found!')
// Clear the timer
clearInterval(timer)
// Get every cell of the table
const cells = [...document.querySelectorAll('[role=cell] > span')];
// Discard junk from rows
cells.forEach(c => {
if (c.textContent !== '' && c.textContent !== '•') {
console.log(c.textContent)
}
})
}
// Bail after 30 attempts
if (counter === 30) {
// Clear the timer
clearInterval(timer)
console.log('Could not find submissions, aborting.')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment