Skip to content

Instantly share code, notes, and snippets.

@SimonNitzsche
Last active July 1, 2022 08:36
Show Gist options
  • Save SimonNitzsche/24f7644a9b0ae46524c7a34b4d2ba8cd to your computer and use it in GitHub Desktop.
Save SimonNitzsche/24f7644a9b0ae46524c7a34b4d2ba8cd to your computer and use it in GitHub Desktop.
ELF2022 timetable grabber
function actsToJson() {
window._dayMap = ["July 6, 2022 ", "July 7, 2022 ", "July 8, 2022 ", "July 9, 2022 ", "July 10, 2022 "];
let dayContainer = $(".timetable > .container > .timetable__inner > .timetable__main > .swiper-wrapper");
window._actList = [];
for(let dayIndex = 0; dayIndex < dayContainer.children.length; ++dayIndex) {
let dayElement = dayContainer.children[dayIndex];
//console.log(window._dayMap[dayIndex], dayElement);
let top = dayElement.children[0];
let stagesElements = [...(top.children)].find(c=>{return c.classList.contains("timetable__slider-wrapper")}).children[0].children[0]
stagesElements = ([...stagesElements.classList].includes("swiper-wrapper")) ? stagesElements.children : [stagesElements];
//console.log(top)
let stages = ((c)=>{let l = []; for(let i = 0; i < c.length; ++i) l.push(c[i].innerText); return l})(stagesElements);
for(let i = 0; i < stages.length; ++i) if(window._actList[stages[i]] === undefined) window._actList[stages[i]] = [];
//console.log(stages);
let bottom = dayElement.children[1];
let stagesActs = bottom.children[1].children[0];
stagesActs = ([...stagesActs.classList].includes("swiper-wrapper")) ? stagesActs.children : [stagesActs];
//console.log(stagesActs);
for(let i = 0; i < stagesActs.length; ++i) {
let stageActs = stagesActs[i].children;
let stage = stages[i];
for(let j = 0; j < stageActs.length; ++j) {
let stageAct = stageActs[j];
//console.log(stageAct)
let ts = stageAct.getAttribute("data-time-start");
let te = stageAct.getAttribute("data-time-end");
te = te == "00:00" ? "23:59" : te;
if(![...stageAct.classList].includes("timetable__slot")) continue;
let act = stageAct.children[0].innerHTML.trim();
let timeToComp = (t) => {return parseFloat(t.replace(":","."));};
let obj = {
time: window._dayMap[(timeToComp(ts) > 12) ? dayIndex : dayIndex + 1]+ts,act:act,end: window._dayMap[(timeToComp(te) > 12) ? dayIndex : dayIndex + 1]+te};
//console.log(stage, obj);
window._actList[stage].push(obj);
}
}
}
return JSON.stringify([
{
"name": "Mainstage",
"divname": "mainstage",
"colorA": "#5d569d",
"colorB": "#9189be",
"acts": window._actList["MAINSTAGE"]
},
{
"name": "Hard Dance Factory",
"divname": "hdfactory",
"colorA": "#f0814e",
"colorB": "#f6ae87",
"acts": window._actList["HARD DANCE FACTORY"]
},
{
"name": "Club Circus",
"divname": "clubcircus",
"colorA": "#e05e76",
"colorB": "#ea99a2",
"acts": window._actList["CLUB CIRCUS"]
},
{
"name": "Heineken Starclub",
"divname": "heinekenstarclub",
"colorA": "#629a67",
"colorB": "#9db996",
"acts": window._actList["HEINEKEN STARCLUB"]
},
{
"name": "Shutdown Cave",
"divname": "shutdowncave",
"colorA": "#40371f",
"colorB": "#7f6d3e",
"acts": window._actList["SHUTDOWN CAVE"]
}
]).replaceAll("&amp;", "&");
}
actsToJson();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment