Skip to content

Commit

Permalink
including Uni Bremen
Browse files Browse the repository at this point in the history
first atemp to provide the service for uni-bremen.de
  • Loading branch information
RIVEK-Development committed Aug 17, 2023
1 parent af412c7 commit b23a314
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
12 changes: 7 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

const UniLink = ["https://opencast-present.tu-braunschweig.de/search/episode.json?id=",
"https://opencast03.zmml.uni-bremen.de/search/episode.json?id="];

chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.vidId != null){
if(request.download != null){
getLink(request.vidId, request.vidForm, sendResponse, true);
getLink(request.UniId, request.vidId, request.vidForm, sendResponse, true);
}
else{
getLink(request.vidId, request.vidForm, sendResponse, false);
getLink(request.UniId, request.vidId, request.vidForm, sendResponse, false);
}
}
return true;
Expand Down Expand Up @@ -71,8 +73,8 @@ function parseJson(res, vidForm, sendResponse, download){

}

async function getLink(vidId, vidForm, sendResponse, download){
jsonUrl = "https://opencast-present.tu-braunschweig.de/search/episode.json?id=" + vidId;
async function getLink(UniId, vidId, vidForm, sendResponse, download){
jsonUrl = UniLink[UniId] + vidId;
fetch(jsonUrl).then(res => res.json()).then(data => parseJson(data, vidForm, sendResponse, download));
}

Expand Down
18 changes: 15 additions & 3 deletions content.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
var vidLink = "https://moritz-riedel.de";
const Unis =["tu-braunschweig.de",
"uni-bremen.de"];

var UniId = 0;
var url = document.location.href;

if(url.includes("https://opencast-present") && (url.includes("paella/ui/") || url.includes("engage/theodul/ui" )) && !url.includes("mode=desktop")){ //Ist die Seite eine mit Video?
for (i=0; i<Unis.length; i++){
if(url.includes(Unis[i])){
UniId = i;
break;
}
}

var vidLink = "https://moritz-riedel.de";

if((url.includes("https://opencast-present") || url.includes("https://opencast03")) && (url.includes("paella/ui/") || url.includes("engage/theodul/ui" )) && !url.includes("mode=desktop")){ //Ist die Seite eine mit Video?

var ids = url.split("id=");
var id = ids[ids.length -1];
Expand Down Expand Up @@ -81,7 +93,7 @@ if(url.includes("https://opencast-present") && (url.includes("paella/ui/") || ur


function download(id,vidForm){
chrome.runtime.sendMessage({vidId: id, vidForm: vidForm, download: "true"}, function(response) {
chrome.runtime.sendMessage({UniId: UniId, vidId: id, vidForm: vidForm, download: "true"}, function(response) {
console.log(response.videoName);
});
}
16 changes: 15 additions & 1 deletion content2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
var episodes = document.getElementsByClassName("oce_list list")[0].children;

const Unis =["tu-braunschweig.de",
"uni-bremen.de"];

var UniId = 0;
var url = document.location.href;

for (i=0; i<Unis.length; i++){
if(url.includes(Unis[i])){
UniId = i;
break;
}
}


createBtn();

function createBtn(){
Expand All @@ -23,7 +37,7 @@ function createBtn(){
}

function download(id){
chrome.runtime.sendMessage({vidId: id, vidForm: null, download: "true"}, function(response) {
chrome.runtime.sendMessage({UniId: UniId, vidId: id, vidForm: null, download: "true"}, function(response) {
console.log(response.videoName);
});
}
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
},
"content_scripts": [
{
"matches": ["https://opencast-present.tu-braunschweig.de/*"],
"matches": ["https://opencast-present.tu-braunschweig.de/*","https://opencast03.zmml.uni-bremen.de/*"],
"js": ["content.js"],
"all_frames":true
},
{
"matches": ["https://studip.tu-braunschweig.de/plugins.php/opencast/*"],
"matches": ["https://studip.tu-braunschweig.de/plugins.php/opencast/*","https://elearning.uni-bremen.de/plugins.php/opencast/*"],
"js": ["content2.js"]
},
{
Expand Down

0 comments on commit b23a314

Please sign in to comment.