document.addEventListener('DOMContentLoaded', function(event) { var cloaks = document.querySelectorAll('[data-atob]'), i; for (i = 0; i < cloaks.length; ++i) { cloaks[i].addEventListener('click', onLeftClick, false); cloaks[i].addEventListener('contextmenu', onRightClick, false); } }); var onLeftClick = function(event) { var attribute = this.getAttribute('data-atob'); if (event.ctrlKey) { var newWindow = window.open(decodeURIComponent(window.atob(attribute)), '_blank'); newWindow.focus(); } else { document.location.href = decodeURIComponent(window.atob(attribute)); } }; var onRightClick = function(event) { var attribute = this.getAttribute('data-atob'); if (event.ctrlKey) { var newWindow = window.open(decodeURIComponent(window.atob(attribute)), '_blank'); newWindow.focus(); } else { window.open(decodeURIComponent(window.atob(attribute)),'_blank'); } }