From b7d17fd8eb20b2999db4b71321f24c92649efc8a Mon Sep 17 00:00:00 2001
From: TheThonos <84212123+TheThonos@users.noreply.github.com>
Date: Sat, 11 Mar 2023 15:05:08 -0500
Subject: [PATCH 01/11] Added dropdown menu for changing theme in settings
(#303)
---
js/preload.js | 44 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/js/preload.js b/js/preload.js
index c9de872..b11b289 100644
--- a/js/preload.js
+++ b/js/preload.js
@@ -417,6 +417,23 @@ function updateSettings(callback) {
return defaultGradingScale;
}
+ let themeOptions = [];
+
+ for (let theme of __defaultThemes) {
+ if(theme.name.includes('LAUSD') && storageContents.defaultDomain !== "lms.lausd.net") continue;
+ themeOptions.push({
+ text: theme.name,
+ value: theme.name
+ });
+ }
+
+ for (let theme of storageContents.themes) {
+ themeOptions.push({
+ text: theme.name,
+ value: theme.name
+ });
+ }
+
if (firstLoad) {
if (storageContents.themes) {
for (let t of storageContents.themes) {
@@ -433,15 +450,30 @@ function updateSettings(callback) {
modalContents = createElement("div", [], undefined, [
createElement("div", ["splus-modal-contents"], {}, [
new Setting(
- "theme",
- "Theme",
+ "themeEditor",
+ "Theme Editor",
"Click to open the theme editor to create, edit, or select a theme",
- "Schoology Plus",
+ "Theme Editor",
"button",
{},
- value => value || "Schoology Plus",
- event => location.href = chrome.runtime.getURL("/theme-editor.html"),
- element => element.value
+ value => "Theme Editor",
+ event => location.href = chrome.runtime.getURL("/theme-editor.html")
+ ).control,
+ new Setting(
+ "theme",
+ "Theme",
+ "[Reload required] Changes the theme of Schoology Plus",
+ "Schoology Plus",
+ "select",
+ {
+ options: themeOptions
+ },
+ value => value,
+ undefined,
+ element => {
+ chrome.storage.sync.set({"theme": element.value});
+ return element.value
+ }
).control,
new Setting(
"notifications",
From 3db8160063e7dae32ab9f2d94a8ef52d65aa654e Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Sat, 11 Mar 2023 14:44:35 -0800
Subject: [PATCH 02/11] Prevent LAUSD theme name conflicts
---
css/theme-editor.css | 4 ++++
js/all.js | 1 +
js/default-themes.js | 3 +++
js/home.js | 8 +++++---
js/preload.js | 44 +++++++++++++++++++-------------------------
js/theme-editor.js | 4 +---
theme-editor.html | 6 +++---
7 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/css/theme-editor.css b/css/theme-editor.css
index 7b1f9be..e682f1a 100644
--- a/css/theme-editor.css
+++ b/css/theme-editor.css
@@ -805,4 +805,8 @@ a[href].link-color {
#modern-wrapper .row .input-field.col.s12.m6 {
padding-top: 5px;
+}
+
+input::placeholder {
+ color: rgba(42, 42, 42, 0.5);
}
\ No newline at end of file
diff --git a/js/all.js b/js/all.js
index ebdcd58..a8bd1e7 100644
--- a/js/all.js
+++ b/js/all.js
@@ -286,6 +286,7 @@ let modals = [
{ name: "@jetline0", url: "https://github.com/jetline0" },
{ name: "@dsnsgithub", url: "https://github.com/dsnsgithub" },
{ name: "@senoj26", url: "https://github.com/senoj26" },
+ { name: "@TheThonos", url: "https://github.com/TheThonos" },
])
}),
]),
diff --git a/js/default-themes.js b/js/default-themes.js
index c35c64b..f08945d 100644
--- a/js/default-themes.js
+++ b/js/default-themes.js
@@ -6,6 +6,9 @@
await loadDependencies("default-themes", []);
})();
+const LAUSD_THEMES = ["LAUSD Orange", "LAUSD Dark Blue", "LAUSD 2019"];
+const CLASSIC_THEMES = ["Schoology Plus", "Rainbow"]
+
let __defaultThemes = [
{
"name": "Schoology Plus Modern Light",
diff --git a/js/home.js b/js/home.js
index 8f07994..57ae615 100644
--- a/js/home.js
+++ b/js/home.js
@@ -122,15 +122,17 @@ if (homeFeedContainer && Setting.getValue("broadcasts") !== "disabled") {
// once this happens, we can do our thing
let unreadBroadcasts = Setting.getValue("unreadBroadcasts");
+ let unexpiredBroadcasts = [];
for (let broadcast of unreadBroadcasts || []) {
if (!broadcast.expires || broadcast.expires > Date.now()) {
feed.insertAdjacentElement("afterbegin", postFromBroadcast(broadcast));
- } else {
- unreadBroadcasts.splice(unreadBroadcasts.findIndex(x => x.id == broadcast.id), 1);
- Setting.setValue("unreadBroadcasts", unreadBroadcasts);
+ unexpiredBroadcasts.push(broadcast);
}
}
+ // remove expired broadcasts
+ Setting.setValue("unreadBroadcasts", unexpiredBroadcasts);
+
// then disconnect
observer.disconnect();
});
diff --git a/js/preload.js b/js/preload.js
index b11b289..20cf5f0 100644
--- a/js/preload.js
+++ b/js/preload.js
@@ -417,23 +417,6 @@ function updateSettings(callback) {
return defaultGradingScale;
}
- let themeOptions = [];
-
- for (let theme of __defaultThemes) {
- if(theme.name.includes('LAUSD') && storageContents.defaultDomain !== "lms.lausd.net") continue;
- themeOptions.push({
- text: theme.name,
- value: theme.name
- });
- }
-
- for (let theme of storageContents.themes) {
- themeOptions.push({
- text: theme.name,
- value: theme.name
- });
- }
-
if (firstLoad) {
if (storageContents.themes) {
for (let t of storageContents.themes) {
@@ -462,18 +445,29 @@ function updateSettings(callback) {
new Setting(
"theme",
"Theme",
- "[Reload required] Changes the theme of Schoology Plus",
+ "Change the theme of Schoology Plus",
"Schoology Plus",
"select",
{
- options: themeOptions
+ options: [
+ ...__defaultThemes.filter(
+ t => LAUSD_THEMES.includes(t.name) ? isLAUSD() : true
+ ).map(t => {return {text: t.name, value: t.name}}),
+ ...(__storage.themes || []).map(
+ t => {return {text: t.name, value: t.name}}
+ )
+ ]
},
- value => value,
- undefined,
- element => {
- chrome.storage.sync.set({"theme": element.value});
- return element.value
- }
+ value => {
+ tempTheme = undefined;
+ Theme.apply(Theme.active);
+ return value;
+ },
+ event => {
+ tempTheme = event.target.value;
+ Theme.apply(Theme.byName(event.target.value));
+ },
+ element => element.value
).control,
new Setting(
"notifications",
diff --git a/js/theme-editor.js b/js/theme-editor.js
index df1a4f5..e217764 100644
--- a/js/theme-editor.js
+++ b/js/theme-editor.js
@@ -5,8 +5,6 @@ const lausd2019ImageUrl = chrome.runtime.getURL("/imgs/lausd-2019.png");
const lausd2022ImageUrl = chrome.runtime.getURL("/imgs/lausd-2022.png");
const CURRENT_VERSION = SchoologyTheme.CURRENT_VERSION;
const placeholderUrl = "https://via.placeholder.com/200x50?text=School+Logo";
-const LAUSD_THEMES = ["LAUSD Orange", "LAUSD Dark Blue", "LAUSD 2019"];
-const CLASSIC_THEMES = ["Schoology Plus", "Rainbow"]
var defaultDomain = "app.schoology.com";
@@ -1709,11 +1707,11 @@ $(document).ready(function () {
}
for (let t of __defaultThemes) {
+ defaultThemes.push(t.name);
if (!isLAUSD() && LAUSD_THEMES.includes(t.name)) {
continue;
}
allThemes[t.name] = t;
- defaultThemes.push(t.name);
}
chrome.storage.sync.get(["theme", "themes"], s => {
diff --git a/theme-editor.html b/theme-editor.html
index fcf53f6..ecbe472 100644
--- a/theme-editor.html
+++ b/theme-editor.html
@@ -348,7 +348,7 @@ Logo
+ data-splus-tracking-context="Theme Editor" placeholder="Direct image URL or paste/drop image here">
@@ -357,7 +357,7 @@ Logo
Cursor
+ data-splus-tracking-context="Theme Editor" placeholder="Direct image URL or paste/drop image here">
@@ -899,7 +899,7 @@
Icon URL or paste/drop
- image
+ image here
help
From 8c52a3c7ab9e13dda3c39d9f5bf26f8e926df48b Mon Sep 17 00:00:00 2001
From: Jiaming-S <112342179+Jiaming-S@users.noreply.github.com>
Date: Thu, 6 Apr 2023 17:02:57 -0700
Subject: [PATCH 03/11] Update all.css
---
css/all.css | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/css/all.css b/css/all.css
index 7559619..b3cd904 100644
--- a/css/all.css
+++ b/css/all.css
@@ -766,6 +766,20 @@ a._3_bfp {
display: none !important;
}
+/* ---- Hotfix for missized timer icons ---- */
+.upcoming-list .upcoming-event {
+ align-items: flex-start !important;
+}
+
+.upcoming-list .upcoming-event * {
+ flex-basis: fit-content;
+}
+
+.upcoming-list .upcoming-event > *:not(h4) {
+ margin-top: 2rem !important;
+}
+/* ---------------------------------------- */
+
.splus-mark-completed-check .infotip {
width: 90% !important;
}
From c5bdc099043cf422ecbf8d05ea349822b436aed8 Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Thu, 6 Apr 2023 20:18:24 -0700
Subject: [PATCH 04/11] fix hide upcoming/overdue
---
css/all.css | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/css/all.css b/css/all.css
index b3cd904..5fd0061 100644
--- a/css/all.css
+++ b/css/all.css
@@ -532,7 +532,7 @@ the selector matches inside notifications in the new notifs dropdown
display: var(--overdue-assignments-display) !important;
}
-.upcoming-events-wrapper {
+.upcoming-submissions-wrapper {
display: var(--upcoming-assignments-display) !important;
}
From a24beab20f3ce16e91f30d15a970d5fa1abf40d1 Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Thu, 6 Apr 2023 21:25:57 -0700
Subject: [PATCH 05/11] add tabs to splus settings
---
css/all.css | 30 ++
js/all-idle.js | 6 +-
js/all.js | 4 +
js/preload.js | 897 +++++++++++++++++++++++++------------------------
manifest.json | 4 +-
5 files changed, 497 insertions(+), 444 deletions(-)
diff --git a/css/all.css b/css/all.css
index 5fd0061..58a86c6 100644
--- a/css/all.css
+++ b/css/all.css
@@ -168,6 +168,36 @@ video.easter-egg {
overflow: auto;
}
+.splus-modal-contents.ui-tabs {
+ border: none !important;
+ background: none !important;
+}
+
+.splus-modal-contents select {
+ font-size: 16px !important;
+}
+
+.splus-modal-contents .ui-tabs-nav {
+ background-color: var(--primary-color) !important;
+ border: none !important;
+ border-bottom: 1px solid var(--primary-color) !important;
+}
+
+.splus-modal-contents.ui-tabs .ui-tab {
+ background-color: var(--primary-color) !important;
+ border: none !important;
+}
+
+.splus-modal-contents.ui-tabs .ui-tab .ui-tabs-anchor {
+ color: var(--contrast-text-color) !important;
+ font-size: 14px;
+ text-decoration: underline;
+}
+
+.splus-modal-contents.ui-tabs .ui-tab.ui-tabs-active {
+ background-color: var(--background-color) !important;
+}
+
@-webkit-keyframes animatetop {
from {
top: -300px;
diff --git a/js/all-idle.js b/js/all-idle.js
index 5412e44..0d5acc3 100644
--- a/js/all-idle.js
+++ b/js/all-idle.js
@@ -402,7 +402,11 @@ function parseSettingsHash() {
if (hashes.length > 2) {
setTimeout(() => {
location.hash = hashes[2];
- document.getElementById(hashes[2]).parentElement.parentElement.classList.add("setting-highlight");
+ let settingEntry = document.getElementById(hashes[2]).parentElement.parentElement;
+ let settingTab = settingEntry.parentElement;
+ let tabIndex = Array.from(settingTab.parentElement.children).indexOf(settingTab) - 1;
+ $(".splus-settings-tabs").tabs("option", "active", tabIndex);
+ settingEntry.classList.add("setting-highlight");
location.hash = "";
}, 500);
}
diff --git a/js/all.js b/js/all.js
index a8bd1e7..3773957 100644
--- a/js/all.js
+++ b/js/all.js
@@ -662,6 +662,10 @@ function openOptionsMenu(settingsModal) {
settingsModal.body.appendChild(getModalContents());
settingsModal.element.querySelector("#open-changelog").addEventListener("click", () => openModal("changelog-modal"), { once: true });
settingsModal.element.querySelector("#open-contributors").addEventListener("click", () => openModal("contributors-modal"), { once: true });
+ $(".splus-settings-tabs").tabs({
+ active: 0,
+ heightStyle: "fill"
+ });
});
}
diff --git a/js/preload.js b/js/preload.js
index 20cf5f0..7729a8d 100644
--- a/js/preload.js
+++ b/js/preload.js
@@ -431,451 +431,464 @@ function updateSettings(callback) {
let noControl = document.createElement("div");
modalContents = createElement("div", [], undefined, [
- createElement("div", ["splus-modal-contents"], {}, [
- new Setting(
- "themeEditor",
- "Theme Editor",
- "Click to open the theme editor to create, edit, or select a theme",
- "Theme Editor",
- "button",
- {},
- value => "Theme Editor",
- event => location.href = chrome.runtime.getURL("/theme-editor.html")
- ).control,
- new Setting(
- "theme",
- "Theme",
- "Change the theme of Schoology Plus",
- "Schoology Plus",
- "select",
- {
- options: [
- ...__defaultThemes.filter(
- t => LAUSD_THEMES.includes(t.name) ? isLAUSD() : true
- ).map(t => {return {text: t.name, value: t.name}}),
- ...(__storage.themes || []).map(
- t => {return {text: t.name, value: t.name}}
- )
- ]
- },
- value => {
- tempTheme = undefined;
- Theme.apply(Theme.active);
- return value;
- },
- event => {
- tempTheme = event.target.value;
- Theme.apply(Theme.byName(event.target.value));
- },
- element => element.value
- ).control,
- new Setting(
- "notifications",
- "Desktop Notifications",
- "Displays desktop notifications and a number badge on the extension button when new grades are entered",
- "enabled",
- "select",
- {
- options: [
- {
- text: "Enable All Notifications",
- value: "enabled"
- },
- {
- text: "Number Badge Only (No Pop-Ups)",
- value: "badge"
- },
- {
- text: "Pop-Ups Only (No Badge)",
- value: "popup"
- },
- {
- text: "Disable All Notifications",
- value: "disabled"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "indicateSubmission",
- "Submitted Assignments Checklist",
- '[Reload required] Shows a checkmark, shows a strikethrough, or hides items in "Upcoming Assignments" that have been submitted. If "Show Check Mark" is selected, a checklist function will be enabled allowing you to manually mark assignments as complete.',
- "check",
- "select",
- {
- options: [
- {
- text: "Show Check Mark ✔ (Enables manual checklist)",
- value: "check"
- },
- {
- text: "Show Strikethrough (Doesn't allow manual checklist)",
- value: "strikethrough"
- },
- {
- text: "Hide Assignment (Not recommended)",
- value: "hide"
- },
- {
- text: "Do Nothing",
- value: "disabled"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "quickAccessVisibility",
- "Quick Access",
- "[Reload Required to Reposition] Changes the visibility of the Quick Access panel on the homepage",
- "enabled",
- "select",
- {
- options: [
- {
- text: "Top of Right Sidebar",
- value: "enabled"
- },
- {
- text: "Between Overdue and Upcoming",
- value: "belowOverdue"
- },
- {
- text: "Bottom of Right Sidebar",
- value: "bottom"
- },
- {
- text: "Disabled",
- value: "disabled"
- }
- ]
- },
- value => {
- setCSSVariable("quick-access-display", value === "disabled" ? "none" : "block");
- return value;
- },
- function (event) { this.onload(event.target.value) },
- element => element.value
- ).control,
- new Setting(
- "upcomingOverdueVisibility",
- "Hide Upcoming and Overdue Assignments",
- 'Hides the "Upcoming" and "Overdue" sidebars on the homepage',
- "showAll",
- "select",
- {
- options: [
- {
- text: "Show Both",
- value: "showAll"
- },
- {
- text: "Hide Upcoming Only",
- value: "hideUpcoming"
- },
- {
- text: "Hide Overdue Only",
- value: "hideOverdue"
- },
- {
- text: "Hide Both",
- value: "hideAll"
- }
- ]
- },
- value => {
- setCSSVariable("overdue-assignments-display", "block");
- setCSSVariable("upcoming-assignments-display", "block");
- switch (value) {
- case "hideUpcoming":
- setCSSVariable("upcoming-assignments-display", "none");
- break;
- case "hideOverdue":
- setCSSVariable("overdue-assignments-display", "none");
- break;
- case "hideAll":
- setCSSVariable("upcoming-assignments-display", "none");
- setCSSVariable("overdue-assignments-display", "none");
- break;
- }
- return value;
- },
- function (event) { this.onload(event.target.value) },
- element => element.value
- ).control,
- new Setting(
- "courseIcons",
- "Override Course Icons",
- "[Refresh required to disable] Replace the course icons with the selected theme's icons",
- isLAUSD() ? "enabled" : "defaultOnly",
- "select",
- {
- options: [
- {
- text: "All Icons",
- value: "enabled"
- },
- {
- text: "Default Icons Only",
- value: "defaultOnly",
- },
- {
- text: "Disabled",
- value: "disabled"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "useDefaultIconSet",
- "Use Built-In Icon Set",
- `[Refresh required] Use Schoology Plus's default course icons as a fallback when a custom icon has not been specified. NOTE: these icons were meant for schools in Los Angeles Unified School District and may not work correctly for other schools.`,
- isLAUSD() ? "enabled" : "disabled",
- "select",
- {
- options: [
- {
- text: "Enabled",
- value: "enabled"
- },
- {
- text: "Disabled",
- value: "disabled"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "customScales",
- "Custom Grading Scales",
- "[Refresh required] Uses custom grading scales (set per-course in course settings) when courses don't have one defined",
- "enabled",
- "select",
- {
- options: [
- {
- text: "Enabled",
- value: "enabled"
- },
- {
- text: "Disabled",
- value: "disabled"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "orderClasses",
- "Order Classes",
- "[Refresh required] Changes the order of your classes on the grades and mastery pages (only works if your course names contain PER N or PERIOD N)",
- "period",
- "select",
- {
- options: [
- {
- text: "By Period",
- value: "period"
- },
- {
- text: "Alphabetically",
- value: "alpha"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "overrideUserStyles",
- "Override Styled Text",
- "Override styled text in homefeed posts and discussion responses when using modern themes. WARNING: This guarantees text is readable on dark theme, but removes colors and other styling that may be important. You can always use the Toggle Theme button on the navigation bar to temporarily disble your theme.",
- "true",
- "select",
- {
- options: [
- {
- text: "Enabled",
- value: "true"
- },
- {
- text: "Disabled",
- value: "false"
- }
- ]
- },
- value => {
- document.documentElement.setAttribute("style-override", value);
- return value;
- },
- function (event) { this.onload(event.target.value) },
- element => element.value
- ).control,
- new Setting(
- "archivedCoursesButton",
- "Archived Courses Button",
- 'Adds a link to see past/archived courses in the courses dropdown',
- "show",
- "select",
- {
- options: [
- {
- text: "Show",
- value: "show"
- },
- {
- text: "Hide",
- value: "hide"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "weightedGradebookIndicator",
- "Weighted Gradebook Indicator",
- "Adds an indicator next to gradebooks which are weighted",
- "enabled",
- "select",
- {
- options: [
- {
- text: "Show",
- value: "enabled"
- },
- {
- text: "Hide",
- value: "disabled"
- }
- ]
- },
- value => {
- setCSSVariable("weighted-gradebook-indicator-display", value == "enabled" ? "inline" : "none")
- return value;
- },
- function (event) { this.onload(event.target.value) },
- element => element.value
- ).control,
- new Setting(
- "broadcasts",
- "Announcement Notifications",
- "Displays news feed posts for announcements sent to all Schoology Plus users",
- "enabled",
- "select",
- {
- options: [
- {
- text: "Enable Announcements",
- value: "enabled"
- },
- {
- text: "Disable Announcements",
- value: "disabled"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "autoBypassLinkRedirects",
- "Automatically Bypass Link Redirects",
- "Automatically skip the external link redirection page, clicking 'Continue' by default",
- "enabled",
- "select",
- {
- options: [
- {
- text: "Enabled",
- value: "enabled"
- },
- {
- text: "Disabled",
- value: "disabled"
- }
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- new Setting(
- "helpCenterFAB",
- "Schoology Help Button",
- "Controls the visibility of the S button in the bottom right that shows the Schoology Guide Center",
- "hidden",
- "select",
- {
- options: [
- {
- text: "Show",
- value: "visible"
- },
- {
- text: "Hide",
- value: "hidden"
- }
- ]
- },
- value => {
- setCSSVariable("help-center-fab-visibility", value);
- return value;
- },
- function (event) { this.onload(event.target.value) },
- element => element.value
- ).control,
- new Setting(
- "sessionCookiePersist",
- "Stay Logged In",
- "[Logout/login required] Stay logged in to Schoology when you restart your browser",
- "disabled",
- "select",
- {
- options: [
- {
- text: "Enabled",
- value: "enabled"
- },
- {
- text: "Disabled",
- value: "disabled"
+ createElement("div", ["splus-modal-contents", "splus-settings-tabs"], {}, [
+ createElement("ul", [], {}, [
+ createElement("li", [], {}, [createElement("a", [], {href: "#splus-settings-section-appearance", textContent: "Appearance"})]),
+ createElement("li", [], {}, [createElement("a", [], {href: "#splus-settings-section-sidebar", textContent: "Homepage/Sidebar"})]),
+ createElement("li", [], {}, [createElement("a", [], {href: "#splus-settings-section-grades", textContent: "Grades"})]),
+ createElement("li", [], {}, [createElement("a", [], {href: "#splus-settings-section-utilities", textContent: "Utilities"})]),
+ ]),
+ createElement("div", [], {id: "splus-settings-section-appearance"}, [
+ new Setting(
+ "themeEditor",
+ "Theme Editor",
+ "Click to open the theme editor to create, edit, or select a theme",
+ "Theme Editor",
+ "button",
+ {},
+ value => "Theme Editor",
+ event => location.href = chrome.runtime.getURL("/theme-editor.html")
+ ).control,
+ new Setting(
+ "theme",
+ "Theme",
+ "Change the theme of Schoology Plus",
+ "Schoology Plus",
+ "select",
+ {
+ options: [
+ ...__defaultThemes.filter(
+ t => LAUSD_THEMES.includes(t.name) ? isLAUSD() : true
+ ).map(t => {return {text: t.name, value: t.name}}),
+ ...(__storage.themes || []).map(
+ t => {return {text: t.name, value: t.name}}
+ )
+ ]
+ },
+ value => {
+ tempTheme = undefined;
+ Theme.apply(Theme.active);
+ return value;
+ },
+ event => {
+ tempTheme = event.target.value;
+ Theme.apply(Theme.byName(event.target.value));
+ },
+ element => element.value
+ ).control,
+ new Setting(
+ "courseIcons",
+ "Override Course Icons",
+ "[Refresh required to disable] Replace the course icons with the selected theme's icons",
+ isLAUSD() ? "enabled" : "defaultOnly",
+ "select",
+ {
+ options: [
+ {
+ text: "All Icons",
+ value: "enabled"
+ },
+ {
+ text: "Default Icons Only",
+ value: "defaultOnly",
+ },
+ {
+ text: "Disabled",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "useDefaultIconSet",
+ "Use Built-In Icon Set",
+ `[Refresh required] Use Schoology Plus's default course icons as a fallback when a custom icon has not been specified. NOTE: these icons were meant for schools in Los Angeles Unified School District and may not work correctly for other schools.`,
+ isLAUSD() ? "enabled" : "disabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Enabled",
+ value: "enabled"
+ },
+ {
+ text: "Disabled",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "overrideUserStyles",
+ "Override Styled Text",
+ "Override styled text in homefeed posts and discussion responses when using modern themes. WARNING: This guarantees text is readable on dark theme, but removes colors and other styling that may be important. You can always use the Toggle Theme button on the navigation bar to temporarily disble your theme.",
+ "true",
+ "select",
+ {
+ options: [
+ {
+ text: "Enabled",
+ value: "true"
+ },
+ {
+ text: "Disabled",
+ value: "false"
+ }
+ ]
+ },
+ value => {
+ document.documentElement.setAttribute("style-override", value);
+ return value;
+ },
+ function (event) { this.onload(event.target.value) },
+ element => element.value
+ ).control,
+ new Setting(
+ "archivedCoursesButton",
+ "Archived Courses Button",
+ 'Adds a link to see past/archived courses in the courses dropdown',
+ "show",
+ "select",
+ {
+ options: [
+ {
+ text: "Show",
+ value: "show"
+ },
+ {
+ text: "Hide",
+ value: "hide"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "helpCenterFAB",
+ "Schoology Help Button",
+ "Controls the visibility of the S button in the bottom right that shows the Schoology Guide Center",
+ "hidden",
+ "select",
+ {
+ options: [
+ {
+ text: "Show",
+ value: "visible"
+ },
+ {
+ text: "Hide",
+ value: "hidden"
+ }
+ ]
+ },
+ value => {
+ setCSSVariable("help-center-fab-visibility", value);
+ return value;
+ },
+ function (event) { this.onload(event.target.value) },
+ element => element.value
+ ).control,
+ ]),
+ createElement("div", [], {id: "splus-settings-section-sidebar"}, [
+ new Setting(
+ "indicateSubmission",
+ "Submitted Assignments Checklist",
+ '[Reload required] Shows a checkmark, shows a strikethrough, or hides items in "Upcoming Assignments" that have been submitted. If "Show Check Mark" is selected, a checklist function will be enabled allowing you to manually mark assignments as complete.',
+ "check",
+ "select",
+ {
+ options: [
+ {
+ text: "Show Check Mark ✔ (Enables manual checklist)",
+ value: "check"
+ },
+ {
+ text: "Show Strikethrough (Doesn't allow manual checklist)",
+ value: "strikethrough"
+ },
+ {
+ text: "Hide Assignment (Not recommended)",
+ value: "hide"
+ },
+ {
+ text: "Do Nothing",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "quickAccessVisibility",
+ "Quick Access",
+ "[Reload Required to Reposition] Changes the visibility of the Quick Access panel on the homepage",
+ "enabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Top of Right Sidebar",
+ value: "enabled"
+ },
+ {
+ text: "Between Overdue and Upcoming",
+ value: "belowOverdue"
+ },
+ {
+ text: "Bottom of Right Sidebar",
+ value: "bottom"
+ },
+ {
+ text: "Disabled",
+ value: "disabled"
+ }
+ ]
+ },
+ value => {
+ setCSSVariable("quick-access-display", value === "disabled" ? "none" : "block");
+ return value;
+ },
+ function (event) { this.onload(event.target.value) },
+ element => element.value
+ ).control,
+ new Setting(
+ "upcomingOverdueVisibility",
+ "Hide Upcoming and Overdue Assignments",
+ 'Hides the "Upcoming" and "Overdue" sidebars on the homepage',
+ "showAll",
+ "select",
+ {
+ options: [
+ {
+ text: "Show Both",
+ value: "showAll"
+ },
+ {
+ text: "Hide Upcoming Only",
+ value: "hideUpcoming"
+ },
+ {
+ text: "Hide Overdue Only",
+ value: "hideOverdue"
+ },
+ {
+ text: "Hide Both",
+ value: "hideAll"
+ }
+ ]
+ },
+ value => {
+ setCSSVariable("overdue-assignments-display", "block");
+ setCSSVariable("upcoming-assignments-display", "block");
+ switch (value) {
+ case "hideUpcoming":
+ setCSSVariable("upcoming-assignments-display", "none");
+ break;
+ case "hideOverdue":
+ setCSSVariable("overdue-assignments-display", "none");
+ break;
+ case "hideAll":
+ setCSSVariable("upcoming-assignments-display", "none");
+ setCSSVariable("overdue-assignments-display", "none");
+ break;
}
- ]
- },
- value => value,
- undefined,
- element => element.value
- ).control,
- createElement("div", ["setting-entry"], {}, [
- createElement("h2", ["setting-title"], {}, [
- createElement("a", [], { href: "#", textContent: "Change Schoology Account Access", onclick: () => {location.pathname = "/api";}, style: { fontSize: "" } })
- ]),
- createElement("p", ["setting-description"], { textContent: "Grant Schoology Plus access to your Schoology API Key so many features can function, or revoke that access." })
+ return value;
+ },
+ function (event) { this.onload(event.target.value) },
+ element => element.value
+ ).control,
]),
- getBrowser() !== "Firefox" ? createElement("div", ["setting-entry"], {}, [
- createElement("h2", ["setting-title"], {}, [
- createElement("a", [], { href: "#", textContent: "Anonymous Usage Statistics", onclick: () => openModal("analytics-modal"), style: { fontSize: "" } })
+ createElement("div", [], {id: "splus-settings-section-grades"}, [
+ new Setting(
+ "customScales",
+ "Custom Grading Scales",
+ "[Refresh required] Uses custom grading scales (set per-course in course settings) when courses don't have one defined",
+ "enabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Enabled",
+ value: "enabled"
+ },
+ {
+ text: "Disabled",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "orderClasses",
+ "Order Classes",
+ "[Refresh required] Changes the order of your classes on the grades and mastery pages (only works if your course names contain PER N or PERIOD N)",
+ "period",
+ "select",
+ {
+ options: [
+ {
+ text: "By Period",
+ value: "period"
+ },
+ {
+ text: "Alphabetically",
+ value: "alpha"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "weightedGradebookIndicator",
+ "Weighted Gradebook Indicator",
+ "Adds an indicator next to gradebooks which are weighted",
+ "enabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Show",
+ value: "enabled"
+ },
+ {
+ text: "Hide",
+ value: "disabled"
+ }
+ ]
+ },
+ value => {
+ setCSSVariable("weighted-gradebook-indicator-display", value == "enabled" ? "inline" : "none")
+ return value;
+ },
+ function (event) { this.onload(event.target.value) },
+ element => element.value
+ ).control,
+ ]),
+ createElement("div", [], {id: "splus-settings-section-utilities"}, [
+ new Setting(
+ "notifications",
+ "Desktop Notifications",
+ "Displays desktop notifications and a number badge on the extension button when new grades are entered",
+ "enabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Enable All Notifications",
+ value: "enabled"
+ },
+ {
+ text: "Number Badge Only (No Pop-Ups)",
+ value: "badge"
+ },
+ {
+ text: "Pop-Ups Only (No Badge)",
+ value: "popup"
+ },
+ {
+ text: "Disable All Notifications",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "broadcasts",
+ "Announcement Notifications",
+ "Displays news feed posts for announcements sent to all Schoology Plus users",
+ "enabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Enable Announcements",
+ value: "enabled"
+ },
+ {
+ text: "Disable Announcements",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "autoBypassLinkRedirects",
+ "Automatically Bypass Link Redirects",
+ "Automatically skip the external link redirection page, clicking 'Continue' by default",
+ "enabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Enabled",
+ value: "enabled"
+ },
+ {
+ text: "Disabled",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ new Setting(
+ "sessionCookiePersist",
+ "Stay Logged In",
+ "[Logout/login required] Stay logged in to Schoology when you restart your browser",
+ "disabled",
+ "select",
+ {
+ options: [
+ {
+ text: "Enabled",
+ value: "enabled"
+ },
+ {
+ text: "Disabled",
+ value: "disabled"
+ }
+ ]
+ },
+ value => value,
+ undefined,
+ element => element.value
+ ).control,
+ createElement("div", ["setting-entry"], {}, [
+ createElement("h2", ["setting-title"], {}, [
+ createElement("a", [], { href: "#", textContent: "Change Schoology Account Access", onclick: () => {location.pathname = "/api";}, style: { fontSize: "" } })
+ ]),
+ createElement("p", ["setting-description"], { textContent: "Grant Schoology Plus access to your Schoology API Key so many features can function, or revoke that access." })
]),
- createElement("p", ["setting-description"], { textContent: "[Reload required] Allow Schoology Plus to collect anonymous information about how you use the extension. We don't collect any personal information per our privacy policy." })
- ]) : noControl,
-
+ getBrowser() !== "Firefox" ? createElement("div", ["setting-entry"], {}, [
+ createElement("h2", ["setting-title"], {}, [
+ createElement("a", [], { href: "#", textContent: "Anonymous Usage Statistics", onclick: () => openModal("analytics-modal"), style: { fontSize: "" } })
+ ]),
+ createElement("p", ["setting-description"], { textContent: "[Reload required] Allow Schoology Plus to collect anonymous information about how you use the extension. We don't collect any personal information per our privacy policy." })
+ ]) : noControl,
+ ]),
]),
createElement("div", ["settings-buttons-wrapper"], undefined, [
createButton("save-settings", "Save Settings", () => Setting.saveModified()),
diff --git a/manifest.json b/manifest.json
index 2d4769e..a412fb0 100644
--- a/manifest.json
+++ b/manifest.json
@@ -118,10 +118,12 @@
],
"css": [
"lib/css/contextmenu.css",
- "lib/css/iziToast.min.css"
+ "lib/css/iziToast.min.css",
+ "/lib/css/jquery-ui.min.css"
],
"js": [
"lib/js/jquery-3.3.1.min.js",
+ "/lib/js/jquery-ui.min.js",
"lib/js/contextmenu.js",
"lib/js/iziToast.min.js",
"js/version-specific.js",
From cf2e427caa9e16daa6f105915c0884bd50a46e19 Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Thu, 6 Apr 2023 21:27:09 -0700
Subject: [PATCH 06/11] add spacing to buttons in splus settings
---
css/all.css | 1 +
1 file changed, 1 insertion(+)
diff --git a/css/all.css b/css/all.css
index 58a86c6..a835fd0 100644
--- a/css/all.css
+++ b/css/all.css
@@ -306,6 +306,7 @@ video.easter-egg {
display: flex;
align-items: center;
justify-content: space-between;
+ margin: 0 10px;
}
.settings-actions-wrapper {
From 774201c4fad53ce78dba34fa28372a6e2be3e9ba Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Fri, 7 Apr 2023 13:33:36 -0700
Subject: [PATCH 07/11] Customizable sidebar
---
css/all.css | 56 ++++++++++++----
css/grades.css | 8 ---
js/all.js | 28 ++++----
js/home.js | 50 ++++++++++++++
js/preload.js | 174 ++++++++++++++++++++++++++++++++-----------------
5 files changed, 224 insertions(+), 92 deletions(-)
diff --git a/css/all.css b/css/all.css
index a835fd0..7720f7c 100644
--- a/css/all.css
+++ b/css/all.css
@@ -355,6 +355,39 @@ input[type=text].setting-item {
font-size: 80%;
}
+.sortable-container {
+ display: flex;
+}
+
+.sortable-container .sidebar-sortable {
+ background-color: var(--primary-color) !important;
+ min-height: 200px;
+ padding: 5px;
+}
+
+.sortable-container .sortable-list {
+ margin: 10px;
+ width: 50%;
+}
+
+.sortable-container .sortable-list .sortable-item::before {
+ content: "⡇";
+ padding-right: 5px;
+}
+
+.sortable-container .sortable-list .sortable-item {
+ background-color: var(--background-color);
+ color: var(--contrast-text-color) !important;
+ font-size: 14px;
+ padding: 7px 5px 5px 5px;
+ margin: 5px;
+ cursor: grab;
+}
+
+.sortable-container .ui-sortable-helper {
+ cursor: grabbing;
+}
+
.hierarchical-grading-report.show-title.interactive {
padding: 10px 0 !important;
}
@@ -378,6 +411,14 @@ input[type=text].setting-item {
padding-top: 5px !important;
}
+.grade-active-color {
+ color: #3aa406;
+}
+
+.grade-none-color {
+ color: #767676;
+}
+
.profile-picture img.imagecache-profile_sm {
width: 50px !important;
height: 50px !important;
@@ -559,18 +600,6 @@ the selector matches inside notifications in the new notifs dropdown
visibility: var(--help-center-fab-visibility) !important;
}
-.overdue-submissions-wrapper {
- display: var(--overdue-assignments-display) !important;
-}
-
-.upcoming-submissions-wrapper {
- display: var(--upcoming-assignments-display) !important;
-}
-
-.quick-access-wrapper {
- display: var(--quick-access-display) !important;
-}
-
.quick-link-wrapper {
padding-top: 5px;
}
@@ -806,8 +835,9 @@ a._3_bfp {
flex-basis: fit-content;
}
-.upcoming-list .upcoming-event > *:not(h4) {
+.upcoming-list .upcoming-event > .infotip.submission-infotip {
margin-top: 2rem !important;
+ display: var(--to-do-list-icons-display, "block");
}
/* ---------------------------------------- */
diff --git a/css/grades.css b/css/grades.css
index 610b32c..f7d1c58 100644
--- a/css/grades.css
+++ b/css/grades.css
@@ -4,14 +4,6 @@
font-size: 14px;
}
-.grade-active-color {
- color: #3aa406;
-}
-
-.grade-none-color {
- color: #767676;
-}
-
tr.item-row td.grade-column div.td-content-wrapper {
padding: 7px 10px 5px !important;
text-align: center;
diff --git a/js/all.js b/js/all.js
index 3773957..e0dd7e1 100644
--- a/js/all.js
+++ b/js/all.js
@@ -662,6 +662,7 @@ function openOptionsMenu(settingsModal) {
settingsModal.body.appendChild(getModalContents());
settingsModal.element.querySelector("#open-changelog").addEventListener("click", () => openModal("changelog-modal"), { once: true });
settingsModal.element.querySelector("#open-contributors").addEventListener("click", () => openModal("contributors-modal"), { once: true });
+ Setting.onShown();
$(".splus-settings-tabs").tabs({
active: 0,
heightStyle: "fill"
@@ -1147,7 +1148,7 @@ async function createQuickAccess() {
createSvgLogo("splus-logo-inline"),
// createElement("img", ["splus-logo-inline"], { src: chrome.runtime.getURL("imgs/plus-icon.png"), title: "Provided by Schoology Plus" }),
createElement("span", [], { textContent: "Quick Access" }),
- createElement("a", ["quick-right-link", "splus-track-clicks"], { id: "quick-access-splus-settings", textContent: "Settings", href: "#splus-settings#setting-input-quickAccessVisibility" })
+ createElement("a", ["quick-right-link", "splus-track-clicks"], { id: "quick-access-splus-settings", textContent: "Settings", href: "#splus-settings#setting-input-sidebarSectionOrder" })
]),
createElement("div", ["date-header", "first"], {}, [
createElement("h4", [], { textContent: "Pages" })
@@ -1221,17 +1222,7 @@ async function createQuickAccess() {
}
}
- switch (Setting.getValue("quickAccessVisibility")) {
- case "belowOverdue":
- rightCol.querySelector(".overdue-submissions").insertAdjacentElement("afterend", wrapper);
- break;
- case "bottom":
- rightCol.append(wrapper);
- break;
- default:
- rightCol.prepend(wrapper);
- break;
- }
+ rightCol.append(wrapper);
}
function indicateSubmittedAssignments() {
@@ -1388,7 +1379,18 @@ function indicateSubmittedAssignments() {
// check if reload is present and visible on page
let reloadButton = upcomingList.querySelector("button.button-reset.refresh-button");
if (reloadButton && reloadButton.offsetParent !== null) {
- reloadButton.addEventListener("click", () => setTimeout(indicateSubmitted, 500));
+ reloadButton.addEventListener("click", () => setTimeout(() => {
+ indicateSubmitted();
+
+ try {
+ document.getElementById("todo")?.remove();
+ let overdueHeading = document.querySelector(`${SIDEBAR_SECTIONS_MAP["Overdue"].selector} h4`);
+ overdueHeading?.replaceWith(createElement("h3", [], {style: {textTransform: "capitalize"}, textContent: overdueHeading.textContent.toLowerCase()}));
+ let upcomingHeading = document.querySelector(`${SIDEBAR_SECTIONS_MAP["Upcoming"].selector} h4`);
+ upcomingHeading?.replaceWith(createElement("h3", [], {style: {textTransform: "capitalize"}, textContent: upcomingHeading.textContent.toLowerCase()}));
+ }
+ catch {}
+ }, 500));
} else {
// loaded properly
// clear out old assignments from local cache which aren't relevant anymore
diff --git a/js/home.js b/js/home.js
index 57ae615..42d3abb 100644
--- a/js/home.js
+++ b/js/home.js
@@ -144,9 +144,59 @@ if (homeFeedContainer && Setting.getValue("broadcasts") !== "disabled") {
})();
}
+function reorderSidebar() {
+ let sidebar = document.getElementById("right-column-inner");
+ let sidebarOrder = Setting.getValue("sidebarSectionOrder");
+ let excluded = sidebarOrder?.exclude || [];
+ let included = (Array.from(sidebarOrder?.include || [])).reverse();
+
+ for (let section of Array.from(SIDEBAR_SECTIONS).reverse()) {
+ if (!included.includes(section.name) && !excluded.includes(section.name)) {
+ if (section) {
+ let element = document.querySelector(section.selector);
+ if (element) {
+ sidebar.insertAdjacentElement("afterbegin", element);
+ }
+ }
+ }
+ }
+
+ for (let sectionName of included) {
+ let section = SIDEBAR_SECTIONS_MAP[sectionName];
+ if (section) {
+ let element = document.querySelector(section.selector);
+ if (element) {
+ sidebar.insertAdjacentElement("afterbegin", element);
+ }
+ }
+ }
+
+ for (let sectionName of excluded) {
+ let section = SIDEBAR_SECTIONS_MAP[sectionName];
+ if (section) {
+ let element = document.querySelector(section.selector);
+ if (element) {
+ element.style.display = "none";
+ }
+ }
+ }
+
+ try {
+ document.getElementById("todo")?.remove();
+ let overdueHeading = document.querySelector(`${SIDEBAR_SECTIONS_MAP["Overdue"].selector} h4`);
+ overdueHeading?.replaceWith(createElement("h3", [], {style: {textTransform: "capitalize"}, textContent: overdueHeading.textContent.toLowerCase()}));
+ let upcomingHeading = document.querySelector(`${SIDEBAR_SECTIONS_MAP["Upcoming"].selector} h4`);
+ upcomingHeading?.replaceWith(createElement("h3", [], {style: {textTransform: "capitalize"}, textContent: upcomingHeading.textContent.toLowerCase()}));
+ }
+ catch {}
+}
+
(function () {
indicateSubmittedAssignments();
createQuickAccess();
+ setTimeout(() => {
+ reorderSidebar();
+ }, 500);
})();
Logger.debug("Finished loading home.js");
diff --git a/js/preload.js b/js/preload.js
index 7729a8d..86c341e 100644
--- a/js/preload.js
+++ b/js/preload.js
@@ -20,6 +20,34 @@ var beta_tests = {
var defaultCourseIconUrlRegex = /\/sites\/[a-zA-Z0-9_-]+\/themes\/[%a-zA-Z0-9_-]+\/images\/course-default.(?:svg|png|jpe?g|gif)(\?[a-zA-Z0-9_%-]+(=[a-zA-Z0-9_%-]+)?(&[a-zA-Z0-9_%-]+(=[a-zA-Z0-9_%-]+)?)*)?$/;
+var SIDEBAR_SECTIONS = [
+ {
+ name: "Quick Access",
+ selector: "#right-column-inner div.quick-access-wrapper"
+ },
+ {
+ name: "Reminders",
+ selector: "#right-column-inner div.reminders-wrapper"
+ },
+ {
+ name: "Overdue",
+ selector: "#right-column-inner div#overdue-submissions.overdue-submissions-wrapper"
+ },
+ {
+ name: "Upcoming",
+ selector: "#right-column-inner div.upcoming-submissions-wrapper"
+ },
+ {
+ name: "Upcoming Events",
+ selector: "#right-column-inner div#upcoming-events.upcoming-events-wrapper"
+ },
+ {
+ name: "Recently Completed",
+ selector: "#right-column-inner div.recently-completed-wrapper"
+ },
+];
+var SIDEBAR_SECTIONS_MAP = Object.fromEntries(SIDEBAR_SECTIONS.map(s => [s.name, s]));
+
// Functions
/** @type {HTMLDivElement} */
@@ -629,83 +657,100 @@ function updateSettings(callback) {
element => element.value
).control,
new Setting(
- "quickAccessVisibility",
- "Quick Access",
- "[Reload Required to Reposition] Changes the visibility of the Quick Access panel on the homepage",
- "enabled",
+ "toDoIconVisibility",
+ '"Overdue" and "Due Tomorrow" Icon Visibility',
+ 'Controls the visibility of the "Overdue" exclamation point icon and the "Due Tomorrow" clock icon in the Upcoming and Overdue lists on the sidebar of the homepage',
+ "visible",
"select",
{
options: [
{
- text: "Top of Right Sidebar",
- value: "enabled"
- },
- {
- text: "Between Overdue and Upcoming",
- value: "belowOverdue"
- },
- {
- text: "Bottom of Right Sidebar",
- value: "bottom"
+ text: "Show Icons",
+ value: "visible"
},
{
- text: "Disabled",
- value: "disabled"
+ text: "Hide Icons",
+ value: "hidden"
}
]
},
value => {
- setCSSVariable("quick-access-display", value === "disabled" ? "none" : "block");
+ setCSSVariable("to-do-list-icons-display", "block");
+ switch (value) {
+ case "hidden":
+ setCSSVariable("to-do-list-icons-display", "none");
+ break;
+ }
return value;
},
function (event) { this.onload(event.target.value) },
element => element.value
).control,
new Setting(
- "upcomingOverdueVisibility",
- "Hide Upcoming and Overdue Assignments",
- 'Hides the "Upcoming" and "Overdue" sidebars on the homepage',
- "showAll",
- "select",
+ "sidebarSectionOrder",
+ "Customize Sidebar",
+ "",
{
- options: [
- {
- text: "Show Both",
- value: "showAll"
- },
- {
- text: "Hide Upcoming Only",
- value: "hideUpcoming"
- },
- {
- text: "Hide Overdue Only",
- value: "hideOverdue"
- },
- {
- text: "Hide Both",
- value: "hideAll"
+ include: [],
+ exclude: []
+ },
+ "custom",
+ {
+ element: createElement("div", [], {}, [
+ createElement("p", [], {style: {fontWeight: "normal"}, textContent: "Drag items between the sections to control which sections of the sidebar are visible and the order in which they are shown."}),
+ createElement("div", ["sortable-container"], {}, [
+ createElement("div", ["sortable-list"], {}, [
+ createElement("h3", [], {textContent: "Sections to Hide"}),
+ createElement("ul", ["sidebar-sortable"], {id: "sidebar-excluded-sortable"})
+ ]),
+ createElement("div", ["sortable-list"], {}, [
+ createElement("h3", [], {textContent: "Sections to Show"}),
+ createElement("ul", ["sidebar-sortable"], {id: "sidebar-included-sortable"})
+ ]),
+ ])
+ ]),
+ },
+ function (value, element) {
+ let includeList = element.querySelector("#sidebar-included-sortable");
+ let excludeList = element.querySelector("#sidebar-excluded-sortable");
+
+ includeList.innerHTML = "";
+ excludeList.innerHTML = "";
+
+ if (!value || !value.include || !value.exclude) {
+ value = {include: [], exclude: []};
+ }
+
+ for (let section of value.include) {
+ includeList.appendChild(createElement("p", ["sortable-item"], {textContent: section}))
+ }
+
+ for (let section of value.exclude) {
+ excludeList.appendChild(createElement("p", ["sortable-item"], {textContent: section}))
+ }
+
+ for (let section of SIDEBAR_SECTIONS) {
+ if (!value.include.includes(section.name) && !value.exclude.includes(section.name)) {
+ includeList.appendChild(createElement("p", ["sortable-item"], {textContent: section.name}))
}
- ]
+ }
},
- value => {
- setCSSVariable("overdue-assignments-display", "block");
- setCSSVariable("upcoming-assignments-display", "block");
- switch (value) {
- case "hideUpcoming":
- setCSSVariable("upcoming-assignments-display", "none");
- break;
- case "hideOverdue":
- setCSSVariable("overdue-assignments-display", "none");
- break;
- case "hideAll":
- setCSSVariable("upcoming-assignments-display", "none");
- setCSSVariable("overdue-assignments-display", "none");
- break;
+ function (event) { console.log(event); },
+ element => {
+ let includeList = element.querySelector("#sidebar-included-sortable");
+ let excludeList = element.querySelector("#sidebar-excluded-sortable");
+
+ return {
+ include: Array.from(includeList.children).map(e => e.textContent),
+ exclude: Array.from(excludeList.children).map(e => e.textContent)
}
- return value;
},
- function (event) { this.onload(event.target.value) },
- element => element.value
+ function () {
+ $(".sidebar-sortable").sortable({
+ connectWith: ".sidebar-sortable",
+ stop: () => Setting.onModify(this.getElement())
+ }).disableSelection();
+ }
).control,
]),
createElement("div", [], {id: "splus-settings-section-grades"}, [
@@ -930,13 +975,15 @@ let __settings = {};
* - First argument is the HTML element containing the setting value set by the user
* - Must return the value to be saved to extension settings
* - Will only be called if user saves settings and setting was modified
+ * @param {function():any} onshown Function called when the setting element is shown on screen
*/
-function Setting(name, friendlyName, description, defaultValue, type, options, onload, onmodify, onsave) {
+function Setting(name, friendlyName, description, defaultValue, type, options, onload, onmodify, onsave, onshown) {
this.name = name;
this.getElement = () => document.getElementById(`setting-input-${this.name}`);
this.onmodify = onmodify;
this.onsave = onsave;
this.onload = onload;
+ this.onshown = onshown;
this.modified = false;
this.default = defaultValue;
/**
@@ -965,6 +1012,9 @@ function Setting(name, friendlyName, description, defaultValue, type, options, o
title.appendChild(selectElement);
selectElement.onchange = Setting.onModify;
break;
+ case "custom":
+ title.appendChild(options.element);
+ break;
}
setting.appendChild(title);
@@ -978,7 +1028,7 @@ function Setting(name, friendlyName, description, defaultValue, type, options, o
}
if (onload) {
- title.firstElementChild.value = onload(__storage[name]) || this.default;
+ title.firstElementChild.value = this.onload(__storage[name], title.firstElementChild) || this.default;
} else {
title.firstElementChild.value = __storage[name] || this.default;
}
@@ -1138,6 +1188,14 @@ Setting.onModify = function (event) {
}
}
+Setting.onShown = function () {
+ for (let setting in __settings) {
+ if (__settings[setting].onshown) {
+ __settings[setting].onshown();
+ }
+ }
+}
+
/**
* @returns {boolean} `true` if any setting has been modified
*/
From 3aa22becfd9386822306e55a21d4a9cfa57cc8cf Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Fri, 7 Apr 2023 13:39:13 -0700
Subject: [PATCH 08/11] Fix grabbing hand and update settings text
---
css/all.css | 2 +-
js/all.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/css/all.css b/css/all.css
index 7720f7c..cf9b610 100644
--- a/css/all.css
+++ b/css/all.css
@@ -384,7 +384,7 @@ input[type=text].setting-item {
cursor: grab;
}
-.sortable-container .ui-sortable-helper {
+.sortable-container .sortable-list .ui-sortable-helper {
cursor: grabbing;
}
diff --git a/js/all.js b/js/all.js
index e0dd7e1..87f868a 100644
--- a/js/all.js
+++ b/js/all.js
@@ -1148,7 +1148,7 @@ async function createQuickAccess() {
createSvgLogo("splus-logo-inline"),
// createElement("img", ["splus-logo-inline"], { src: chrome.runtime.getURL("imgs/plus-icon.png"), title: "Provided by Schoology Plus" }),
createElement("span", [], { textContent: "Quick Access" }),
- createElement("a", ["quick-right-link", "splus-track-clicks"], { id: "quick-access-splus-settings", textContent: "Settings", href: "#splus-settings#setting-input-sidebarSectionOrder" })
+ createElement("a", ["quick-right-link", "splus-track-clicks"], { id: "quick-access-splus-settings", textContent: "Sidebar Settings", href: "#splus-settings#setting-input-sidebarSectionOrder" })
]),
createElement("div", ["date-header", "first"], {}, [
createElement("h4", [], { textContent: "Pages" })
From 1f28fba6840d4ffd4daee00de57c1c68e96bb341 Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Fri, 7 Apr 2023 13:53:54 -0700
Subject: [PATCH 09/11] minor style changes
---
css/all.css | 5 +++++
css/modern/all.css | 8 ++++++++
js/all.js | 2 +-
js/preload.js | 14 +++++++-------
scss/modern/all.scss | 8 ++++++++
5 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/css/all.css b/css/all.css
index cf9b610..05cfd3c 100644
--- a/css/all.css
+++ b/css/all.css
@@ -198,6 +198,11 @@ video.easter-egg {
background-color: var(--background-color) !important;
}
+.splus-underline-heading {
+ text-decoration: underline;
+ margin-bottom: 5px;
+}
+
@-webkit-keyframes animatetop {
from {
top: -300px;
diff --git a/css/modern/all.css b/css/modern/all.css
index 4ed6ac8..d53847d 100644
--- a/css/modern/all.css
+++ b/css/modern/all.css
@@ -3386,3 +3386,11 @@ variable-intellisense {
[modern=true]:root #grade-comment-field {
background-color: var(--primary);
}
+
+[modern=true]:root .splus-modern-border-radius {
+ border-radius: var(--border-radius);
+}
+
+[modern=true]:root .splus-modern-padding {
+ padding: var(--padding);
+}
diff --git a/js/all.js b/js/all.js
index 87f868a..1fe59f0 100644
--- a/js/all.js
+++ b/js/all.js
@@ -1148,7 +1148,7 @@ async function createQuickAccess() {
createSvgLogo("splus-logo-inline"),
// createElement("img", ["splus-logo-inline"], { src: chrome.runtime.getURL("imgs/plus-icon.png"), title: "Provided by Schoology Plus" }),
createElement("span", [], { textContent: "Quick Access" }),
- createElement("a", ["quick-right-link", "splus-track-clicks"], { id: "quick-access-splus-settings", textContent: "Sidebar Settings", href: "#splus-settings#setting-input-sidebarSectionOrder" })
+ createElement("a", ["quick-right-link", "splus-track-clicks"], { id: "quick-access-splus-settings", textContent: "Customize Sidebar", href: "#splus-settings#setting-input-sidebarSectionOrder" })
]),
createElement("div", ["date-header", "first"], {}, [
createElement("h4", [], { textContent: "Pages" })
diff --git a/js/preload.js b/js/preload.js
index 86c341e..09c2f2d 100644
--- a/js/preload.js
+++ b/js/preload.js
@@ -700,12 +700,12 @@ function updateSettings(callback) {
createElement("p", [], {style: {fontWeight: "normal"}, textContent: "Drag items between the sections to control which sections of the sidebar are visible and the order in which they are shown."}),
createElement("div", ["sortable-container"], {}, [
createElement("div", ["sortable-list"], {}, [
- createElement("h3", [], {textContent: "Sections to Hide"}),
- createElement("ul", ["sidebar-sortable"], {id: "sidebar-excluded-sortable"})
+ createElement("h3", ["splus-underline-heading"], {textContent: "Sections to Hide"}),
+ createElement("ul", ["sidebar-sortable", "splus-modern-border-radius", "splus-modern-padding"], {id: "sidebar-excluded-sortable"})
]),
createElement("div", ["sortable-list"], {}, [
- createElement("h3", [], {textContent: "Sections to Show"}),
- createElement("ul", ["sidebar-sortable"], {id: "sidebar-included-sortable"})
+ createElement("h3", ["splus-underline-heading"], {textContent: "Sections to Show"}),
+ createElement("ul", ["sidebar-sortable", "splus-modern-border-radius", "splus-modern-padding"], {id: "sidebar-included-sortable"})
]),
])
]),
@@ -722,16 +722,16 @@ function updateSettings(callback) {
}
for (let section of value.include) {
- includeList.appendChild(createElement("p", ["sortable-item"], {textContent: section}))
+ includeList.appendChild(createElement("p", ["sortable-item", "splus-modern-border-radius", "splus-modern-padding"], {textContent: section}))
}
for (let section of value.exclude) {
- excludeList.appendChild(createElement("p", ["sortable-item"], {textContent: section}))
+ excludeList.appendChild(createElement("p", ["sortable-item", "splus-modern-border-radius", "splus-modern-padding"], {textContent: section}))
}
for (let section of SIDEBAR_SECTIONS) {
if (!value.include.includes(section.name) && !value.exclude.includes(section.name)) {
- includeList.appendChild(createElement("p", ["sortable-item"], {textContent: section.name}))
+ includeList.appendChild(createElement("p", ["sortable-item", "splus-modern-border-radius", "splus-modern-padding"], {textContent: section.name}))
}
}
},
diff --git a/scss/modern/all.scss b/scss/modern/all.scss
index 9e65c9e..d7e2abd 100644
--- a/scss/modern/all.scss
+++ b/scss/modern/all.scss
@@ -3799,4 +3799,12 @@ variable-intellisense {
#grade-comment-field {
background-color: var(--primary);
}
+
+ .splus-modern-border-radius {
+ border-radius: var(--border-radius);
+ }
+
+ .splus-modern-padding {
+ padding: var(--padding);
+ }
}
From 420d06888c44acdf040d5079d8cd92e65c08e673 Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Fri, 7 Apr 2023 14:13:29 -0700
Subject: [PATCH 10/11] bump version
---
manifest.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/manifest.json b/manifest.json
index a412fb0..4bb7ede 100644
--- a/manifest.json
+++ b/manifest.json
@@ -10,7 +10,7 @@
"update_url": "https://schoologypl.us/firefox_updates.json"
}
},
- "version": "7.7.3",
+ "version": "7.8",
"icons": {
"128": "imgs/icon@128.png",
"64": "imgs/icon@64.png",
From 39e99be2728406169b422cda3952eb6ff15237c7 Mon Sep 17 00:00:00 2001
From: Aaron Opell
Date: Fri, 7 Apr 2023 14:42:48 -0700
Subject: [PATCH 11/11] Update broadcasts and add version filter
---
js/home.js | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/js/home.js b/js/home.js
index 42d3abb..77007a7 100644
--- a/js/home.js
+++ b/js/home.js
@@ -101,18 +101,7 @@ function formatDateAsString(date) {
if (homeFeedContainer && Setting.getValue("broadcasts") !== "disabled") {
(async function () {
- try {
- let onlineBroadcasts = await (await fetch("https://schoologypl.us/alert.json")).json();
-
- let readBroadcasts = localStorage.getItem("splus-readBroadcasts");
- readBroadcasts = readBroadcasts === null ? [] : JSON.parse(readBroadcasts);
-
- saveBroadcasts(onlineBroadcasts.filter(b => !readBroadcasts.includes(b.id)));
- } catch (err) {
- // Ignore
- }
-
- let observer = new MutationObserver(function (mutations) {
+ let observer = new MutationObserver(async function (mutations) {
if (mutations.length == 0) {
return;
}
@@ -121,10 +110,26 @@ if (homeFeedContainer && Setting.getValue("broadcasts") !== "disabled") {
// style is set on homeFeedContainer whenever Schoology decides to unhide it (static CSS sets display: none), i.e. when it's finished loading
// once this happens, we can do our thing
- let unreadBroadcasts = Setting.getValue("unreadBroadcasts");
+ let unreadBroadcasts = Setting.getValue("unreadBroadcasts") || [];
+ let onlineBroadcasts = [];
+
+ try {
+ onlineBroadcasts = await (await fetch("https://schoologypl.us/alert.json")).json();
+
+ let readBroadcasts = localStorage.getItem("splus-readBroadcasts");
+ readBroadcasts = readBroadcasts === null ? [] : JSON.parse(readBroadcasts);
+
+ onlineBroadcasts = onlineBroadcasts.filter(b => !readBroadcasts.includes(b.id) && !unreadBroadcasts.map(u => u.id).includes(b.id));
+ } catch (err) {
+ // Ignore
+ }
+
let unexpiredBroadcasts = [];
- for (let broadcast of unreadBroadcasts || []) {
- if (!broadcast.expires || broadcast.expires > Date.now()) {
+ for (let broadcast of [...unreadBroadcasts, ...onlineBroadcasts]) {
+ if (
+ (!broadcast.expires || broadcast.expires > Date.now())
+ && (!broadcast.version || compareVersions(chrome.runtime.getManifest().version, broadcast.version) >= 0)
+ ) {
feed.insertAdjacentElement("afterbegin", postFromBroadcast(broadcast));
unexpiredBroadcasts.push(broadcast);
}
|