Skip to content

Instantly share code, notes, and snippets.

@z1lc
Created December 1, 2025 11:49
Show Gist options
  • Select an option

  • Save z1lc/dd113890675f85ad51e680f735b0f1c8 to your computer and use it in GitHub Desktop.

Select an option

Save z1lc/dd113890675f85ad51e680f735b0f1c8 to your computer and use it in GitHub Desktop.
Bookmarklet to insert buttons on MathAcademy pages to copy LaTeX code
javascript:(function(){const s=document.querySelectorAll('svg');let c=0;s.forEach(e=>{if(e.parentNode.querySelector('.cp-tex-btn'))return;let t="";const ti=e.querySelector('title');const an=e.querySelector('annotation[encoding="application/x-tex"]');if(ti)t=ti.textContent;if(an)t=an.textContent;if(!t||t.trim().length===0)return;t=t.trim();const b=document.createElement('span');b.innerText='[TeX]';b.className='cp-tex-btn';Object.assign(b.style,{fontSize:'0.75em',color:'#007bff',cursor:'pointer',marginLeft:'5px',verticalAlign:'super',fontFamily:'sans-serif',fontWeight:'bold',zIndex:'1000',position:'relative'});b.onclick=(ev)=>{ev.preventDefault();ev.stopPropagation();navigator.clipboard.writeText(t).then(()=>{const o=b.innerText;b.innerText='[Copied!]';setTimeout(()=>b.innerText=o,1200);});};e.parentNode.appendChild(b);c++;});if(c>0){console.log(`Added copy buttons to ${c} formulas.`);}else{alert('No standard MathJax SVG formulas found.');}})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment