Skip to content
Snippets Groups Projects
Commit 7486a7c3 authored by K1R0J's avatar K1R0J
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
frame.js 0 → 100644
if(window.location.host == 'engage.streaming.rwth-aachen.de'){
fetch(`https://engage.streaming.rwth-aachen.de/search/episode.json?id=${new URLSearchParams(location.search).get('id')}`).then(d=>d.json()).then(meta => {
window._meta = meta
let videoTracks = meta['search-results'].result.mediapackage.media.track.filter(t=> t.mimetype.startsWith('video/') && t.url.startsWith('http'))
window.parent.postMessage({videoTracks, meta}, '*')
})
}else if(window.location.host === 'moodle.rwth-aachen.de'){
document.querySelectorAll('iframe.ocplayer').forEach((frame)=>{
let outer = frame.parentNode.parentNode;
let linkDiv = document.createElement('div');
linkDiv.id = "link_div";
outer.append(linkDiv);
})
window.addEventListener('message', msg => {
let frame;
document.querySelectorAll('iframe.ocplayer').forEach((e)=>{
if(msg.source == e.contentWindow){
frame = e.parentNode.parentNode;
return;
}
})
let container = frame.querySelector('#link_div');
msg.data.videoTracks.forEach(track => {
let a = document.createElement('a')
a.href = track.url
a.innerText = `${track.video.resolution} (${track.mimetype})`
a.classList.add('btn');
a.classList.add('btn-link');
a.style = ('background-color:#00549f ;color:white; border-radius:2px; padding:4px 8px; margin-top:10px; margin-right:20px;');
container.appendChild(a)
})
return false;
})
}
\ No newline at end of file
{
"manifest_version": 2,
"name": "Moodle Downloader",
"description": "Download your Moodle Videos",
"version": "1.0",
"author": "Jorik van Genuchten",
"browser_action": {
"default_icon": "tab-icon.png"
},
"permissions": ["activeTab"],
"content_scripts": [{
"matches": ["http://*/*", "https://*/*"],
"js": ["frame.js"],
"all_frames": true
}],
"icons": {
"256": "tab-icon.png"
}
}
\ No newline at end of file
tab-icon.png

6.38 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment