Created
April 10, 2026 05:42
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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