diff --git a/js/background.js b/js/background.js index 163dd79..cbc97d2 100644 --- a/js/background.js +++ b/js/background.js @@ -40,7 +40,7 @@ chrome.runtime.onInstalled.addListener(function () { "better_todo": false, "todo_hr24": false, "todo_separate_scrollbar": false, - "better_sidebar": true, + "better_sidebar": false, "condensed_cards": false, "custom_cards": {}, "custom_cards_2": {}, @@ -77,7 +77,7 @@ chrome.runtime.onInstalled.addListener(function () { "assignment_states": {}, "tab_icons": false, "todo_hide_feedback": false, - "todo_full_height": false, + "todo_full_height": true, "device_dark": false, "cumulative_gpa": { "name": "Cumulative GPA", "hidden": false, "weight": "dnc", "credits": 999, "gr": 3.21 }, // "show_updates": false, diff --git a/js/content.js b/js/content.js index 19b1048..9ad9f00 100644 --- a/js/content.js +++ b/js/content.js @@ -1354,81 +1354,8 @@ function setupBetterSidebar(mode = "dash") { let sidebarContent = makeElement("div", sidebarList, { style: "display:flex;flex-direction:column;gap:20px;width:100%;flex:1;justify-content:flex-start;align-items:center;margin:40px;" }); - // sidebar contents - createSidebarButton("Dashboard", domain + "/", sidebarContent, - ` - - - - - - - - - `, - ); - createSidebarButton( - "Courses", - domain + "/courses", - sidebarContent, - ` - - - - - - - `, - ); - createSidebarButton( - "Groups", - domain + "/groups", - sidebarContent, - ` - - - - - - `, - ); - createSidebarButton( - "Calendar", - domain + "/calendar", - sidebarContent, - ` - - - - - - `, - ); - createSidebarButton( - "Inbox", - domain + "/conversations", - sidebarContent, - ` - - - - - - `, - ); - createSidebarButton( - "Studio", - domain + - "accounts/1/external_tools/69?launch_type=global_navigation", - sidebarContent, - ` - - - - - - `, - ); + // Populate sidebar from Canvas navigation menu dynamically + populateSidebarFromNav(sidebarContent); if (mode == "course") { makeElement("h1", sidebarContent, { @@ -1485,6 +1412,45 @@ function createSidebarButton(text, url, parent, icon) { }); button.innerHTML = `${icon ? `${icon}${text}` : `${text}`}`; } +function populateSidebarFromNav(sidebarContent) { + const excludeIds = ["global_nav_help_link", "global_nav_history_link"]; + const customIcons = { + "global_nav_profile_link": ``, + "global_nav_dashboard_link": ``, + "global_nav_conversations_link": ``, + "global_nav_calendar_link": ``, + "global_nav_courses_link": ``, + "global_nav_groups_link": ``, + "globalNavExternalTool-69": ``, + }; + + const navMenu = document.getElementById("menu"); + if (!navMenu) return; + + const menuItems = navMenu.querySelectorAll(".menu-item a[id^='global_nav'], .globalNavExternalTool a"); + menuItems.forEach(item => { + const itemId = item.id || item.closest(".menu-item")?.id; + if (excludeIds.includes(itemId)) return; + + const href = item.getAttribute("href"); + const textEl = item.querySelector(".menu-item__text"); + const text = textEl?.textContent?.trim(); + + if (!text || !href) return; + + let icon = customIcons[itemId] || ""; + if (!icon) { + const svg = item.querySelector("svg"); + if (svg) { + icon = svg.outerHTML; + // Make SVG white by adding style + icon = icon.replace(" { + if (options.tab_icons || options.better_todo || options.better_sidebar) { + return getData(`${domain}/api/v1/users/self/colors`).then(data => { let cards = options.custom_cards_3; Object.keys(cards).forEach(key => { cards[key] = { ...cards[key], "color": data["custom_colors"]["course_" + key] ? data["custom_colors"]["course_" + key] : null }; }); chrome.storage.sync.set({ "custom_cards_3": cards }); + return cards; }); } } @@ -2851,7 +2824,7 @@ function getAssignments() { } function getApiData() { - if (current_page === "/" || current_page === "") { + if (current_page === "/" || current_page === "" || options.better_todo || options.better_sidebar) { getAssignments(); getGrades(); getColors(); diff --git a/js/popup.js b/js/popup.js index c12a31e..d84f93f 100644 --- a/js/popup.js +++ b/js/popup.js @@ -69,7 +69,7 @@ const defaultOptions = { "dashboard_notes": false, "dashboard_notes_text": "", "better_todo": false, - "better_sidebar": true, + "better_sidebar": false, "todo_hr24": false, "todo_separate_scrollbar": false, "condensed_cards": false,