Etherscan Contract Downloader

batch download etherscan verified contract

اعتبارا من 30-01-2022. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Etherscan Contract Downloader
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  batch download etherscan verified contract
// @author       [email protected]
// @match        https://etherscan.io/address/*
// @icon         https://etherscan.io/images/brandassets/etherscan-logo-circle.png
// @grant        unsafeWindow
// @license      MIT 
// ==/UserScript==



(function() {
    'use strict';

    // Your code here...
    let editorIds = $("[id^=editor]")
    let spans = $("span[class=text-secondary]")

    console.log(`found ${editorIds.length-1} editors`);


    function getAddr() {
        const regex = /0x[0-9A-Fa-f]{40}/g;
        const found = window.location.href.match(regex);
        return found[0]
    }

    function downloadEditor(index) {
        let addr = getAddr()
        let editor = ace.edit(editorIds[index])
        let filename;
        try {
            filename = spans[index].innerText.split(":")[1].trim()
        } catch {
            filename = `${addr}.sol`
        }
        console.log(filename)
        let HTMLhiddenElement = document.createElement("a");
        HTMLhiddenElement.href = 'data:attachment/text,' + encodeURIComponent(editor.getValue());
        HTMLhiddenElement.target = '_blank';
        HTMLhiddenElement.download = `${addr}-${filename}`;
        HTMLhiddenElement.click();
    }

    function downloadAll() {
        if (editorIds.length == 1) {
            downloadEditor(0)
            return
        }
        for (let i=0;i<editorIds.length-1;i++) {
            downloadEditor(i)
        }
    }

    if(!unsafeWindow.downloadAll)
    {
        unsafeWindow.downloadAll = downloadAll;
    }

    $("#nav_subtabs").append('<li><a class="nav-link show" href="#download" data-toggle="tab" onclick="javascript:downloadAll();"><span>Download</span></a></li>');
    //
})();