-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
chrome.runtime.onMessage.addListener((r) => chrome.downloads.download({'url': r})); | ||
chrome.runtime.onMessage.addListener(function (url) { | ||
chrome.downloads.download({ | ||
'url': url | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
const raw = document.getElementById('raw-url'); | ||
if (raw) { | ||
const el = document.createElement('button'); | ||
const bar = raw.parentElement.parentElement.lastChild.previousSibling; | ||
bar.insertBefore(el, bar.firstChild); | ||
el.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" class="octicon octicon-device-desktop"><path fill-rule="evenodd" d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"></path></svg>'; | ||
el.onclick = () => { | ||
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'); | ||
} | ||
function run() { | ||
console.log("Running the stuff!"); | ||
if (document.getElementById('raw-dl')) { | ||
return; | ||
} | ||
console.log("Does not exist!"); | ||
const raw = document.getElementById('raw-url'); | ||
if (raw) { | ||
console.log("Raw exists."); | ||
const el = document.createElement('button'); | ||
el.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" class="octicon octicon-device-desktop"><path fill-rule="evenodd" d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"></path></svg>'; | ||
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(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
{ | ||
"name": "Let's Get!", | ||
"description": "Download those pesky raw files on Github!", | ||
"manifest_version": 3, | ||
"version": "0.0.1", | ||
"manifest_version": 2, | ||
"version": "0.0.2", | ||
"background": { | ||
"service_worker": "background.js" | ||
"scripts": ["background.js"], | ||
"persistent": true | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["https://github.com/*/blob/*"], | ||
"matches": ["*://github.com/*"], | ||
"js": ["content_script.js"] | ||
} | ||
], | ||
"permissions": [ | ||
"downloads" | ||
"downloads", | ||
"*://github.com/*" | ||
] | ||
} |