Daymap Graphics

Allows Daymap to be customised.

当前为 2022-07-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Daymap Graphics
  3. // @namespace apate98
  4. // @version 7.0.2
  5. // @description Allows Daymap to be customised.
  6. // @author apate98
  7. // @match https://*.daymap.net/*
  8. // @icon https://www.google.com/s2/favicons?domain=daymap.net
  9. // @require https://cdn.jsdelivr.net/npm/p5@1.4.1/lib/p5.js
  10. // @grant none
  11. // @license GNU GPLv3
  12. // ==/UserScript==
  13.  
  14. // Changelog
  15. // 6.0.0: Added changelog and introduced compatibility for Daymap's timetable view.
  16. // 6.0.1: Fixed a problem where opacity is reversed in timetable view.
  17. // 6.0.2: Changed the manual background change to apply to underlay rather than body. Increased speed of underlay rainbow.
  18. // 6.0.3: Allowed manual changing of the attendance indicator colour to anything, replacing the old background-color with background.
  19. // 6.1.0: Allows blurring behind the foreground cards, giving a glassy effect.
  20. // 6.1.1: Made header also change opacity and made logo transparent.
  21. // 7.0.0: Removed all jQuery usage to enable compatibility with new Daymap. Also basically rewrote a bunch of code to work with new Daymap.
  22. // 7.0.1: Fixed an issue to do with timetable view transparency. Also made transparent cards match with dark mode or light mode.
  23. // 7.0.2: Fixed transparency... again. This time for feed view.
  24.  
  25. // Credits and thanks:
  26. // Special thanks to Kelvin for troubleshooting many issues when transferring to the new Daymap, whom without I could not have solved any of the problems.
  27.  
  28. // TODO:
  29. // Presets
  30. // Change homework page opacity
  31. // Change summary/portfolio page opacity
  32. // Make diary look a bit nicer
  33. // Change class list opacity
  34. // Change task finder opacity
  35. // Change results page opacity
  36. // Change schedule page opacity
  37. // Change my messages page opacity
  38. // Change my calenders page opacity
  39. // Add option to revert Daymap to original layout
  40.  
  41. // Compatibile pages:
  42. // Feed View
  43. // Timetable
  44. // Mobile Daymap
  45. // My Details
  46.  
  47. // Tips:
  48. // Change the Daymap.Web_DaymapIdentityCookie cookie expiry date to 2038-01-18T18:14:07.000Z every time you log into Daymap. Daymap Graphics cannot do this automatically as the cookie is HTTP only, and creating another cookie witht the same data can lock a person out of Daymap.
  49.  
  50. // Known issues:
  51. // When changing messages pages, the messages are opaque.
  52.  
  53. // Local storage functions by DY from Khan Academy at https://www.khanacademy.org/profile/darrylyeo/projects
  54. var storage;
  55. (function() {
  56. storage = localStorage;
  57. })();
  58.  
  59. function getItem(key) {
  60. if(storage != undefined) {
  61. return storage.getItem(key);
  62. }
  63. storage = this.localStorage;
  64. return null;
  65. };
  66.  
  67. function setItem(key, value) {
  68. if(storage != undefined) {
  69. storage.setItem(key, value);
  70. } else {
  71. storage = this.localStorage;
  72. }
  73. };
  74.  
  75. function rainbowMove(val1, val2, val3, val4, val5, speed) {
  76. speed = speed ? speed : 1;
  77. val1 += (Math.random() - val4) * speed;
  78. val2 += (Math.random() - val5) * speed;
  79. val1 = val1 < 0 ? 0 : val1 > 410 ? 410 : val1;
  80. val2 = val2 < 0 ? 0 : val2 > 410 ? 410 : val2;
  81. return [val1, val2, val3, val4, val5];
  82. }
  83.  
  84. function constrain(num, min, max) {
  85. return num < min ? min : num > max ? max : num;
  86. }
  87.  
  88.  
  89. var lessonStart;
  90. var lessonEnd;
  91.  
  92. function timeOfDiaryEl(lessonEl) {
  93. if(lessonEl.innerText.substr(1, 1) === ":" && lessonEl.innerText.substr(12, 1) !== ":") {
  94. lessonStart = lessonEl.innerText.substr(0, 1) + lessonEl.innerText.substr(2, 2);
  95. lessonEnd = lessonEl.innerText.substr(11, 2) + lessonEl.innerText.substr(14, 2);
  96. if(lessonEl.innerText.substr(5, 1) === "P") {
  97. lessonStart = Number(lessonStart) + 1200;
  98. }
  99. }
  100. if(lessonEl.innerText.substr(1, 1) === ":" && lessonEl.innerText.substr(12, 1) === ":") {
  101. lessonStart = lessonEl.innerText.substr(0, 1) + lessonEl.innerText.substr(2, 2);
  102. lessonEnd = lessonEl.innerText.substr(11, 1) + lessonEl.innerText.substr(13, 2);
  103. if(lessonEl.innerText.substr(5, 1) === "P") {
  104. lessonStart = Number(lessonStart) + 1200;
  105. }
  106. if(lessonEl.innerText.substr(16, 1) === "P") {
  107. lessonEnd = Number(lessonEnd) + 1200;
  108. }
  109. }
  110. if(lessonEl.innerText.substr(1, 1) !== ":" && lessonEl.innerText.substr(13, 1) !== ":") {
  111. lessonStart = lessonEl.innerText.substr(0, 2) + lessonEl.innerText.substr(3, 2);
  112. lessonEnd = lessonEl.innerText.substr(12, 2) + lessonEl.innerText.substr(15, 2);
  113. }
  114. if(lessonEl.innerText.substr(1, 1) !== ":" && lessonEl.innerText.substr(13, 1) === ":") {
  115. lessonStart = lessonEl.innerText.substr(0, 2) + lessonEl.innerText.substr(3, 2);
  116. lessonEnd = lessonEl.innerText.substr(12, 1) + lessonEl.innerText.substr(14, 2);
  117. if(lessonEl.innerText.substr(17, 1) === "P") {
  118. lessonEnd = Number(lessonEnd) + 1200;
  119. }
  120. }
  121. return [lessonStart, lessonEnd];
  122. }
  123.  
  124. // By joshuacockrell based on a post by Maxwell Collard and edited by Mahdi https://stackoverflow.com/a/25582882/#36481059
  125. function randn_bm() {
  126. let u = 0, v = 0;
  127. while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
  128. while(v === 0) v = Math.random();
  129. let num = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
  130. num = num / 10.0 + 0.5; // Translate to 0 -> 1
  131. if (num > 1 || num < 0) return randn_bm(); // resample between 0 and 1
  132. return num;
  133. }
  134.  
  135. var attendanceColour = "#7FFFD4";
  136. var bodyColour = "#ABCDEF";
  137. var cardColour = "#E6E6E6";
  138. var date;
  139. var classEls = [];
  140. var i;
  141. var anything = [];
  142. const animatedPhotoLinks = [5097557231353856, 6056784221388800, 5537046336684032]; //4617381095718912 (khanemon), 5169842873122816 (were in a comic, not working yet)
  143. const animatedPhotoLinks2 = [5097557231353856, 6056784221388800, 4617381095718912];
  144. var r50d = [];
  145.  
  146.  
  147.  
  148. (function() {
  149. 'use strict';
  150. try {
  151. if(!getItem("usedTools")) {
  152. document.querySelector("body").innerHTML += `
  153. <div id='guide'></div>
  154. <style>
  155. #guide {
  156. position: absolute;
  157. }
  158. </style>
  159. `;
  160. }
  161. document.querySelector("body").style.fontFamily='Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif';
  162. document.querySelector("head").innerHTML += `<style>
  163. #toolbox {
  164. top: 15vh;
  165. left: 20vw;
  166. background-color: rgba(229, 229, 229, 0.8);
  167. position: fixed;
  168. width: 60vw;
  169. height: 70vh;
  170. padding: 50px;
  171. border-width: 50px;
  172. border-image: linear-gradient(red, yellow);
  173. }
  174. #closeToolbox {
  175. float: right;
  176. color: rgb(200, 200, 200);
  177. font-size: 2.5vw;
  178. cursor: pointer;
  179. background-color: rgba(255, 255, 255, 0.6);
  180. border-radius: 50%;
  181. width: 2.5vw;
  182. height: 2.5vw;
  183. text-align: center;
  184. vertical-align: baseline;
  185. line-height: 2.3vw;
  186. }
  187. #reloadBtn {
  188. position: absolute;
  189. bottom: 2vw;
  190. background-image: radial-gradient(100% 100% at 100% 0, #5adaff 0, #5468ff 100%);
  191. border: 0;
  192. border-radius: 4.25%;
  193. width: 15vw;
  194. height: 4vh;
  195. color: white;
  196. cursor: pointer;
  197. }
  198. #bodyBackground, #additionalCSS {
  199. display:inline-block;
  200. width:100%;
  201. }
  202. </style>`;
  203. {
  204. let toolbox = document.createElement("div");
  205. toolbox.innerHTML = `<div id='closeToolbox'>×</div>
  206. <div>
  207. <form oninput='blurAmount.value=parseFloat(blur.value)'>
  208. Opacity: <input id='translucent' type='range' min='0' max='1' step='0.001'></input><br/>
  209. Blur amount: <input id='blur' type='range' min='0' max='50' step='0.1' name='blur'></input>
  210. <input id='blurAmount' name='blurAmount' readonly='true' style='background-color:light-gray;'></input><br/>
  211. Auto animated photo:<input id='autoAnimatedPhoto' type='checkbox'></input><br/>
  212. Auto attendance rainbow:<input id='autoAttendanceRainbow' type='checkbox'></input><br/>
  213. Animated profile project id:&nbsp;<input id='animatedProfileProjectId' type='number'></input><br/>
  214. Auto body background:<input id='autoBackground' type='checkbox'/><br/>
  215. Body background CSS property (value only):<input type='text' id='bodyBackground'/><br/>
  216. Additional CSS (CSS style declaration):<textarea id='additionalCSS' rows='3'></textarea>
  217. </form>
  218. </div>
  219. <button id='reloadBtn'>&nbsp;Apply changes and reload page</button>`;
  220. toolbox.setAttribute("id","toolbox");
  221. toolbox.style.display = "none";
  222. document.querySelector(".main-layout").appendChild(toolbox);
  223. }
  224. document.querySelector("head").innerHTML += "<style id='customStyles'></style>";
  225. var tools = setInterval(function() {if(document.querySelector("li[menu-id='60']")) {document.querySelector("li[menu-id='60']").parentNode.innerHTML = "<tr><div class='tools' style='border-left: 2px solid #a0d7f1; text-align: left; padding: 7px 11px;' onclick='document.getElementById(`toolbox`).style.display = `block`;'>Daymap Graphics Command Center</div></div></tr><style>.tools:hover{background-color:#e5e5e5}</style>"; clearInterval(tools)}}, 50);
  226. {
  227. let bodyUnderlay = document.createElement("div");
  228. bodyUnderlay.setAttribute("id", "bodyUnderlay");
  229. document.querySelector("head").innerHTML += "<style>#bodyUnderlay {position: fixed; width: 100%; height: 100%; top: 0; z-index: -2147483647;}</style>";
  230. document.querySelector("#ctl00_mainBody").appendChild(bodyUnderlay);
  231. }
  232. document.querySelector("#reloadBtn").innerHTML = '<svg width="0.75vw" height="0.75vw" viewBox="0 0 24 24" class="_18zn2ntb"><path fill="currentColor" d="M18.071 18.644c-3.532 3.232-9.025 3.13-12.452-.297a9.014 9.014 0 0 1-2.636-6.866 1 1 0 0 1 1.997.105 7.014 7.014 0 0 0 2.053 5.346c2.642 2.642 6.856 2.747 9.606.31h-1.81a1 1 0 1 1 0-2h4.242a1 1 0 0 1 1 1v4.243a1 1 0 0 1-2 0v-1.84zM7.361 6.757h1.81a1 1 0 0 1 0 2H4.93a1 1 0 0 1-1-1V3.515a1 1 0 1 1 2 0v1.84c3.532-3.231 9.025-3.13 12.452.298a9.014 9.014 0 0 1 2.636 6.866 1 1 0 1 1-1.997-.105 7.014 7.014 0 0 0-2.053-5.346c-2.642-2.642-6.856-2.747-9.606-.31z"></path></svg>' + document.querySelector("#reloadBtn").innerHTML;
  233. document.querySelector("#blurAmount").value = getItem("blurAmount");
  234. document.querySelector("#animatedProfileProjectId").value = getItem("animatedProfileProjectId");
  235. document.querySelector("#bodyBackground").value = getItem("bodyBackground");
  236. document.querySelector("#translucent").setAttribute("value", getItem("translucentMode"));
  237. document.querySelector("#blur").setAttribute("value", getItem("blurAmount"));
  238. if(getItem("autoAnimatedPhoto") != 0 && getItem("autoAnimatedPhoto")) {
  239. document.querySelector("#autoAnimatedPhoto").setAttribute("checked", 1);
  240. }
  241. if(getItem("autoAttendanceRainbow") != 0 && getItem("autoAttendanceRainbow")) {
  242. document.querySelector("#autoAttendanceRainbow").setAttribute("checked", 1);
  243. }
  244. if(getItem("autoBackground") != 0 && getItem("autoBackground")) {
  245. document.querySelector("#autoBackground").setAttribute("checked", 1);
  246. if(getItem("bodyBackground") != "" && getItem("bodyBackground") != undefined) {
  247. document.querySelector("#bodyUnderlay").style.background=getItem("bodyBackground");
  248. if(getItem("bodyBackground") === "linear-gradient(to bottom right, yellow, black, black, black)") {
  249. document.querySelector("#bodyUnderlay").innerHTML += "<style></style>";
  250. for(i = 0; i < 500; i ++) {
  251. anything[0] = Math.random() * 7.5;
  252. anything[1] = randn_bm() * 255;
  253. anything[2] = Math.random() * 100;
  254. anything[3] = Math.random() * 100;
  255. anything[4] = Math.random() + 1;
  256. anything[5] = (Math.random() - 0.5) * 90;
  257. if(anything[2] < 37.5 && anything[3] < 37.5) {
  258. continue;
  259. }
  260. document.querySelector("#bodyUnderlay").innerHTML += "<div class='r50d' style='width:" + anything[0] + "px;height:" + anything[0] + "px;top:" + anything[2] + "vh;left:" + anything[3] + "vw;position:absolute;border-radius:" + constrain(randn_bm() * 50, 0, 50) + "%;background-color:rgba(" + constrain(anything[1] * anything[4], 0, 255) + ", " + constrain((anything[1] > 127.5 ? (127.5 - anything[1]) : anything[1]) * anything[4], 0, 255) + ", " + constrain((255 - anything[1]) * anything[4], 0, 255) + ", " + Math.random() / 1.5 +");transform:rotate("+ anything[5] + "deg);'></div>";
  261. r50d.push("1," + Math.random() / 100 + "," + anything[5] + "," + (randn_bm() - 0.5) * 15);
  262. }
  263. }
  264. if(getItem("bodyBackground") === "url('https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLB_p0PncTtkrhaNDZtntrE3gKkoYw')") {
  265. setItem("bodyBackground", "black url('https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLB_p0PncTtkrhaNDZtntrE3gKkoYw')");
  266. window.location.href = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
  267. }
  268. }
  269. }
  270. document.querySelector("#customStyles").innerText = getItem("additionalCSS");
  271. document.querySelector("#additionalCSS").value = getItem("additionalCSS");
  272. i = 0;
  273.  
  274. setInterval(function() {
  275. for(i = 0; i < document.querySelectorAll(".r50d").length; i++) {
  276. document.querySelectorAll(".r50d")[i].style.transform = "scale(" + r50d[i].split(",")[0] + ", " + r50d[i].split(",")[0] + ") rotate(" + r50d[i].split(",")[2] + "deg)";
  277. r50d[i] = (parseFloat(r50d[i].split(",")[0]) + parseFloat(r50d[i].split(",")[1])) + "," + (parseFloat(r50d[i].split(",")[0]) >= 1.1 ? Math.abs(parseFloat(r50d[i].split(",")[1])) * -1 : parseFloat(r50d[i].split(",")[0]) <= 0.9 ? Math.abs(r50d[i].split(",")[1]) : parseFloat(r50d[i].split(",")[1])) + "," + (parseFloat(r50d[i].split(",")[2]) + parseFloat(r50d[i].split(",")[3])) + "," + parseFloat(r50d[i].split(",")[3]); i = i >= r50d.length - 1 ? 0 : i + 1;
  278. }
  279. }, 30);
  280.  
  281. document.querySelector("#closeToolbox").addEventListener("click", function() {
  282. document.querySelector("#toolbox").style.display = "none";
  283. });
  284. document.querySelector("#reloadBtn").addEventListener("click", function() {
  285. setItem("animatedProfileProjectId", document.querySelector("#animatedProfileProjectId").value);
  286. setItem("bodyBackground", document.querySelector("#bodyBackground").value);
  287. setItem("translucentMode", document.querySelector("#translucent").value);
  288. setItem("additionalCSS", document.querySelector("#additionalCSS").value);
  289. setItem("blurAmount", document.querySelector("#blur").value);
  290. location.reload();
  291. });
  292. document.querySelector("#autoAnimatedPhoto").addEventListener("click", function() {setItem("autoAnimatedPhoto", getItem("autoAnimatedPhoto") != 0 && getItem("autoAnimatedPhoto") ? 0 : 1);});
  293. document.querySelector("#autoAttendanceRainbow").addEventListener("click", function() {setItem("autoAttendanceRainbow", getItem("autoAttendanceRainbow") != 0 ? 0 : 1);});
  294. document.querySelector("#autoBackground").addEventListener("click", function() {setItem("autoBackground", getItem("autoBackground") != 0 && getItem("autoBackground") ? 0 : 1);});
  295. if (!document.querySelector(".sdIndicator")) {
  296. if(document.querySelector(".StudentBox > table > tbody")) {
  297. document.querySelector(".StudentBox > table > tbody").innerHTML += ('<tr><td colspan="3"><div id="divIndicators"><div><div class="sdIndicator" title="Term" style="background-color:#65EC0B">100</div><div class="sdCap">Attendance Tracking</div></div></div></td></tr>');
  298. document.querySelector(".sdIndicator").innerHTML += ("<style>.sdIndicator{color: #302F46;font-size: 16pt;width: 50px;height: 50px;border-radius: 25px;text-align: center;vertical-align: baseline;margin-left: auto;margin-right: auto;line-height: 50px;}</style>");
  299. } else {
  300. document.querySelector(".expContent").innerHTML += ('<tr><td colspan="3"><div id="divIndicators"><div><div class="sdIndicator" title="Term" style="background-color:#65EC0B">100</div><div class="sdCap">Attendance Tracking</div></div></div></td></tr>');
  301. document.querySelector(".sdIndicator").innerHTML += ("<style>.sdIndicator{color: #302F46;font-size: 16pt;width: 50px;height: 50px;border-radius: 25px;text-align: center;vertical-align: baseline;margin-left: auto;margin-right: auto;line-height: 50px;}</style>");
  302. }
  303. }
  304. for(i = 0; i < document.querySelectorAll(".itm .Error").length; i ++) {
  305. document.querySelectorAll(".itm .Error")[i].innerText = "Uh did you submit on Turnitin or something?";
  306. }
  307. var attendanceEl = document.querySelector(".sdIndicator");
  308. attendanceEl.classList.add("attendance");
  309. var cardEl = document.querySelector(".diaryDay");
  310. var attendanceRainbow = [0, 0, 0, 0.5, 0.5];
  311. var attendanceRainbow1 = [400, 5, 0, 0.5, 0.5];
  312. var attendanceRainbow2 = [210, 350, 0, 0.5, 0.5];
  313. var bodyRainbow = [200, 200, 0, 0.5, 0.5];
  314. var cardRainbow = [200, 200, 0, 0.5, 0.5];
  315. // To make random numbers into colours that actually look good, there is a method by Weather: https://www.khanacademy.org/computer-programming/the-randomish-quiz/6515084802260992
  316. setInterval(function(){attendanceRainbow = rainbowMove(attendanceRainbow[0], attendanceRainbow[1], attendanceRainbow[2], attendanceRainbow[3], attendanceRainbow[4] , 15); attendanceRainbow1 = rainbowMove(attendanceRainbow1[0], attendanceRainbow1[1], attendanceRainbow1[2], attendanceRainbow1[3], attendanceRainbow1[4] , 15); attendanceRainbow2 = rainbowMove(attendanceRainbow2[0], attendanceRainbow2[1], attendanceRainbow2[2], attendanceRainbow2[3], attendanceRainbow2[4] , 15)}, 10);
  317. setInterval(function(){if(attendanceRainbow[2]) {document.querySelector(".attendance").style.backgroundImage = "linear-gradient(" + attendanceRainbow[0] + "deg, rgb(" + bodyRainbow[0] + "," + (400 - attendanceRainbow1[0] + attendanceRainbow1[1]) / 2.5 + "," + (400 - attendanceRainbow1[1]) + ") -75%, rgb(" + attendanceRainbow[0] + "," + (400 - attendanceRainbow[0] + attendanceRainbow[1]) / 2.5 + "," + (400 - attendanceRainbow[1]) + ") 50%, rgb(" + attendanceRainbow2[0] + "," + (400 - attendanceRainbow2[0] + attendanceRainbow2[1]) / 2.5 + "," + (400 - attendanceRainbow2[1]) + ") 175%)";}}, 10);
  318. setInterval(function(){attendanceRainbow[3] = Math.random() / 2 + 0.25; attendanceRainbow[4] = Math.random() / 2 + 0.25; attendanceRainbow1[3] = Math.random() / 2 + 0.25; attendanceRainbow1[4] = Math.random() / 2 + 0.25; attendanceRainbow2[3] = Math.random() / 2 + 0.25; attendanceRainbow2[4] = Math.random() / 2 + 0.25;}, 5000);
  319. setInterval(function(){bodyRainbow = rainbowMove(bodyRainbow[0], bodyRainbow[1], bodyRainbow[2], bodyRainbow[3], bodyRainbow[4] , 10)}, 10);
  320. setInterval(function(){if(bodyRainbow[2]) {document.querySelector("#bodyUnderlay").style.backgroundColor = "rgb(" + bodyRainbow[0] + "," + (400 - bodyRainbow[0] + bodyRainbow[1]) / 2.5 + "," + (400 - bodyRainbow[1]) + ")";}}, 10);
  321. setInterval(function(){bodyRainbow[3] = Math.random() / 2 + 0.25; bodyRainbow[4] = Math.random() / 2 + 0.25;}, 2000);
  322. setInterval(function(){cardRainbow = rainbowMove(cardRainbow[0], cardRainbow[1], cardRainbow[2], cardRainbow[3], cardRainbow[4] , 10)}, 10);
  323. setInterval(function(){if(cardRainbow[2]) {cardEl.style.backgroundColor = "rgb(" + cardRainbow[0] + "," + (400 - cardRainbow[0] + cardRainbow[1]) / 2.5 + "," + (400 - cardRainbow[1]) + ")";}}, 10);
  324. setInterval(function(){cardRainbow[3] = Math.random() / 2 + 0.25; cardRainbow[4] = Math.random() / 2 + 0.25;}, 5000);
  325. attendanceRainbow[2] = getItem("autoAttendanceRainbow") != 0 && getItem("autoAttendanceRainbow") ? 1 : 0;
  326. attendanceEl.addEventListener("click", function() {
  327. attendanceColour = prompt("Please enter a colour", "#7FFFD4");
  328. if (attendanceColour && attendanceColour != "RAINBOW") {
  329. attendanceRainbow[2] = 0;
  330. attendanceEl.style.backgroundImage = "";
  331. attendanceEl.style.background = attendanceColour;
  332. } else if (attendanceColour === "RAINBOW") {
  333. attendanceRainbow[2] = 1;
  334. }
  335. });
  336. if(cardEl) {
  337. cardEl.addEventListener("click", function() {
  338. cardColour = prompt("Please enter a colour", "#7FFFD4");
  339. if (cardColour && cardColour != "RAINBOW") {
  340. cardRainbow[2] = 0;
  341. cardEl.style.backgroundColor = cardColour;
  342. } else if (cardColour === "RAINBOW") {
  343. cardRainbow[2] = 1;
  344. }
  345. });
  346. }
  347. if(document.querySelector(".diaryWeek")) {
  348. document.querySelector(".diaryWeek").addEventListener("click", function() {
  349. alert("rgb(" + attendanceRainbow[0] + "," + (400 - attendanceRainbow[0] + attendanceRainbow[1]) / 2.5 + "," + (400 - attendanceRainbow[1]) + ")");
  350. });
  351. }
  352. if(document.querySelector(".diaryDay")) {
  353. switch(Date().substr(4, 3)) {
  354. case "Jan":
  355. date = Date().substr(11, 4) + "-01-" + Date().substr(8, 2);
  356. break;
  357. case "Feb":
  358. date = Date().substr(11, 4) + "-02-" + Date().substr(8, 2);
  359. break;
  360. case "Mar":
  361. date = Date().substr(11, 4) + "-03-" + Date().substr(8, 2);
  362. break;
  363. case "Apr":
  364. date = Date().substr(11, 4) + "-04-" + Date().substr(8, 2);
  365. break;
  366. case "May":
  367. date = Date().substr(11, 4) + "-05-" + Date().substr(8, 2);
  368. break;
  369. case "Jun":
  370. date = Date().substr(11, 4) + "-06-" + Date().substr(8, 2);
  371. break;
  372. case "Jul":
  373. date = Date().substr(11, 4) + "-07-" + Date().substr(8, 2);
  374. break;
  375. case "Aug":
  376. date = Date().substr(11, 4) + "-08-" + Date().substr(8, 2);
  377. break;
  378. case "Sep":
  379. date = Date().substr(11, 4) + "-09-" + Date().substr(8, 2);
  380. break;
  381. case "Oct":
  382. date = Date().substr(11, 4) + "-10-" + Date().substr(8, 2);
  383. break;
  384. case "Nov":
  385. date = Date().substr(11, 4) + "-11-" + Date().substr(8, 2);
  386. break;
  387. case "Dec":
  388. date = Date().substr(11, 4) + "-12-" + Date().substr(8, 2);
  389. break;
  390. }
  391. var time = Number(Date().substr(16, 2) + Date().substr(19, 2));
  392. var lessonEls = [document.querySelector(".diaryDay[data-date='"+date+"']").nextSibling, document.querySelector(".diaryDay[data-date='"+date+"']").parentNode.childNodes[1], document.querySelector(".diaryDay[data-date='"+date+"']").parentNode.childNodes[2], document.querySelector(".diaryDay[data-date='"+date+"']").parentNode.childNodes[3], document.querySelector(".diaryDay[data-date='"+date+"']").parentNode.childNodes[4], document.querySelector(".diaryDay[data-date='"+date+"']").parentNode.childNodes[5]];
  393. var lessonEl;
  394.  
  395. i = 0;
  396. while (!lessonEl && i < 10) {
  397. if (lessonEls[i]) {
  398. if (timeOfDiaryEl(lessonEls[i])[0] < time && timeOfDiaryEl(lessonEls[i])[1] >= time) {
  399. lessonEl = lessonEls[i];
  400. }
  401. }
  402. i ++;
  403. }
  404. var evilEl;
  405. for(var i = 0; i < document.querySelectorAll(".L").length; i++) {
  406. let evils = ["ELZ", "ENG", "LLS", "LLH"];
  407. let something = document.querySelectorAll(".L")[i];
  408. if(evils.indexOf(something.childNodes[1].childNodes[0].innerText.substr(0, 3))) {
  409. something.classList.add("evil");
  410. }
  411. }
  412. if(lessonEl != undefined) {
  413. lessonEl.style.transformOrigin = "50% 50%";
  414. lessonEl.style.borderRadius = "5px";
  415. lessonEl.innerHTML += "<style>@keyframes lessonAnimation {from, to {} 50% {}} .lessonEl {animation: lessonAnimation 15s infinite;}</style>";
  416. lessonEl.classList.add("lessonEl");
  417. document.querySelector(".lessonEl .t").addEventListener("click", function() {
  418. lessonEl.style.borderRadius = prompt("Enter the radius", "5px");
  419. });
  420. }
  421. if(document.querySelector(".evil")) {
  422. document.querySelector(".evil .t").addEventListener("click", function() {
  423. if(confirm("Are you sure you would like to enable evil mode? You will need to refresh the page to revert this.")) {
  424. document.querySelector("daymap-menu div").style.backgroundColor = "rgb(85, 2, 2)";
  425. document.querySelector(".menu-list li").style.backgroundColor = "rgb(85, 2, 2)";
  426. document.querySelector(".logo-img").remove();
  427. document.querySelector("daymap-menu div").style.borderBottom = "rgb(0, 0, 0)";
  428. document.querySelector("#bodyUnderlay").style.backgroundColor = "rgb(85, 10, 10)";
  429. {
  430. let something = document.createElement("div");
  431. something.setAttribute("class", "bodyOverlay");
  432. something.setAttribute("style", "background-color:rgba(113,13,13,0.5);width:100vw; height: 100vh; position:fixed;");
  433. document.querySelector(".main-layout").appendChild(something);
  434. document.querySelector("head").innerHTML += "<style>.bodyOverlay {background-color:rgba(113,13,13,0.5);width:100vw; height: 100vh; position:fixed;}</style>";
  435. }
  436. document.querySelector(".Toolbar").style.background = "rgb(100, 20, 20)";
  437. for (i = 0; i < document.querySelectorAll(".grid div").length; i++) {
  438. document.querySelectorAll(".grid div")[i].style.backgroundColor = "rgb(100, 20, 40)";
  439. };
  440. for (i = 0; i < document.querySelectorAll(".msgHead .icon").length; i++) {
  441. document.querySelectorAll(".msgHead icon")[i].innerText("Mua ha ha ha!");
  442. };
  443. for (i = 0; i < document.querySelectorAll(".msgHead .icon").length; i++) {
  444. document.querySelectorAll(".msgHead icon")[i].nextSibling.nextSibling.innerText("Always.");
  445. };
  446. for (i = 0; i < document.querySelectorAll(".msg table tbody tr:nth-child(2) td").length; i++) {
  447. document.querySelectorAll(".msg table tbody tr:nth-child(2) td")[i].innerText("Daymap bows down to my power.");
  448. };
  449. }
  450. });
  451. }
  452. document.querySelector(".MasterContent table tbody tr td .Header").addEventListener("click", function() {
  453. bodyColour = prompt("Please enter a background", "#ABCDEF");
  454. if (bodyColour && bodyColour != "RAINBOW") {
  455. bodyRainbow[2] = 0;
  456. document.querySelector("#bodyUnderlay").style.background = bodyColour;
  457. } else if (bodyColour === "RAINBOW") {
  458. bodyRainbow[2] = 1;
  459. }
  460. });
  461. }
  462. if(getItem("autoBodyRainbow") && getItem("autoBodyRainbow")) {
  463. setTimeout(bodyRainbow[2]=1,1)
  464. }
  465. if(getItem("autoCardRainbow")) {
  466. setTimeout(cardRainbow[2]=1,1)
  467. }
  468. if(getItem("translucentMode") && getItem("translucentMode") < 1) {
  469. let dark = document.cookie.substr(document.cookie.length - 1, document.cookie.length);
  470. for(i = 0; i < document.querySelectorAll(".card, .msg, .ditm, .Toolbar").length; i ++) {
  471. document.querySelectorAll(".card, .msg, .ditm, .Toolbar")[i].style.background = "rgba(" + (dark ? "37, 37, 37," : "237, 235, 233,") + getItem("translucentMode") + ")";
  472. }
  473. for(i = 0; i < document.querySelectorAll(".item-container").length; i ++) {
  474. document.querySelectorAll(".item-container")[i].style.background = "rgba(255, 255, 255, 0)";
  475. }
  476. for(i = 0; i < document.querySelectorAll(".hasDatepicker").length; i ++) {
  477. document.querySelectorAll(".hasDatepicker")[i].style.backgroundColor = "rgba(" + (dark ? "37, 37, 37," : "237, 235, 233,") + getItem("translucentMode") * 0.7 + ")";
  478. }
  479. for(i = 0; i < document.querySelectorAll(".ditm, .Toolbar").length; i ++) {
  480. document.querySelectorAll(".ditm, .Toolbar")[i].style.outline = "3px solid rgba(250, 250, 250, " + getItem("translucentMode") * 0.45 + ")";
  481. }
  482. for(i = 0; i < document.querySelectorAll(".msg").length; i ++) {
  483. document.querySelector(".msg").style.border = "3px solid rgba(220, 220, 220, " + getItem("translucentMode") * 0.45 + ")";
  484. }
  485. if(document.querySelector("#bCalendar")) {
  486. document.querySelector("#bCalendar").style.backgroundColor = "rgba(31, 157, 217, " + getItem("translucentMode") * 1.6 + ")";
  487. document.querySelector("#btnDiary").style.backgroundColor = "rgba(31, 157, 217, " + getItem("translucentMode") * 1.6 + ")";
  488. }
  489.  
  490. for(i = 0; i < document.querySelectorAll(".card, .msg, .ditm, .Toolbar, .ditm .t, .ditm .c, .hasDatepicker, #tblTt tbody tr td, #tblTt tbody tr td .ttCell, .msg, #bCalendar, #btnDiary").length; i ++) {
  491. document.querySelectorAll(".card, .msg, .ditm, .Toolbar, .ditm .t, .ditm .c, .hasDatepicker, #tblTt tbody tr td, #tblTt tbody tr td .ttCell, .msg, #bCalendar, #btnDiary")[i].style.backdropFilter = "blur(" + getItem("blurAmount") + "px)";
  492. }
  493. window.setTimeout(function() {
  494. document.querySelector(".logo-img").style.marginTop = "-1.5px";
  495. document.querySelector(".logo-img").style.marginLeft = "43px";
  496. document.querySelector(".logo-img").style.width = "122px";
  497. }, 510);
  498. window.setTimeout(function() {
  499. document.querySelector("daymap-header").style.backgroundColor = "rgba(255, 255, 255, " + getItem("translucentMode") * 1.2 + ")";
  500. document.querySelector("daymap-header").style.backdropFilter = "blur(" + getItem("blurAmount") * 3 + "px)";
  501. for(i = 0; document.querySelector("daymap-header div ul li"); i++) {
  502. document.querySelectorAll("daymap-header div ul li")[i].style.backgroundColor = "rgba(255, 255, 255, " + getItem("translucentMode") * 0.8 + ")";
  503. }
  504. document.querySelector(".logo-img").setAttribute("src", "https://portal-beta.daymap.net/daymapidentity/logo.png");
  505. }, 500);
  506. }
  507. document.querySelector("#customStyles").innerHTML = getItem("additionalCSS");
  508. window.setInterval(function() {
  509. let length = document.querySelectorAll(".fa-mail-bulk").length;
  510. for(i = 0; i < length; i++) {
  511. document.querySelector(".fa-mail-bulk").outerHTML = "<img src='https://qasmt.eq.daymap.net/Daymap/images/coms/post32.png'/>";
  512. }
  513. length = document.querySelectorAll(".img-container .fa-comment-alt").length;
  514. for(i = 0; i < length; i++) {
  515. document.querySelector(".img-container .fa-comment-alt").outerHTML = "<img src='https://qasmt.eq.daymap.net/Daymap/images/coms/newmsg.png'/>";
  516. }
  517. length = document.querySelectorAll(".fa-comment-alt-dots").length;
  518. for(i = 0; i < length; i++) {
  519. document.querySelector(".fa-comment-alt-dots").outerHTML = "<img src='https://qasmt.eq.daymap.net/Daymap/images/coms/newmsg.png'/>";
  520. }
  521. length = document.querySelectorAll(".fa-paperclip").length;
  522. for(i = 0; i < length; i++) {
  523. document.querySelector(".fa-paperclip").outerHTML = "<img src='https://qasmt.eq.daymap.net/Daymap/images/buttons/attachment.gif'/>";
  524. }
  525. for(i = 0; i < document.querySelectorAll(".msg"); i ++) {
  526. document.querySelectorAll(".msg")[i].style.backdropFilter = "blur(" + getItem("blurAmount") + "px)";
  527. }
  528. for(i = 0; i < document.querySelectorAll(".msg").length; i ++) {
  529. document.querySelectorAll(".msg")[i].style.background = "rgba(255, 255, 255, " + getItem("translucentMode") + ")";
  530. }
  531. }, 1000);
  532. } catch (error) {
  533. alert("An error has occured with the script. Please contact apate98.\n" + error)
  534. }
  535. })();
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.