Skip to content

Instantly share code, notes, and snippets.

@eeeschwartz
Last active August 29, 2015 14:24
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 eeeschwartz/316c5d13bba5b1e6cd8f to your computer and use it in GitHub Desktop.
Save eeeschwartz/316c5d13bba5b1e6cd8f to your computer and use it in GitHub Desktop.
<a href="javascript:void(function () {
var jsCode = document.createElement('script');
jsCode.setAttribute('src', 'https://gist.githubusercontent.com/eeeschwartz/316c5d13bba5b1e6cd8f/raw/main.js');
document.body.appendChild(jsCode);
}())">Extract Qs</a>
(function(){
var body = document.getElementsByTagName('body')[0];
var html = '<div id="extracted-container" style="position:absolute; left: 0; top: 0; border: 1px solid #CCC; background: white; padding: 0.4em"><ul class="extracted-questions"></ul></div>'
body.insertAdjacentHTML('afterBegin', html);
var container = document.getElementById('extracted-container');
var extractedQuestions = container.getElementsByClassName('extracted-questions')[0];
var newLocation = "https://" + window.location.pathname.split("/")[1] + ".github.io/" + window.location.pathname.split("/")[2];
var gQuestions = [newLocation];
Array.prototype.forEach.call(gQuestions, function(question) {
if (question.getElementsByClassName('ss-q-title')[0]) {
var label = question.getElementsByClassName('ss-q-title')[0].textContent;
var input = question.getElementsByTagName('input')[0] || question.getElementsByTagName('textarea')[0];
var attr = [];
//if (question.getElementsByClassName('required-message').length > 0) { attr.push('required') }
if (input && input.type) { attr.push(input.type) }
if (attr.length > 0) { label += (' (' + attr.join(' ') + ')') }
extractedQuestions.insertAdjacentHTML('beforeEnd', '<li>' + label + '</li>');
} else {
// pluck section title
}
}()
@eeeschwartz
Copy link
Author

Non-functional at the moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment