Skip to content

Instantly share code, notes, and snippets.

@geraldotech
Last active May 5, 2024 10:55
Show Gist options
  • Save geraldotech/e8330204f7c2629b07c4af72383c0b5c to your computer and use it in GitHub Desktop.
Save geraldotech/e8330204f7c2629b07c4af72383c0b5c to your computer and use it in GitHub Desktop.
scripts
// get all questions || or gararito answers
const title = document.querySelectorAll("[data-testid='question-typography']:first-child")
for(const i of title){
console.log(i.textContent)
console.log("=============")
}
// get all answers
const resp = document.querySelectorAll("[data-element='link_resposta'] [data-testid='question-typography']")
resp.forEach((val) => {
console.log(val.textContent)
console.log("=============")
})
// === Download all question in a questions.txt file ===
const titles = document.querySelectorAll("[data-testid='question-typography']:first-child");
let combinedContent = "";
// Loop through all the selected elements to accumulate their content
titles.forEach(title => {
combinedContent += title.textContent + "\n";
combinedContent += "=====================\n";
});
// Create a Blob containing all the accumulated content
const file = new Blob([combinedContent], { type: "text/plain" });
// Create a link to download the Blob as a file
const a = document.createElement("a");
a.setAttribute("href", URL.createObjectURL(file));
a.setAttribute("download", "questions.txt");
// Trigger the download by programmatically clicking the link
a.click();
// Clean up
URL.revokeObjectURL(a.getAttribute("href"));
// === Download all answers in a answers.txt file ===
const resp = document.querySelectorAll("[data-element='link_resposta'] [data-testid='question-typography']")
let combinedContent = "";
// Loop through all the selected elements to accumulate their content
resp.forEach(title => {
combinedContent += title.textContent + "\n";
});
// Create a Blob containing all the accumulated content
const file = new Blob([combinedContent], { type: "text/plain" });
// Create a link to download the Blob as a file
const a = document.createElement("a");
a.setAttribute("href", URL.createObjectURL(file));
a.setAttribute("download", "answers.txt");
// Trigger the download by programmatically clicking the link
a.click();
// Clean up
URL.revokeObjectURL(a.getAttribute("href"));
/*Pegar todo conteúdo de uma página apenas para assinantes
Exemplo: https://oglobo.globo.com/politica/noticia/2023/01/lira-convoca-sessao-extraordinaria-para-camara-analisar-nesta-noite-decreto-de-intervencao-no-df.ghtml
by: gmapdev
*/
Abrir console> CTRL + SHIFT + p: type JavaScript para desabilitar
ou pegar somente o conteudo de text:
const content = document.querySelectorAll(".content-text__container");
content.forEach((item) => {
let novo = open()
for(const i of content){
novo.document.write(i.innerHTML, '<br>')
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment