Created
November 29, 2024 08:03
-
-
Save Bnaya/d42a9d1216d9a816b15c8cea1f4e2e25 to your computer and use it in GitHub Desktop.
Inject download links to cloud.panopto.eu list page
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
// Be in a content list page | |
// Paste and run this code in the dev tools console | |
await main(); | |
async function main() { | |
const linksToViewerPage = [ | |
...document.querySelectorAll("#listViewContainer a.detail-title"), | |
]; | |
let step = linksToViewerPage.map((aElement) => { | |
return { | |
aElement, | |
id: new URLSearchParams(aElement.search).get("id"), | |
}; | |
}); | |
for (let item of step) { | |
item.json = await deliveryInfoRequest(item.id); | |
item.downloadUrl = item.json.Delivery.PodcastStreams[0].StreamUrl; | |
item.aElement.parentElement.parentElement.querySelector( | |
".item-contents" | |
).innerHTML = `<a style="color: red;" href="${item.downloadUrl}">Right Click Save as me, give me file name with .mp4</a>`; | |
} | |
console.log(step); | |
} | |
async function deliveryInfoRequest(id) { | |
const params = [ | |
["deliveryId", id], | |
["isLiveNotes", "false"], | |
["refreshAuthCookie", "true"], | |
["isActiveBroadcast", "false"], | |
["isEditing", "false"], | |
["isKollectiveAgentInstalled", "false"], | |
["isEmbed", "false"], | |
["responseType", "json"], | |
]; | |
const resp = await fetch("/Panopto/Pages/Viewer/DeliveryInfo.aspx", { | |
headers: { | |
"content-type": "application/x-www-form-urlencoded;charset=UTF-8", | |
}, | |
body: new URLSearchParams(params).toString(), | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
}); | |
if (!resp.ok) { | |
throw new Error("NOOOO"); | |
} | |
const jsonResp = await resp.json(); | |
if (jsonResp.ErrorCode) { | |
throw new Error("NOOOO with error code"); | |
} | |
return jsonResp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment