Skip to content

Instantly share code, notes, and snippets.

@ardislu
Created April 10, 2026 05:42
Show Gist options
  • Select an option

  • Save ardislu/5eb08523b343c9edf134273d29dbe1dd to your computer and use it in GitHub Desktop.

Select an option

Save ardislu/5eb08523b343c9edf134273d29dbe1dd to your computer and use it in GitHub Desktop.
Simple script to copy all the code from an Etherscan smart contract code page (updated for Etherscan's new Monaco editor introduced in April 2026).
// Simple script to copy all the code blocks at once from an Etherscan smart contract code page
// (example: https://etherscan.io/address/0x43506849d7c04f9138d1a2050bbf3a0c054402dd#code).
// Uses a hardcoded global variable (`editor_contractJsonData`), must update if Etherscan updates
// its frontend code (this script was last updated April 2026).
const s = Object.values(JSON.parse(editor_contractJsonData).sources).reduce((a, c) => `${a}\n\n${c.content}`, '');
navigator.clipboard.writeText(s);
// Bookmarklet version:
// javascript:s=Object.values(JSON.parse(editor_contractJsonData).sources).reduce((a,c)=>`${a}\n\n${c.content}`,'');navigator.clipboard.writeText(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment