diff --git a/html/popup.html b/html/popup.html index 7cf9139..6c53823 100644 --- a/html/popup.html +++ b/html/popup.html @@ -760,7 +760,7 @@

Card method

This is an experimental feature. You shouldn't need these on.

- + Date
diff --git a/js/content.js b/js/content.js index cfb9110..2075f99 100644 --- a/js/content.js +++ b/js/content.js @@ -365,16 +365,13 @@ function getCardsFromDashboard() { dashboard_cards.forEach(card => { const id = card.querySelector(".ic-DashboardCard__link").href.split("courses/")[1]; if (count >= (options["card_limit"] || 25)) return; + if (!cards || !cards[id]) { console.log("adding to custom_cards"); newCards = true; - cards[id] = { "default": card.querySelector(".ic-DashboardCard__header-subtitle").textContent.substring(0, 20), "name": "", "code": "", "img": "", "hidden": false, "weight": "regular", "credits": 1, "eid": options["card_limit"] - count, "gr": null }; - } /*else if (cards && cards[id]) { - newCards = true; - if (!cards[id].default) cards[id].default = card.querySelector(".ic-DashboardCard__header-subtitle").textContent.substring(0, 20); - if (!cards[id].eid) cards[id].eid = options["card_limit"] - count; - if (!cards[id].code) cards[id].code = ""; - } */ + cards[id] = { "default": card.querySelector(".ic-DashboardCard__header-subtitle").textContent.substring(0, 20), "name": "", "code": "", "img": "", "hidden": false, "weight": "regular", "credits": 1, "eid": 100000 - count, "gr": null }; + } + if (!cards_2 || !cards_2[id]) { console.log("adding to custom_cards_2"); newCards = true; @@ -1426,7 +1423,7 @@ function getCardId(card) { // has ~ but dashboard card method is used if (options["custom_cards"][id]) return id; - + // weird case, some canvases replace consecutive 0s with a ~ in the id // but the number of 0s isn't consistent between schools id = id.split("~"); diff --git a/js/popup.js b/js/popup.js index 8f17fc8..b66a049 100644 --- a/js/popup.js +++ b/js/popup.js @@ -169,11 +169,19 @@ function setupCardLimitSlider(initial) { }) } +function setupDashboardMethod(initial) { + let el = document.querySelector("#card_method_dashboard"); + el.checked = initial; + el.addEventListener("change", (e) => { + chrome.storage.sync.set({ "custom_cards": {}, "custom_cards_2": {}, "custom_cards_3": {}, "card_method_dashboard": e.target.checked }); + }); +} + function setup() { const menu = { "switches": syncedSwitches, - "checkboxes": ['card_method_dashboard', 'card_method_date', 'show_updates', 'todo_colors', 'device_dark', 'relative_dues', 'card_overdues', 'todo_overdues', 'gpa_calc_prepend', 'auto_dark', 'assignment_date_format', 'todo_hr24', 'grade_hover', 'hide_completed', 'hover_preview'], + "checkboxes": ['card_method_date', 'show_updates', 'todo_colors', 'device_dark', 'relative_dues', 'card_overdues', 'todo_overdues', 'gpa_calc_prepend', 'auto_dark', 'assignment_date_format', 'todo_hr24', 'grade_hover', 'hide_completed', 'hover_preview'], "tabs": { "advanced-settings": { "setup": displayAdvancedCards, "tab": ".advanced" }, "gpa-bounds-btn": { "setup": displayGPABounds, "tab": ".gpa-bounds-container" }, @@ -189,7 +197,9 @@ function setup() { { "identifier": "auto_dark_end", "setup": (initial) => setupAutoDarkInput(initial, "auto_dark_end") }, { "identifier": "num_assignments", "setup": (initial) => setupAssignmentsSlider(initial) }, { "identifier": "num_todo_items", "setup": (initial) => setupTodoSlider(initial) }, - { "identifier": "card_limit", "setup": (initial) => setupCardLimitSlider(initial) }], + { "identifier": "card_limit", "setup": (initial) => setupCardLimitSlider(initial) }, + { "identifier": "card_method_dashboard", "setup": (initial) => setupDashboardMethod(initial) } + ], } chrome.storage.sync.get(menu.switches, sync => { diff --git a/manifest.json b/manifest.json index 42d54d1..8ade2d9 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Better Canvas", "description": "Feature packed extension for Canvas.", - "version": "5.11.2", + "version": "5.11.3", "icons": { "16": "icon/icon-16.png", "32": "icon/icon-32.png",