Created
January 31, 2023 00:22
-
-
Save miclgael/29a677cebbe759ded7a6f73b7f128585 to your computer and use it in GitHub Desktop.
Greasemonkey Formspree Exporter
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
// ==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