Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Copy/Paste-able Survey Monkey Answers - Paste the following into a bookmark's location setting and then run it on a single page of a Survey Monkey form. You'll then get a list of the questions and answers you can copy and paste. Currently works for radio, textarea, and text input fields. More to come?
( function() {
const questions = document.querySelectorAll( '.question-container' );
let result = '';
questions.forEach( ( q ) => {
let answerText = '';
let question = q.querySelector( '.question-title-container' ).innerText.replace( '* ', '' );
let answer = q.querySelector( 'label.checked' );
if ( null === answer ) {
answer = q.querySelector( 'textarea' );
}
if ( null === answer ) {
answer = q.querySelector( 'input.text' ); // note: input[type="text"] should work but doesn't
}
if ( null !== answer ) {
tag = answer.tagName.toLowerCase();
if ( 'label' === tag ) {
answerText = answer.innerText;
} else if ( 'textarea' === tag || 'input' === tag ) {
answerText = answer.value;
}
}
if ( '' !== answerText ) {
result += question + ' ' + answerText + '\n';
}
});
alert( result );
}() );
javascript:!function(){const e=document.querySelectorAll(".question-container");let t="";e.forEach(e=>{let l="",n=e.querySelector(".question-title-container").innerText.replace("* ",""),r=e.querySelector("label.checked");null===r&&(r=e.querySelector("textarea")),null===r&&(r=e.querySelector("input.text")),null!==r&&(tag=r.tagName.toLowerCase(),"label"===tag?l=r.innerText:"textarea"!==tag&&"input"!==tag||(l=r.value)),""!==l&&(t+=n+" "+l+"\n")})}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment