OnCampusTweaks

A couple tweaks for my school's website

当前为 2020-02-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name OnCampusTweaks
  3. // @namespace https://elderhs.myschoolapp.com
  4. // @version 0.8
  5. // @description A couple tweaks for my school's website
  6. // @author Zack Sargent
  7. // @match https://elderhs.myschoolapp.com/app/student
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // Runs when page is fully loaded
  12. // The website is set up in a way that window.onload triggers before the page is fully loaded.
  13. // Thus, we must check independently to see if the full page has loaded.
  14. var checkExist = setInterval(function() {
  15. if (document.readyState === 'ready' || document.readyState === 'complete') {
  16. changeToWeekView();
  17. hideCompletedTasks();
  18. clearInterval(checkExist);
  19. }
  20. }, 100); // check every 100ms
  21.  
  22. // Changes to week view
  23. function changeToWeekView() {
  24. // if the string "assignment-center" is in the url
  25. if (window.location.href.indexOf("assignment-center") > -1) {
  26. document.getElementById("week-view").click();
  27. console.log("OnCampusTweaks: Changed to week view");
  28. }
  29.  
  30. }
  31.  
  32. // hides completed tasks automatically in the assignment center
  33. function hideCompletedTasks() {
  34. if (window.location.href.indexOf("assignment-center") > -1) {
  35. document.getElementById("filter-status").click();
  36.  
  37. // Create a list of all of the button elements that appear when you filter by status
  38. var buttonElements = document.getElementsByClassName("pull-left btn btn-xs btn-approve status-button active");
  39. buttonElements[3].click(); // Hides Completed tasks
  40.  
  41. // We have to get the buttons again because clicking on them changes the class structure
  42. buttonElements = document.getElementsByClassName("pull-left btn btn-xs btn-approve status-button active");
  43. buttonElements[3].click(); // Hides Graded tasks
  44.  
  45. document.getElementById("btn-filter-apply").click();
  46.  
  47. console.log("OnCampusTweaks: Hid completed tasks");
  48. }
  49. }