Last active
August 29, 2015 14:24
-
-
Save eeeschwartz/316c5d13bba5b1e6cd8f to your computer and use it in GitHub Desktop.
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
<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> |
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
(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 | |
} | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Non-functional at the moment