Adding a new link to etherscan to the top navigation bar

I want to add a new link to etherscan to the top navigation bar of the exchange. How can I achieve this?

2 Likes

creating a plugin, or using code inject may work.

You can add the following script to your console in your body:

<script>
function open(url) {
	const a = document.createElement('a');
	a.style = 'display: none';
	a.href = url;
	a.target = '_blank';
	a.rel = 'noopener noreferrer';

	document.body.appendChild(a);
	a.click();
	document.body.removeChild(a);
};

function addItem(id) {
var menu = document.getElementsByClassName('app-menu-bar')[0];
if (id && menu) {
var item = document.createElement('div');
item.id = id;
item.onclick = function () { open('https://etherscan.io/'); };
item.classList.add('app-menu-bar-content', 'd-flex');
var content = document.createElement('div');
content.innerHTML = 'EtherScan';
content.classList.add('app-menu-bar-content-item', 'd-flex');
item.appendChild(content);
menu.appendChild(item);
}
}

function checkMenuItem(id) {
    if (id) {
        if (!document.getElementById(id)) {
            addItem(id)
        }
    }
}

checkMenuItem('etherscan');

setInterval(function() {
    checkMenuItem('etherscan')
}, 1000);
</script>
2 Likes

This is a great code snippet and works like a charm. A bit of JS and CSS can make magic happen.

awesome! thanks sharing that with screengrab