function run() { if (document.getElementById('raw-dl')) { return; } const raw = document.getElementById('raw-url'); if (raw) { const el = document.createElement('button'); el.innerHTML = ''; el.onclick = function () { chrome.runtime.sendMessage(window.location.protocol + window.location.host + raw.getAttribute('href')); }; el.setAttribute('data-platforms', 'windows,mac'); el.setAttribute('aria-label', 'Download this file'); el.setAttribute('id', 'raw-dl'); el.classList.add('btn-octicon', 'tooltipped', 'tooltipped-nw', 'js-remove-unless-platform'); const bar = raw.parentElement.parentElement.lastChild.previousSibling; bar.insertBefore(el, bar.firstChild); } } document.addEventListener('pjax:success', function () { run(); }); run();