var base_url,popup=null;function http_get(e,t,n=[],o="GET",i=null){var s=new XMLHttpRequest;s.addEventListener("load",t),s.open(o,e,!0),window.__EDPUZZLE_DATA__&&window.__EDPUZZLE_DATA__.token&&n.push(["authorization",window.__EDPUZZLE_DATA__.token]);for(const e of n)s.setRequestHeader(e[0],e[1]);s.send(i)}function init(){"edpuzzle.hs.vc"==window.location.hostname?alert("To use this, drag this button into your bookmarks bar. Then, run it when you're on an Edpuzzle assignment."):/https{0,1}:\/\/edpuzzle.com\/assignments\/[a-f0-9]{1,30}\/watch/.test(window.location.href)?getAssignment():window.canvasReadyState?handleCanvasURL():window.schoologyMoreLess?handleSchoologyURL():alert("Please run this script on an Edpuzzle assignment. For reference, the URL should look like this:\nhttps://edpuzzle.com/assignments/{ASSIGNMENT_ID}/watch")}function handleCanvasURL(){let e=window.location.href.split("/");http_get(`/api/v1/courses/${e[4]}/assignments/${e[6]}`,(function(){http_get(JSON.parse(this.responseText).url,(function(){let e=JSON.parse(this.responseText).url;alert("Please re-run this script in the newly opened tab. If nothing happens, then allow popups on Canvas and try again."),open(e)}))}))}function handleSchoologyURL(){http_get(`/external_tool/${window.location.href.split("/")[4]}/launch/iframe`,(function(){alert("Please re-run this script in the newly opened tab. If nothing happens, then allow popups on Schoology and try again.");let e=this.responseText.replace(//,""),t=document.createElement("div");t.innerHTML=e;let n=t.querySelector("form"),o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name","ext_submit"),o.setAttribute("value","Submit"),n.append(o),document.body.append(t),n.setAttribute("target","_blank"),n.submit(),t.remove()}))}function getAssignment(e){var t=window.location.href.split("/")[4];void 0!==t?http_get("https://edpuzzle.com/api/v3/assignments/"+t,(function(){var e=JSON.parse(this.responseText);"2"==(""+this.status)[0]?openPopup(e):alert(`Error: Status code ${this.status} recieved when attempting to fetch the assignment data.`)})):alert("Error: Could not infer the assignment ID. Are you on the correct URL?")}function openPopup(e){var t,n=e.medias[0],o=e.teacherAssignments[0],i=new Date(o.preferences.startDate),s=new Date(n.createdAt);thumbnail=n.thumbnailURL,thumbnail.startsWith("/")&&(thumbnail="https://"+window.location.hostname+thumbnail),t=""==o.preferences.dueDate?"no due date":"due on "+new Date(o.preferences.dueDate).toDateString();var a=`\n \n \n \n