From b3cf9776f26876c07394f5ff5202d3102bceea1f Mon Sep 17 00:00:00 2001 From: tretrauit Date: Thu, 4 Apr 2024 16:51:45 +0700 Subject: [PATCH] feat: add another script for olm.vn --- web/olm.vn/screenshot-answer-custom.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 web/olm.vn/screenshot-answer-custom.js diff --git a/web/olm.vn/screenshot-answer-custom.js b/web/olm.vn/screenshot-answer-custom.js new file mode 100644 index 0000000..007cb1b --- /dev/null +++ b/web/olm.vn/screenshot-answer-custom.js @@ -0,0 +1,24 @@ +// Dependencies +eval( + await ( + await fetch("https://html2canvas.hertzen.com/dist/html2canvas.min.js") + ).text(), +); + +async function screenshotAnswer(answerElement) { + console.log(answerElement); + const canvas = await html2canvas(answerElement); + return await canvas.toDataURL(); +} + +const answerCol = document.querySelector("#list-question"); +// Patch the style to make it show all answers +answerCol.style.maxHeight = "10000vh"; +const answerImgData = await screenshotAnswer(answerCol); +// Create an image +const img = new Image(); +img.src = answerImgData; +const w = window.open(""); +// Write the image to the new window +w.document.write(img.outerHTML); +w.document.close();