-
Notifications
You must be signed in to change notification settings - Fork 14
/
MSBookmarklet.min.js
1 lines (1 loc) · 7.11 KB
/
MSBookmarklet.min.js
1
javascript:(()=>{document.getElementById("player-iframe")&&(alert('MediasiteDownloader: A Mediasite Channel was detected. After you click "OK" you will be redirected to the video. Click Play and then again on the MediasiteDownloader bookmark.\nNote: Your browser may block the redirect. Make sure to allow pop-ups for this website.'),window.open(document.getElementById("player-iframe").src)),"object"!=typeof MediasitePlayer?fetch(window.location.origin+document.getElementById("ServicePath").innerHTML+"/GetPlayerOptions",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify({getPlayerOptionsRequest:{ResourceId:document.getElementById("ResourceId").innerHTML,QueryString:"",UseScreenReader:"false",UrlReferrer:""}})}).then(a=>a.json()).then(c=>{if(document.head.insertAdjacentHTML("beforeend","<style type='text/css'>.modal-window {position: fixed;display: flex;justify-content: center;align-items: center;background-color: rgba(0, 0, 0, 0.75);top: 0;right: 0;bottom: 0;left: 0;z-index: 999;opacity: 0;pointer-events: none;}.modal-window:target {opacity: 1;pointer-events: auto;}.modal-window > div {width: 450px;position: absolute;padding: 3em;background: #ffffff;color: #333333;border-radius: 5px;}.modal-window header {font-weight: bold;}.modal-window h1 {font-size: 150%;margin: 0 0 15px;color: #333333;}.modal-close {color: #4c4c4c;line-height: 35px;position: absolute;right: 5px;text-align: center;top: 5px;width: 70px;text-decoration: none;border: #4c4c4c;border-style: solid;border-radius: 5px;border-width: 1px;}.modal-window > div > ul > li {margin: 10px 0;}.MSDLthumbnail {width: 350px;vertical-align: middle;margin-bottom: 4px;}div#MSDLinfo {max-height: 70vh;min-height: 5vh;overflow-y: auto;}</style>"),document.contains(document.getElementById("open-modal"))&&document.getElementById("open-modal").remove(),"OnDemand"!=c.d.Presentation.PlayStatus)document.body.insertAdjacentHTML("beforeend",'<div id="open-modal" class="modal-window"><div><a href="#" title="Close" class="modal-close">Close</a><p style="font-size: 20px;">Lecture is currently not available on-demand and therefore cannot be downloaded.<br>Try again later.</p></div></div>');else{document.body.insertAdjacentHTML("beforeend",'<div id="open-modal" class="modal-window"><div><div style="font-size: 20px;line-height: 45px;position: absolute;left: 20px;top: 5px;">MediasiteDownloader (<a href="https://github.com/KLVN/MediasiteDownloader" target="_blank">GitHub</a>)</div><a href="#" title="Close" class="modal-close">Close</a><div id="MSDLinfo"><ul style="list-style: outside; !important"><li>Copy the title: <input type="text" onClick="this.select();" value="'+document.title+'"></li><li>Right-click on the thumbnail(s) and choose "Save <span style="font-weight: bold;">link</span> as..."</li><div id="MSDLvideos"></div><li>Paste in to rename file correctly and save it</li><li>Click <a href="https://klvn.github.io/MediasiteDownloader/" target="_blank">here</a> for more detailed instructions</li></ul></div></div></div>');for(var b=c.d.Presentation.Streams,e=!1,a=0;a<b.length;a++)if(b[a].VideoUrls.length){for(var d=0;d<b[a].VideoUrls.length;d++)if("video/mp4"==b[a].VideoUrls[d].MimeType){e=!0;var f=window.location.origin+b[a].ThumbnailUrl,g=b[a].VideoUrls[d].Location;document.getElementById("MSDLvideos").innerHTML+="<li><a href='"+g+"' target='_blank'><img class='MSDLthumbnail' src='"+f+"'></a></li>"}}if(null!=c.d.Presentation.VodcastUrl){e=!0;var f=window.location.origin+c.d.Presentation.ThumbnailUrl,g=c.d.Presentation.VodcastUrl;document.getElementById("MSDLvideos").innerHTML+="<li>Vodcast:<br><a href='"+g+"' target='_blank'><img class='MSDLthumbnail' src='"+f+"'></a></li>"}e||(document.getElementById("MSDLinfo").innerHTML="<li>Sorry, no video(s) available.</li>")}Mediasite.Player.API.pause(),location.href="#open-modal"}):fetch(window.location.origin+SiteData.PlayerService+"/GetPlayerOptions",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify({getPlayerOptionsRequest:{ResourceId:SiteData.PresentationId,QueryString:"",UseScreenReader:"false",UrlReferrer:""}})}).then(a=>a.json()).then(c=>{if(document.head.insertAdjacentHTML("beforeend","<style type='text/css'>.modal-window {position: fixed;display: flex;justify-content: center;align-items: center;background-color: rgba(0, 0, 0, 0.75);top: 0;right: 0;bottom: 0;left: 0;z-index: 999;opacity: 0;pointer-events: none;}.modal-window:target {opacity: 1;pointer-events: auto;}.modal-window > div {width: 450px;position: absolute;padding: 3em;background: #ffffff;color: #333333;border-radius: 5px;}.modal-window header {font-weight: bold;}.modal-window h1 {font-size: 150%;margin: 0 0 15px;color: #333333;}.modal-close {color: #4c4c4c;line-height: 35px;position: absolute;right: 5px;text-align: center;top: 5px;width: 70px;text-decoration: none;border: #4c4c4c;border-style: solid;border-radius: 5px;border-width: 1px;}.modal-window > div > ul > li {margin: 10px 0;}.MSDLthumbnail {width: 350px;vertical-align: middle;margin-bottom: 4px;}div#MSDLinfo {max-height: 70vh;min-height: 5vh;overflow-y: auto;}</style>"),document.contains(document.getElementById("open-modal"))&&document.getElementById("open-modal").remove(),"OnDemand"!=c.d.Presentation.PlayStatus)document.body.insertAdjacentHTML("beforeend",'<div id="open-modal" class="modal-window"><div><a href="#" title="Close" class="modal-close">Close</a><p style="font-size: 20px;">Lecture is currently not available on-demand and therefore cannot be downloaded.<br>Try again later.</p></div></div>');else{document.body.insertAdjacentHTML("beforeend",'<div id="open-modal" class="modal-window"><div><div style="font-size: 20px;line-height: 45px;position: absolute;left: 20px;top: 5px;">MediasiteDownloader (<a href="https://github.com/KLVN/MediasiteDownloader" target="_blank">GitHub</a>)</div><a href="#" title="Close" class="modal-close">Close</a><div id="MSDLinfo"><ul style="list-style: outside; !important"><li>Copy the title: <input type="text" onClick="this.select();" value="'+document.title+'" style="background-color: #FFF"></li><li>Right-click on the thumbnail(s) and choose "Save <span style="font-weight: bold;">link</span> as..."</li><div id="MSDLvideos"></div><li>Paste in to rename file correctly and save it</li><li>Click <a href="https://klvn.github.io/MediasiteDownloader/" target="_blank">here</a> for more detailed instructions</li></ul></div></div></div>');for(var b=c.d.Presentation.Streams,e=!1,a=0;a<b.length;a++)if(b[a].VideoUrls.length){for(var d=0;d<b[a].VideoUrls.length;d++)if("video/mp4"==b[a].VideoUrls[d].MimeType){e=!0;var f=window.location.origin+b[a].ThumbnailUrl,g=b[a].VideoUrls[d].Location;document.getElementById("MSDLvideos").innerHTML+="<li><a href='"+g+"' target='_blank'><img class='MSDLthumbnail' src='"+f+"'></a></li>"}}if(null!=c.d.Presentation.VodcastUrl){e=!0;var f=window.location.origin+c.d.Presentation.ThumbnailUrl,g=c.d.Presentation.VodcastUrl;document.getElementById("MSDLvideos").innerHTML+="<li>Vodcast:<br><a href='"+g+"' target='_blank'><img class='MSDLthumbnail' src='"+f+"'></a></li>"}e||(document.getElementById("MSDLinfo").innerHTML="<li>Sorry, no video(s) available.</li>")}MediasitePlayer.pause(),location.href="#open-modal"})})()