Skip to content

Instantly share code, notes, and snippets.

@watagashi
Last active December 22, 2025 23:57
Show Gist options
  • Select an option

  • Save watagashi/e22e48e8f2454b71223fc50bb0c9761d to your computer and use it in GitHub Desktop.

Select an option

Save watagashi/e22e48e8f2454b71223fc50bb0c9761d to your computer and use it in GitHub Desktop.
void setTimeout(() => {
const t = document.title
.replaceAll('&', '&')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;');
const h = `<a href="${location.href}">${t}</a>`;
const e = [
['html', h],
['plain', t],
].map(([m, d]) => {
const b = new Blob([d], { type: `text/${m}` });
return [b.type, b];
});
navigator.clipboard
.write([new ClipboardItem(Object.fromEntries(e))])
.then(() => console.log('copied.'))
.catch((err) => console.error(err.name, err.message));
}, 1000);
// javascript:void%20setTimeout(()=>{const%20t=document.title.replaceAll('&','&amp;').replaceAll('<','&lt;').replaceAll('>','&gt;');const%20h=`<a%20href="${location.href}">${t}</a>`;const%20e=[['html',h],['plain',t],].map(([m,d])=>{const%20b=new%20Blob([d],{type:`text/${m}`});return[b.type,b];});navigator.clipboard.write([new%20ClipboardItem(Object.fromEntries(e))]).then(()=>console.log('copied.')).catch((err)=>console.error(err.name,err.message));},1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment