Created
July 30, 2019 13:30
-
-
Save thuongnn/ece85e09f425e7a3d58a913ce0a59fef 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
let dataCrawl = localStorage.getItem("dataCrawl") || ""; | |
let lessonCrawl = localStorage.getItem("lessonCrawl") || ""; | |
let lesson = document.getElementsByClassName("hd hd-2 unit-title")[0].innerText; | |
lessonCrawl += lessonCrawl === "" ? lesson : `, ${lesson}`; | |
localStorage.setItem("lessonCrawl", lessonCrawl); | |
let containers = document.getElementsByClassName("wrapper-problem-response"); | |
for (let i = 0; i < containers.length; i++) { | |
let correct = "Ans:"; | |
let count = 0; | |
containers.item(i).getElementsByTagName("fieldset").item(0).childNodes.forEach(con => { | |
let ansCode = String.fromCharCode(65 + count); | |
if (con.tagName === "LEGEND") dataCrawl += `\n${con.innerText}`; | |
if (con.className === "field") { | |
if (con.childNodes[1].childNodes[1].checked) correct += correct === "Ans:" ? ansCode : `, ${ansCode}`; | |
dataCrawl += `\n${ansCode}. ${con.childNodes[1].childNodes[2].nodeValue.trim()}`; | |
count += 1; | |
} | |
}); | |
dataCrawl += `\n${correct}\n`; | |
localStorage.setItem("dataCrawl", dataCrawl); | |
} | |
console.log(lessonCrawl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment