-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
0 parents
commit a87f992
Showing
5 changed files
with
108 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
build.sh | ||
Archive.zip |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This file was created by https://github.com/mozilla/web-ext | ||
# Your auto-generated extension ID for addons.mozilla.org is: | ||
{f412be1a-3260-47a6-811c-f0d6c309828f} |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
function findStreamLinks() { | ||
const $btnLinks = document.querySelectorAll("a.btn"); | ||
console.log($btnLinks); | ||
|
||
for (const linkElement of $btnLinks) { | ||
if (linkElement.href.includes("cmd=streamVideo") && linkElement.classList.contains("btn")) { | ||
addDirectLinkEvent(linkElement); | ||
} | ||
} | ||
} | ||
|
||
function addDirectLinkEvent(e) { | ||
const newLink = document.createElement('a'); | ||
newLink.classList.add('btn'); | ||
newLink.classList.add('btn-info'); | ||
newLink.innerHTML = `Direktlink`; | ||
newLink.addEventListener('click', () => { | ||
loadExternalPage(e, newLink); | ||
}); | ||
e.parentElement.appendChild(newLink); | ||
} | ||
|
||
function loadExternalPage(e, newLink) { | ||
newLink.innerHTML = "Loading"; | ||
let timeout = setTimeout(() => { | ||
newLink.innerHTML = "Timeout!" | ||
setTimeout(() => newLink.innerHTML = "Direktlink") | ||
}, 10000); | ||
|
||
fetch(e.href) | ||
.then(function(response) { | ||
// When the page is loaded convert it to text | ||
return response.text() | ||
}) | ||
.then(function(html) { | ||
// Initialize the DOM parser | ||
let parser = new DOMParser(); | ||
// Parse the text | ||
let targetDocument = parser.parseFromString(html, "text/html"); | ||
|
||
clearTimeout(timeout); | ||
openDirectDownloadLink(e, targetDocument, newLink); | ||
}) | ||
.catch(function(err) { | ||
console.log('Failed to fetch page: ', err); | ||
}); | ||
} | ||
|
||
function openDirectDownloadLink(originalLink, targetDocument, newLink) { | ||
try { | ||
let x = targetDocument.getElementsByTagName('script') | ||
let script = x[x.length - 1] | ||
let text = script.text.replaceAll("\n", "").replaceAll("\t", "").replaceAll("xoctPaellaPlayer.init(", "[").replaceAll(")", "]") | ||
let link = JSON.parse(text)[0].streams[0].sources.mp4[0].src | ||
navigator.clipboard.writeText(link).then(function () { | ||
console.log('Async: Copying to clipboard was successful!'); | ||
newLink.innerHTML = "Copied!"; | ||
setTimeout(() => newLink.innerHTML = "Direktlink", 2500); | ||
}, function (err) { | ||
console.error('Async: Could not copy text: ', err); | ||
newLink.innerHTML = "Error"; | ||
setTimeout(() => newLink.innerHTML = "Direktlink", 2500); | ||
}); | ||
} catch (err) { | ||
newLink.innerHTML = "Error"; | ||
setTimeout(() => newLink.innerHTML = "Direktlink", 2500); | ||
} | ||
} | ||
|
||
const checkExist = setInterval(function() { | ||
if (document.querySelector('#il_center_col form').childNodes) { | ||
console.log("Exists!"); | ||
clearInterval(checkExist); | ||
findStreamLinks(); | ||
} else { | ||
console.log("does not exist"); | ||
} | ||
}, 100); |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "ILIAS Opencast DL", | ||
"version": "1.0.1", | ||
"description": "Adda direct download link to any ILIAS Opencast pages", | ||
"icons": {}, | ||
|
||
"background": { | ||
"scripts": [] | ||
}, | ||
|
||
"content_scripts": [ | ||
{ | ||
"matches": ["*://ilias.studium.kit.edu/*"], | ||
"js": ["content.js"] | ||
} | ||
], | ||
|
||
"applications": { | ||
"gecko": { | ||
"update_url": "https://pages.foxat.de/browser-addons-repository/updates.json" | ||
} | ||
} | ||
} |
Binary file not shown.