Nooble9781 / Firefly Timetable

// ==UserScript==
// @name         Firefly Timetable
// @namespace    https://elizabethcollege.fireflycloud.net/*
// @version      1.0
// @description  try to add back the better timetable
// @author       Kieran Aslett
// @match        https://elizabethcollege.fireflycloud.net/*
// @grant        none
// @copyright 2019, Nooble9781 (https://openuserjs.org/users/Nooble9781)
// @license MIT
// ==/UserScript==

(function () {
  window.onload = function () {
	if (window.location.href == "https://elizabethcollege.fireflycloud.net/student-dashboard") {
      let jquery = document.createElement("script");
      jquery.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js';
      document.head.appendChild(jquery);

      let style = document.createElement("style");
      style.innerHTML = '#cTimetable .ff_container-dashboard-section__main  {overflow-x: auto; white-space: nowrap; } div.tttable {  text-align: center; width:100%; border: 1px solid black;  border-collapse: collapse;}.divTable.tttable .divTableCell, .divTable.tttable .divTableHead {  width: 16.66667%; border: 1px solid black;}.divTable.tttable .divTableBody .divTableCell {  font-size: 13px; border: 1px solid black;}.divTable.tttable .divTableHead {  font-size: 15px;  font-weight: bold;  color: #444; background: #e6e6e6}.divTable{ display: table; }.divTableRow { display: table-row; }.divTableHeading { display: table-header-group;}.divTableCell, .divTableHead { display: table-cell;}.divTableHeading { display: table-header-group;}.divTableBody { display: table-row-group;}';
      document.head.appendChild(style);

      let dom = document.createElement("div");
	  dom.id = "cTimetable";
      dom.innerHTML = '<br><div class="ff_container-dashboard-section ff_container-dashboard-section--tasks"><div class="ff__container-dashboard-section__dialog"></div><header class="ff_container-dashboard-section__header"><h2 class="ff_container-dashboard-section__title">Timetable</h2></header><div class="ff_container-dashboard-section__main"><br><div class="divTable tttable"><div class="divTableHeading"><div class="divTableRow"><div class="divTableHead"></div><div class="divTableHead">Monday</div><div class="divTableHead">Tuesday</div><div class="divTableHead">Wednesday</div><div class="divTableHead">Thursday</div><div class="divTableHead">Friday</div></div></div><div class="divTableBody"><div class="divTableRow"><div class="divTableHead">Registration</div><div class="divTableCell"><!--Mon R--></div><div class="divTableCell"><!--Tue R--></div><div class="divTableCell"><!--Wed R--></div><div class="divTableCell"><!--Thu R--></div><div class="divTableCell"><!--Fri R--></div></div><div class="divTableRow"><div class="divTableHead">Period 1</div><div class="divTableCell"><!--Mon Period 1--></div><div class="divTableCell"><!--Tue Period 1--></div><div class="divTableCell"><!--Wed Period 1--></div><div class="divTableCell"><!--Thu Period 1--></div><div class="divTableCell"><!--Fri Period 1--></div></div><div class="divTableRow"><div class="divTableHead">Period 2</div><div class="divTableCell"><!--Mon Period 2--></div><div class="divTableCell"><!--Tue Period 2--></div><div class="divTableCell"><!--Wed Period 2--></div><div class="divTableCell"><!--Thu Period 2--></div><div class="divTableCell"><!--Fri Period 2--></div></div><div class="divTableRow"><div class="divTableHead">Assembly</div><div class="divTableCell"><!--Mon Assembly--></div><div class="divTableCell"><!--Tue Assembly--></div><div class="divTableCell"><!--Wed Assembly--></div><div class="divTableCell"><!--Thu Assembly--></div><div class="divTableCell"><!--Fri Assembly--></div></div><div class="divTableRow"><div class="divTableHead">Break</div><div class="divTableCell">Break</div><div class="divTableCell">Break</div><div class="divTableCell">Break</div><div class="divTableCell">Break</div><div class="divTableCell">Break</div></div><div class="divTableRow"><div class="divTableHead">Period 3</div><div class="divTableCell"><!--Mon Period 3--></div><div class="divTableCell"><!--Tue Period 3--></div><div class="divTableCell"><!--Wed Period 3--></div><div class="divTableCell"><!--Thu Period 3--></div><div class="divTableCell"><!--Fri Period 3--></div></div><div class="divTableRow"><div class="divTableHead">Period 4</div><div class="divTableCell"><!--Mon Period 4--></div><div class="divTableCell"><!--Tue Period 4--></div><div class="divTableCell"><!--Wed Period 4--></div><div class="divTableCell"><!--Thu Period 4--></div><div class="divTableCell"><!--Fri Period 4--></div></div><div class="divTableRow"><div class="divTableHead">Lunch</div><div class="divTableCell">Lunch</div><div class="divTableCell">Lunch</div><div class="divTableCell">Lunch</div><div class="divTableCell">Lunch</div><div class="divTableCell">Lunch</div></div><div class="divTableRow"><div class="divTableHead">Period 5</div><div class="divTableCell"><!--Mon Period 5--></div><div class="divTableCell"><!--Tue Period 5--></div><div class="divTableCell"><!--Wed Period 5--></div><div class="divTableCell"><!--Thu Period 5--></div><div class="divTableCell"><!--Fri Period 5--></div></div><div class="divTableRow"><div class="divTableHead">Period 6</div><div class="divTableCell"><!--Mon Period 6--></div><div class="divTableCell"><!--Tue Period 6--></div><div class="divTableCell"><!--Wed Period 6--></div><div class="divTableCell"><!--Thu Period 6--></div><div class="divTableCell"><!--Fri Period 6--></div></div><div class="divTableRow"><div class="divTableHead">Period 7</div><div class="divTableCell"><!--Mon Period 7--></div><div class="divTableCell"><!--Tue Period 7--></div><div class="divTableCell"><!--Wed Period 7--></div><div class="divTableCell"><!--Thu Period 7--></div><div class="divTableCell"><!--Fri Period 7--></div></div></div></div><br></div><footer class="ff_container-dashboard-section__footer"><a href="/planner" class="ff_container-dashboard-section__more-link">View your full planner</a></footer></div><br>';

      var subjectCalendar = undefined;
      var daysC = document.getElementById("ffComponent_176064").getElementsByClassName("ff-calendar-days");

      var periods = {
          "08:25": "R",
          "08:30": "Period 1",
          "09:30": "Period 2",
          "10:20": "Assembly",
          "11:00": "Period 3",
          "11:45": "Period 4",
          "13:35": "Period 5",
          "14:25": "Period 6",
          "15:15": "Period 7",
      }


      for (let y = 0; y < daysC.length; y++) {
          subjectCalendar = daysC[y].getElementsByClassName("ff-calendar-day-hasevents");
          for (let i = 0; i < subjectCalendar.length; i++) {
              let events = subjectCalendar[i];
              let eventsData = events.getElementsByClassName("ff-calendar-event-data");
              let eventsTime = events.getElementsByClassName("ff-calendar-event-time");
              let day = subjectCalendar[i].getElementsByClassName("ff-calendar-day-name")[0].innerHTML;

              for (let j = 0; j < eventsData.length; j++) {
                  let subject = eventsData[j].getElementsByClassName("ff-calendar-event-subject")[0].textContent;
                  let location = eventsData[j].getElementsByClassName("ff-calendar-event-location")[0].textContent;
                  let timeStart = eventsTime[j].getElementsByClassName("dtstart")[0].textContent;

                  dom.innerHTML = dom.innerHTML.toString().replace(("<!--" + day + " " + periods[timeStart] + "-->").toString(), (subject + "<br><i>" + location + "</i>").toString());
              }
          }
      }

      $(".ff_container-dashboard-section--tasks:first").after(dom)
	}
	  document.getElementById("section-header").getElementsByClassName("section-image")[0].src = "https://github.com/NoobleMcScrunchkin/ducky/raw/master/eksDee.png";

      document.getElementsByClassName("ff-page-meta-last-updated-by")[0].textContent = "Last updated by Henry Partington";

      var day = new Date().getDate();
      var month = new Date().getMonth() + 1;
      var year = new Date().getFullYear();
      document.getElementsByClassName("ff-page-meta-last-updated-on")[0].textContent = "Last updated on " + day + "/" + month + "/" + year;

      let test = document.getElementsByClassName("ff_module-task-todo__meta");
      for (let el in test) {
          test[el].textContent = "Henry Partington";
      }
  }
})();