diff --git a/README.md b/README.md index ef06193..2e2d98a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Betterer Canvas -name idea: even better canvas +name idea: even better canvas or Actually Better Canvas (ABC) I don't like the direction bettercanvas (bettercampus) is heading so I forked it @@ -12,9 +12,9 @@ Enhancements to Canvas AND bettercanvas like dark mode, better todo list, GPA ca ### Supported on - + - + ## Inquiries @@ -58,7 +58,7 @@ Better Canvas introduces improvements to the Canvas user interface: - GPA presets - Scheduled Reminder Popups (broken) - searching themes (the original didn't actually impliment that) -- Card Styles (image size, card roundness, card spacing, width, height) +- Card Styles (image size, card roundness, card spacing, width, height, theme compatible) ## Planned Features - custom backgrounds @@ -79,11 +79,17 @@ Better Canvas introduces improvements to the Canvas user interface: - hover assignment preview - better what if grade - when opening assignments it will show you "if you get a 0 on this your grade will be _" +- grade leaderboard per class (opt in) +- global search +- module sorting +- quick modules button ## Extra features that might be added: - card grade position, card outline - theme copy button - revamp cards page UI +- streaks +- caching pages for faster loading ## Dev Installation diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 9fe4f32..9ed9ac3 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -42,7 +42,7 @@ "message": "Cards" }, "custom_font": { - "message": "Fonts" + "message": "Styles" }, "useddmm": { "message": "Use dd/mm" diff --git a/css/popup.css b/css/popup.css index 4a23f65..72ad760 100644 --- a/css/popup.css +++ b/css/popup.css @@ -188,6 +188,14 @@ input[type="checkbox"]:checked {background: #8dd28d;} .submitted-theme-tag {border-radius: 4px;padding: 3px 4px;max-width:min-content;font-weight: 600;} #custom-styles {min-height: 100px;} +.card-file-input {background: #2a2a2a;border: 1px solid #4a4a4a;border-radius: 4px;color: #fff;padding: 8px 12px;font-size: 14px;font-family: inherit;margin-top: 8px;transition: border-color 0.2s ease;} +.card-file-input:hover {border-color: #6a6a6a;} +.card-file-input:focus {outline: none;border-color: #007acc;box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);} +.card-file-input::file-selector-button {background: #404040;border: 1px solid #5a5a5a;border-radius: 3px;color: #fff;padding: 6px 12px;margin-right: 12px;font-size: 13px;cursor: pointer;transition: background-color 0.2s ease;} +.card-file-input::file-selector-button:hover {background: #4a4a4a;} +.card-file-input::-webkit-file-upload-button {background: #404040;border: 1px solid #5a5a5a;border-radius: 3px;color: #fff;padding: 6px 12px;margin-right: 12px;font-size: 13px;cursor: pointer;transition: background-color 0.2s ease;} +.card-file-input::-webkit-file-upload-button:hover {background: #4a4a4a;} + ::-webkit-scrollbar {width: 8px;} ::-webkit-scrollbar-track {background: #161616;} ::-webkit-scrollbar-thumb {background: #323232;border-radius:2px;} diff --git a/html/popup.html b/html/popup.html index 87c2995..f9654d0 100644 --- a/html/popup.html +++ b/html/popup.html @@ -43,8 +43,8 @@ Themes - - Custom Font + + Styles @@ -750,9 +750,10 @@ + - Custom Font + Styles Back @@ -769,6 +770,14 @@ You can use a custom font from Google fonts here. Make sure to enter only the bold part after "?family=" + + Custom Background + Use an image url or upload an image file + + + Clear Background + + diff --git a/js/background.js b/js/background.js index cdd64d7..326393c 100644 --- a/js/background.js +++ b/js/background.js @@ -99,6 +99,8 @@ chrome.runtime.onInstalled.addListener(function () { "cardWidth": 262, "cardHeight": 250, "customCardStyles": false, + "customBackgroundLink": "", + "customBackgroundUpload": "", } }; diff --git a/js/content.js b/js/content.js index 8aaff90..7667b52 100644 --- a/js/content.js +++ b/js/content.js @@ -260,6 +260,7 @@ function startExtension() { applyAestheticChanges(); changeFavicon(); updateReminders(); + applyCustomBackground(); //getClassAverages(); setTimeout(() => runDarkModeFixer(false), 800); setTimeout(() => runDarkModeFixer(false), 4500); @@ -373,10 +374,31 @@ function applyOptionsChanges(changes) { case ("customCardStyles"): applyAestheticChanges(); break; + case ("customBackgroundLink"): + case ("customBackgroundUpload"): + applyCustomBackground(); + break; } }); } +function applyCustomBackground() { + // let style = document.querySelector("#DashboardCard_Container") + let style = document.querySelector("#bettercanvas-background") || document.createElement('style'); + style.id = "bettercanvas-background"; + + if (options.customBackgroundUpload && options.customBackgroundUpload !== "") { + style.textContent = `#not_right_side { background-image: url('${options.customBackgroundUpload}') !important; background-size: cover !important; background-attachment: fixed !important; }`; + } else if (options.customBackgroundLink && options.customBackgroundLink !== "") { + style.textContent = `#not_right_side { background-image: url('${options.customBackgroundLink}') !important; background-size: cover !important; background-attachment: fixed !important; } + .ic-Dashboard-header__layout { background: none !important; }`; // try to make this hide things underneath and add to other side + } else { + style.textContent = ""; + } + + document.documentElement.appendChild(style); +} + let insertTimer; function resetTimer() { clearTimeout(insertTimer); diff --git a/js/popup.js b/js/popup.js index 290b22f..260b073 100644 --- a/js/popup.js +++ b/js/popup.js @@ -117,6 +117,8 @@ const defaultOptions = { "cardWidth": 262, "cardHeight": 250, "customCardStyles": false, + "customBackgroundLink": "", + "customBackgroundUpload": "", } }; @@ -264,6 +266,34 @@ function setupCardHeightInput(initial) { }); } +function setupCustomBackgroundLink(initial) { + let el = document.querySelector("#customBackgroundLink"); + el.value = initial || ""; + el.addEventListener("input", (e) => { + chrome.storage.sync.set({ "customBackgroundLink": e.target.value }); + }) +} + +function setupCustomBackgroundUpload(initial) { + let el = document.querySelector("#customBackgroundUpload"); + el.addEventListener("change", handleBackgroundUpload); +} +function handleBackgroundUpload(e) { + const file = e.target.files[0]; + if (file) { + const reader = new FileReader(); + reader.onload = function(event) { + const base64 = event.target.result; + chrome.storage.sync.set({ + "customBackgroundUpload": base64, + "customBackgroundLink": "" + }); + document.querySelector("#customBackgroundLink").value = "Using uploaded file"; + } + reader.readAsDataURL(file); + } +} + function setup() { const menu = { @@ -293,6 +323,8 @@ function setup() { { "identifier": "cardSpacing", "setup": (initial) => setupCardSpacingInput(initial) }, { "identifier": "cardWidth", "setup": (initial) => setupCardWidthInput(initial) }, { "identifier": "cardHeight", "setup": (initial) => setupCardHeightInput(initial) }, + { "identifier": "customBackgroundLink", "setup": (initial) => setupCustomBackgroundLink(initial)}, + { "identifier": "customBackgroundUpload", "setup": (initial) => setupCustomBackgroundUpload(initial)}, ], } @@ -728,6 +760,15 @@ function setup() { chrome.storage.sync.set({ "cardHeight": value }); document.querySelector("#cardHeightValue").textContent = value + "%"; }); + + document.getElementById("clearCustomBackground").addEventListener("click", () => { + chrome.storage.sync.set({ + "customBackgroundLink": "", + "customBackgroundUpload": "" + }); + document.querySelector("#customBackgroundLink").value = ""; + document.querySelector("#customBackgroundUpload").value = ""; + }); } function applyGPAPreset(bounds) {
You can use a custom font from Google fonts here. Make sure to enter only the bold part after "?family="
Use an image url or upload an image file