您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Colorize the Duke University academic calendar for quicker review. Breaks are red, FDOC/LDOC is green, registration is blue.
// ==UserScript== // @name Duke academic calendar highlighting // @namespace http://duke.edu/ // @version 0.1 // @description Colorize the Duke University academic calendar for quicker review. Breaks are red, FDOC/LDOC is green, registration is blue. // @author Tyler Bletsch ([email protected]) // @match https://registrar.duke.edu/*calendar* // @icon https://www.google.com/s2/favicons?sz=64&domain=duke.edu // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Strings-to-colors dictionary const STRINGS2COLORS = { 'break': '#FCC', 'resume': '#FCC', 'recess': '#FCC', 'no classes are held': '#FCC', 'holiday': '#FCC', 'semester begin': '#CFC', 'classes begin': '#CFC', 'classes end': '#CFC', 'carts open': '#CCF', 'registration begins': '#CCF', 'registration ends': '#CCF', 'drop/add begins': '#CCF', 'drop/add ends': '#CCF' }; // Function to find a color based on a string function getColorForString(str) { for (const keyword in STRINGS2COLORS) { if (str.toLowerCase().includes(keyword)) { return STRINGS2COLORS[keyword]; } } return null; // Return null if no matching color found } // Function to highlight cells function highlightCells() { const tables = document.querySelectorAll('table'); tables.forEach(table => { const cells = table.querySelectorAll('td, th'); cells.forEach(cell => { const color = getColorForString(cell.textContent); if (color) { cell.style.backgroundColor = color; } }); }); } // Run the highlighting on page load window.addEventListener('load', () => { highlightCells(); }); // Run the highlighting whenever the page content changes (e.g., AJAX updates) const observer = new MutationObserver(mutations => { highlightCells(); }); observer.observe(document.body, { childList: true, subtree: true, characterData: true }); })();