Skip to content

Instantly share code, notes, and snippets.

@TristanWiley
Created June 4, 2017 01:59
Show Gist options
  • Select an option

  • Save TristanWiley/72e2b5a1a3571dd522332567452b6d31 to your computer and use it in GitHub Desktop.

Select an option

Save TristanWiley/72e2b5a1a3571dd522332567452b6d31 to your computer and use it in GitHub Desktop.
//A scraper I wrote for the site - http://www.bluffton.edu/homepages/facstaff/nesterd/java/derivs.html
//I added some extra bits, like copying it straight to your clipboard because yeah.
var elements = [];
for (var i = 0; i < 5; i++) {
var object = {
"html": document.getElementById("display").getElementsByClassName("base")[0].outerHTML,
"text": document.getElementById("display").textContent.split("Enter as: ")[1]
}
elements.push(object);
document.querySelectorAll("input[value=Skip]")[0].click();
}
var json = JSON.stringify(elements);
copyTextToClipboard(json);
function copyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild(textArea);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment