javascript:(async()=>{function S(n,t){return n.reduce((o,e,a)=>o+e+(t[a]??""),"").replace(/>\s+<").replace(/\s+/g," ").trim()}var b=(n,...t)=>S(n,t),h=(n,...t)=>S(n,t);(async function(){"use strict";let n="https://uber.nicecloudsvc.com/wfm/webstation/my-schedule";if(!location.href.startsWith(n)){location.href=n;return}let t=document.querySelector("iframe");if(!t){alert("No schedule iframe found. Make sure you're on the NICE schedule page.");return}let o=N(t),e=o?k(o):new Date,a=await E(e);if(!a)return;let r=await C(t,a);if(console.log(`[NICE Sync] Total events: ${r.length}`),r.length===0){alert("No events found to export.");return}let s=[...r].sort((u,p)=>u.start.getTime()-p.start.getTime()),l=s[0].start,i=s[s.length-1].start,c=`NICE Schedule ${`${y(l)} to ${y(i)}`}.ics`,g=A(r);x({icsContent:g,fileName:c,events:r})})();function E(n){return new Promise(t=>{let o=y(n),e=document.createElement("dialog");e.innerHTML=b`

Date Range

Leave blank to scrape until an empty week is reached.
`,e.classList.add("date-range");let a=!1,r=s=>{a||(a=!0,e.close(),e.remove(),t(s))};document.body.appendChild(e),e.showModal(),e.querySelector(".btn-start").addEventListener("click",()=>{let s=e.querySelector("#dr-start"),l=e.querySelector("#dr-end");if(!s.value){s.focus();return}let[i,d,c]=s.value.split("-").map(Number),g=new Date(i,d-1,c),u=null;if(l.value){let[p,f,m]=l.value.split("-").map(Number);u=new Date(p,f-1,m)}r({start:g,end:u})}),e.querySelector(".btn-cancel").addEventListener("click",()=>r(null)),e.querySelector(".btn-close").addEventListener("click",()=>r(null)),e.addEventListener("cancel",()=>r(null))})}function x({icsContent:n,fileName:t,events:o}){let e=[...o].sort((d,c)=>d.start.getTime()-c.start.getTime()),a=e[0].start,r=e[e.length-1].start,s=Math.ceil((r.getTime()-a.getTime())/(10080*60*1e3))+1,l=d=>d.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=document.createElement("dialog");i.innerHTML=b`

Export Schedule

Scraped ${o.length} events across ${s} weeks, between ${l(a)} and ${l(r)}.

`,document.body.appendChild(i),i.showModal(),i.querySelector(".btn-download").addEventListener("click",()=>{R(n,t,"text/calendar;charset=utf-8")}),i.querySelector(".btn-close").addEventListener("click",()=>{i.close()}),i.addEventListener("close",()=>{i.remove()})}function k(n){let t=parseInt(n.slice(1,3),10),o=parseInt(n.slice(3,5),10),e=parseInt(n.slice(5,7),10);return new Date(2e3+t,o-1,e)}function N(n){return(n.contentWindow?.location.href??n.src??"").match(/startDay=(\d+)/)?.[1]??null}function T(n){let t=String(n.getFullYear()%25100).padStart(2,"0"),o=String(n.getMonth()+1).padStart(2,"0"),e=String(n.getDate()).padStart(2,"0");return`1${t}${o}${e}`}function $(n){return`https://uber.nicecloudsvc.com/agent/displayMyScheduleAction.mvc?startDay=${n}&viewFormat=weekly`}async function I(n,t,o=2e4){return new Promise(e=>{let a=setTimeout(()=>{console.log(`[NICE Sync] Navigation timed out after ${o}ms`),e(!1)},o);n.addEventListener("load",()=>{clearTimeout(a),e(!0)},{once:!0}),n.contentWindow.location.href=t})}async function C(n,t){let o=[],e=t.end?1/0:52;console.log(`[NICE Sync] Starting from: ${t.start.toDateString()}`+(t.end?`, ending at week containing: ${t.end.toDateString()}`:` (go until done, cap ${e})`));for(let s=0;st.end)break;let i=$(T(l));if(console.log(`[NICE Sync] Page ${s+1}: navigating to ${i}`),!await I(n,i)){console.log("[NICE Sync] Navigation timed out, stopping");break}let c=n.contentDocument;if(!c){console.log("[NICE Sync] No iframe document, stopping");break}let g=L(c);if(g.length===0){if(t.end){console.log(`[NICE Sync] Page ${s+1}: no rows, continuing (end date set)`);continue}console.log(`[NICE Sync] Page ${s+1}: no rows, stopping`);break}let u=M(g);console.log(`[NICE Sync] Page ${s+1}: ${u.length} events`),o.push(...u)}let a=new Date(t.start.getFullYear(),t.start.getMonth(),t.start.getDate()),r=t.end?new Date(t.end.getFullYear(),t.end.getMonth(),t.end.getDate(),23,59,59,999):null;return o.filter(s=>!(s.startr))}function L(n){return Array.from(n.querySelectorAll("#scheduleDetailTableDiv > table tr")).filter(t=>{let o=t.textContent.trim();return!(t.className==="schedTableHdr"||o===""||o==="Add an activity"||o.endsWith("OFF")||o.endsWith("No data available")||t.children.length===1)}).map(t=>Array.from(t.children))}function M(n){let t=[],o,e,a;for(let r of n){if(r[0]?.querySelector('[title="Trade schedule"]')){let D=r[1]?.textContent?.trim(),[,v]=D?.split(" ")??["",""];[e,a,o]=v.split("/").map(Number)}let l=r[r.length-5]?.textContent?.trim()??"",i=r[r.length-4]?.textContent?.trim()??"12:00 AM",d=r[r.length-3]?.textContent?.trim()??"12:00 AM",[c,g]=w(i),[u,p]=w(d),f=new Date(2e3+o,e-1,a,c,g,0,0),m=new Date(2e3+o,e-1,a,u,p,0,0);m