Skip to content

Instantly share code, notes, and snippets.

View viethung0823's full-sized avatar
🤔
I may be slow to respond.

Viet Hung viethung0823

🤔
I may be slow to respond.
View GitHub Profile
@viethung0823
viethung0823 / ptitScript.js
Last active May 17, 2024 04:15
PTIT Script
function selectElementText(e,t=document){let n=t.querySelector(e),o=document.createRange();o.selectNodeContents(n);let l=window.getSelection();return l.removeAllRanges(),l.addRange(o),window.getSelection().toString().replace(/\n/g," ").trim()}if(window.location.href.includes("mod/quiz/review.php?attempt")){const e=document.querySelectorAll(".que");let t="";Array.from(e).forEach((e=>{const n=selectElementText(".qtext p",e),o=n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),l=selectElementText(".rightanswer p",e);t+=`"${o}", "${n}", "${l}"\n`}));const n={data:t};fetch("https://ptit-pool-data.vercel.app/update-sheet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then((e=>e.json())).then((e=>{console.log(e)})).catch((e=>{console.error("Error:",e)})),GM_setClipboard(t)}else if(window.location.href.includes("mod/quiz/attempt.php?attempt")){const e=document.querySelectorAll(".que");let t="";Array.from(e).forEach((async(e,n)=>{const o=e.querySelector(".qtext p"),