Grade Randomizer

grade good ads gone 😉

  1. // ==UserScript==
  2. // @name Grade Randomizer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description grade good ads gone 😉
  6. // @author M1noa
  7. // @match *://campus.ccsd.net/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to generate a random percentage between 71.62 and 100.00
  16. function getRandomPercent() {
  17. const min = 71.62;
  18. const max = 100.00;
  19. return (Math.random() * (max - min) + min).toFixed(2); // Limit to 2 decimal places
  20. }
  21.  
  22. // Function to determine the letter grade based on the percent
  23. function getLetterGrade(percent) {
  24. if (percent >= 90) return 'A';
  25. if (percent >= 80) return 'B';
  26. if (percent >= 70) return 'C';
  27. if (percent >= 60) return 'D';
  28. return 'F';
  29. }
  30.  
  31. // Function to modify the text within the grading-score divs
  32. function modifyGrades() {
  33. const gradeDivs = document.querySelectorAll('.grading-score');
  34.  
  35. gradeDivs.forEach(gradeDiv => {
  36. const percentDiv = gradeDiv.querySelector('.grading-score__row-spacing b');
  37. const letterDiv = gradeDiv.querySelector('b:first-child');
  38.  
  39. if (percentDiv && letterDiv) {
  40. // Extract the percentage from the text like "(67.08%)"
  41. const percentMatch = percentDiv.innerText.match(/\((\d+\.?\d*)%\)/);
  42. if (percentMatch && percentMatch[1]) {
  43. const originalPercent = parseFloat(percentMatch[1]);
  44.  
  45. // Generate a new random percentage
  46. const newPercent = getRandomPercent();
  47.  
  48. // Get the corresponding letter grade
  49. const newLetterGrade = getLetterGrade(newPercent);
  50.  
  51. // Update the div with the new values
  52. percentDiv.innerText = `(${newPercent}%)`;
  53. letterDiv.innerText = newLetterGrade;
  54. }
  55. }
  56. });
  57. }
  58.  
  59. // Function to remove all divs with the class 'ng-star-inserted'
  60. function removeNgStarInsertedDivs() {
  61. const ngStarDivs = document.querySelectorAll('.router-link-reset');
  62. ngStarDivs.forEach(div => div.remove());
  63. }
  64.  
  65. // Function to clear the page if URL contains 'classroom/grades'
  66. function clearPageOnSpecificURLs() {
  67. if (window.location.href.includes('classroom/grades')) {
  68. document.body.innerHTML = '';
  69. }
  70. }
  71.  
  72. // Observe changes to the DOM and modify grades accordingly
  73. const observer = new MutationObserver(() => {
  74. modifyGrades();
  75. removeNgStarInsertedDivs();
  76. });
  77. observer.observe(document.body, { childList: true, subtree: true });
  78.  
  79. // Initial run to modify grades and clean up on page load
  80. modifyGrades();
  81. removeNgStarInsertedDivs();
  82. clearPageOnSpecificURLs();
  83.  
  84. // Listen for URL changes (in case of SPA navigation)
  85. window.addEventListener('popstate', clearPageOnSpecificURLs);
  86. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址