Skip to content

Instantly share code, notes, and snippets.

@cheapsteak
Created July 8, 2014 22:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cheapsteak/fc2070eaa356d24e4f26 to your computer and use it in GitHub Desktop.
Gets the development progress of Sunless Sea and submits it to my google form
var formFields = {
"Sailing": "entry.376220540",
"Survival": "entry.197513274",
"Exploration": "entry.2132268405",
"UI": "entry.2043779183",
"World": "entry.1470664547",
"Combat": "entry.2099888301",
"Music": "entry.1305260500",
"Sound": "entry.2026300973",
"Economy & Trade": "entry.1749673763",
"Ambitions & Legacies": "entry.253097748",
"Fiction": "entry.358679505",
"Phenomena": "entry.997821975",
"Optimisation": "entry.702495680",
"Under the Unterzee": "entry.1646999836"
};
var formUrlRoot = 'https://docs.google.com/forms/d/1xrFTn5fY58YI6iy4QLwfZaA7VhrL-409XfSuj33q8Hc/formResponse?submit=Submit&';
var html = $('iframe').first().get(0).contentDocument.body.innerHTML;
var progress = $(html)
.find('.chart-entry')
.map(function () {
return {
label: $(this).find('.chart-label').text().trim(),
progress: $(this).find('.chart-bar').text().trim()
}
})
.get();
var urlComponent = progress
.map(function (item) {
return formFields[item.label] + "=" + (encodeURIComponent(item.progress) || "0");
})
.join('&');
var destination = formUrlRoot += urlComponent;
$("<img src='" + destination + "' alt=''/>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment