diff --git a/42cal_bookmarklet.js b/42cal_bookmarklet.js index 1a3433e..94594c7 100644 --- a/42cal_bookmarklet.js +++ b/42cal_bookmarklet.js @@ -66,8 +66,8 @@ function addExtraData(event, callback) { parser = new DOMParser(); doc = parser.parseFromString(data, "text/html"); const description = doc.querySelector('.notification-text').textContent; - const duration = doc.querySelector('.icon-clock').parentElement.children[2].textContent; - const _location = doc.querySelector('.icon-location').parentElement.children[1].textContent; + const duration = doc.querySelector('.icon-clock')?.parentElement.children[2].textContent; + const _location = doc.querySelector('.icon-location')?.parentElement.children[1].textContent; if (description) event.description = description; else @@ -161,4 +161,4 @@ function open_upcoming_events_new_tab(only_subscribed_events) { } /* End Functions */ -open_upcoming_events_new_tab(false); \ No newline at end of file +open_upcoming_events_new_tab(false); diff --git a/42cal_bookmarklet.min.js b/42cal_bookmarklet.min.js index 8948e4d..299e13f 100644 --- a/42cal_bookmarklet.min.js +++ b/42cal_bookmarklet.min.js @@ -1 +1 @@ -b="https://profile.intra.42.fr/",n=(t,r)=>fetch(t).then(t=>{if(!t.ok)throw Error(`HTTP Error! Status:${t.status}`);return t.text()}).then(t=>r(null,t)).catch(t=>r(t,"")),a=t=>new Date(t).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",n(b+`events.json?start=${d=(q=new Date).getFullYear()}-${u=String(q.getMonth()+1).padStart(2,"0")}-${v=String(q.getDate()).padStart(2,"0")}&end=${d+1}-${u}-${v}`,(t,r)=>{Promise.all(JSON.parse(r).map(t=>new Promise(r=>{t.id&&t.title&&t.end&&t.start?n(b+`${kind="exam"==t.kind?"exams":"events"}/${t.id}`,(o,l)=>{o?(alert("Error2:"+o),r()):(o=(h=(parser=new DOMParser).parseFromString(l,"text/html")).querySelector(".modal-body").textContent,e=h.querySelector(".icon-clock").parentElement.children[2].textContent,c=h.querySelector(".icon-location").parentElement.children[1].textContent,t.p=o||"Could not fetch p",e?t.e=e:t.e="Could not fetch duration",c?t.f=c:t.f="Could not fetch location",r(t))}):r()}))).then(t=>(t.filter(t=>t),x="