From 59b7523d48b32e0fa0fc81fe2471c55fc25e08bc Mon Sep 17 00:00:00 2001 From: Guy Sandler Date: Tue, 19 May 2026 22:19:08 -0700 Subject: [PATCH] progress --- js/content.js | 92 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 16 deletions(-) diff --git a/js/content.js b/js/content.js index 9ad9f00..b07db56 100644 --- a/js/content.js +++ b/js/content.js @@ -1339,12 +1339,15 @@ function setupBetterSidebar(mode = "dash") { else if (mode == "course") { document.getElementById("header").style.display = "none"; document.querySelector(".ic-Layout-wrapper")?.style.setProperty("margin-left", "0"); + document.querySelector("#main")?.style.setProperty("margin-left", "0"); // document.getElementById("not_right_side").style.display = "flex"; mainWrapper.style.display = "flex"; document.querySelector(".ic-Layout-contentMain").style.flex = "1"; document.querySelector(".ic-Layout-contentMain").style.minWidth = "0"; courseLinks = getCourseLinks(); document.querySelector(".ic-app-nav-toggle-and-crumbs").style.display = "none"; + const leftSide = document.getElementById("left-side"); + if (leftSide) leftSide.style.display = "none"; expanded = true; } @@ -1358,26 +1361,34 @@ function setupBetterSidebar(mode = "dash") { populateSidebarFromNav(sidebarContent); if (mode == "course") { - makeElement("h1", sidebarContent, { - textContent: "Course Links:", - style: "font-size: 20px;color:var(--bctext-0);margin-top:5px;margin-bottom:5px;" - }) - courseLinks.forEach((link) => { + const courseLinksContainer = makeElement("div", sidebarContent, { + id: "better-course-links", + style: "display:flex;flex-direction:column;gap:15px;width:100%;align-items:center;min-height:auto;padding:10px 0;border-top:1px solid var(--bcborder-0);" + }); + + if (courseLinks && courseLinks.length > 0) { + makeElement("h1", courseLinksContainer, { + id: "better-course-links-title", + textContent: "Course Links:", + style: "font-size:12px;color:var(--bctext-0);margin:0;font-weight:bold;white-space:nowrap;text-align:center;display:block;" + }) + courseLinks.forEach((link) => { createSidebarButton( link.name, domain + link.url, - sidebarContent, - ` + courseLinksContainer, + ` - - - + + + ` ); }); + } } @@ -1427,14 +1438,21 @@ function populateSidebarFromNav(sidebarContent) { const navMenu = document.getElementById("menu"); if (!navMenu) return; - const menuItems = navMenu.querySelectorAll(".menu-item a[id^='global_nav'], .globalNavExternalTool a"); + const menuItems = navMenu.querySelectorAll("a[id^='global_nav'], .globalNavExternalTool a"); menuItems.forEach(item => { - const itemId = item.id || item.closest(".menu-item")?.id; + const itemId = item.id; if (excludeIds.includes(itemId)) return; const href = item.getAttribute("href"); - const textEl = item.querySelector(".menu-item__text"); - const text = textEl?.textContent?.trim(); + let textEl = item.querySelector(".menu-item__text"); + let text = textEl?.textContent?.trim(); + + // If text not found, try other sources + if (!text) { + text = item.getAttribute("aria-label")?.trim() || + item.getAttribute("title")?.trim() || + item.textContent?.trim(); + } if (!text || !href) return; @@ -1443,8 +1461,39 @@ function populateSidebarFromNav(sidebarContent) { const svg = item.querySelector("svg"); if (svg) { icon = svg.outerHTML; - // Make SVG white by adding style - icon = icon.replace(" 32 || height > 32) { + // Check if svg already has a style attribute + if (icon.includes('style="')) { + // Append to existing style + icon = icon.replace(/style="([^"]*)"/, `style="$1 width:20px;height:20px;flex-shrink:0;fill:white;stroke:white;"`); + } else { + // Add new style attribute + icon = icon.replace(" label.style.display = expanded ? "block" : "none"); const buttons = document.querySelectorAll(".better-sidebar-btn"); buttons.forEach(label => label.style.width = expanded ? "80%" : "40%"); + const courseLinksTitle = document.getElementById("better-course-links-title"); + if (courseLinksTitle) { + courseLinksTitle.style.display = expanded ? "block" : "none"; + const container = document.getElementById("better-course-links"); + if (container) { + container.style.borderTop = expanded ? "1px solid var(--bcborder-0)" : "none"; + container.style.paddingTop = expanded ? "10px" : "5px"; + container.style.paddingBottom = expanded ? "0" : "5px"; + } + } } function getCourseLinks() { const linkList = document.getElementById("section-tabs"); + if (!linkList) return []; const links = linkList.querySelectorAll("a"); const courseLinks = []; links.forEach(link => {