Skip to content

Commit

Permalink
Merge pull request #175 from aopell/develop
Browse files Browse the repository at this point in the history
Version 6.0
  • Loading branch information
aopell authored Mar 10, 2020
2 parents 903965a + 34a7273 commit eb7e23b
Show file tree
Hide file tree
Showing 23 changed files with 642 additions and 410 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017-2019 Aaron Opell
Copyright (c) 2017-2020 Aaron Opell and Glen Husman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
40 changes: 36 additions & 4 deletions css/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ footer._2T2dA {
background-image: var(--background-url) !important;
background-size: 160px !important;
background-position: center center !important;
height: 60px !important;
margin-top: 0 !important;
}

/* links inside the container for the added "Archived Courses" link within the Courses dropdown */
Expand Down Expand Up @@ -160,6 +162,7 @@ video.easter-egg {
top: -300px;
opacity: 0
}

to {
top: 0;
opacity: 1
Expand All @@ -171,6 +174,7 @@ video.easter-egg {
top: -300px;
opacity: 0
}

to {
top: 0;
opacity: 1
Expand Down Expand Up @@ -392,7 +396,8 @@ h1.setting-title {
margin-top: 7px !important;
}

.footer-divider, .footer-divider > span {
.footer-divider,
.footer-divider>span {
margin-left: 15px;
}

Expand All @@ -415,19 +420,21 @@ h1.setting-title {
.course-list-icon {
float: left;
padding: 7px 16px 7px 7px;
width: 64px;
width: 48px;
}

/*
#139 fix
Make accept and cancel buttons similarly styled throughout the UI
*/
#popup_cancel, .cancel-btn {
#popup_cancel,
.cancel-btn {
background-color: #666 !important;
color: white !important;
}

#popup_cancel:hover, .cancel-btn:hover {
#popup_cancel:hover,
.cancel-btn:hover {
background-color: #444 !important;
}

Expand Down Expand Up @@ -488,4 +495,29 @@ the selector matches inside notifications in the new notifs dropdown

.upcoming-events-wrapper {
display: var(--upcoming-assignments-display) !important;
}

body a,
body .clickable,
body .smart-box .filter-block li a,
body #content-left-top .item-list li a,
body .popups-tab,
body .enrollment-filters span,
body .grading-groups-list .grading-group,
body #grading-group-
span.ajax-post-comment,
.period-row .title,
.category-row .title {
color: var(--hover-color) !important;
}

body a.link-btn {
color: #333333 !important;
}

footer li a,
header li a,
.splus-modal-footer-text a,
body a.link-btn.active {
color: white !important;
}
14 changes: 14 additions & 0 deletions css/theme-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
--hover-color: hsl(var(--color-hue), 55%, 40%);
--border-color: hsl(var(--color-hue), 60%, 25%);
--cursor: auto;
--lausd-visible: block;
--lausd-hidden: none;
--background-url: url(https://ui.schoology.com/design-system/assets/schoology-logo-horizontal-white.884fbe559c66e06d28c5cfcbd4044f0e.svg);
}

Expand Down Expand Up @@ -646,4 +648,16 @@ textarea#json-output[readonly] {

.highlight {
background-color: lightcyan !important;
}

.setting-link {
color: var(--hover-color);
}

.show-lausd {
display: var(--lausd-visible);
}

.hide-lausd {
display: var(--lausd-hidden);
}
117 changes: 117 additions & 0 deletions default-icons.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html>

<head>
<link type="text/css" rel="stylesheet" href="/lib/css/material-icons.css" />
<link type="text/css" rel="stylesheet" href="/lib/css/materialize.min.css" media="screen,projection" />
<link type="text/css" rel="stylesheet" href="/lib/css/roundslider.min.css" />
<link type="text/css" rel="stylesheet" href="/css/theme-editor.css" />
<link rel="shortcut icon" type="image/png" href="/imgs/[email protected]" />

<style>
* {
--condensed-width: 75px;
}

img {
padding: 10px 10px !important;
}

code {
margin-top: 10px;
word-wrap: break-word;
overflow: hidden;
background-color: rgba(27, 31, 35, 0.1);
border-radius: 3px;
color: rgb(224, 68, 68);
}

.icon-preview a {
background-color: #888888;
color: white;
border-radius: 3px;
padding: 3px;
}

.icon-preview {
height: 35vh;
border: 1px dotted black;
}

.condensed .icon-preview {
height: var(--condensed-width) !important;
width: var(--condensed-width) !important;
padding: 0 !important;
border: none;
}

.condensed .icon-preview a,
.condensed .icon-preview code {
display: none;
}

.condensed .icon-preview img {
padding: 0 !important;
width: var(--condensed-width) !important;
height: var(--condensed-width) !important;
}
</style>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title>Default Course Icons - Schoology Plus</title>
</head>

<body>
<header>
<div class="navbar-fixed">
<nav class="splus-blue">
<div class="nav-wrapper">
<ul id="nav-mobile" class="left">
<li>
<a data-position="right" data-tooltip="Back to Theme Editor"
class="waves-effect waves-light tooltipped" href="theme-editor.html">
<i class="material-icons">arrow_back</i>
</a>
</li>
</ul>
<div class="brand-logo center truncate">
Schoology Plus Default Course Icons
</div>
<ul id="nav-mobile" class="right">
<li>
<a data-position="left" data-tooltip="Toggle Condensed Mode"
class="waves-effect waves-light tooltipped" id="toggle">
<i id="toggle-icon" class="material-icons">toggle_off</i>
</a>
</li>
</ul>
</div>
</nav>
</div>
</header>
<main class="container wide-container">
<div class="row content-box">
<div class="input-field col s12">
<input type="text" id="icon-test-text" placeholder="Type a class name here to view matching icons">
</div>
<div class="col s12 row" id="icons-container">
</div>
<div class="col s12 center">
All icons used under CC BY 3.0
</div>
<div class="col s12 center">
Click icon numbers to view sources
</div>
<div class="col s12 center">
List of authors in Contributors under Schoology Plus settings
</div>
</div>
</div>
</main>
<script src="/lib/js/materialize.min.js"></script>
<script src="/js/icons.js"></script>
<script src="/js/default-icons-page.js"></script>
</body>

</html>
Binary file added imgs/lausd-2019.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion js/all-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
}
}

let notifsMenuContainer = document.querySelector("#header nav button[aria-label$=\"notifications\"]").parentElement;
let notifsMenuContainer = document.querySelector("#header nav button[aria-label$=\"notifications\"], #header nav button[aria-label$=\"notification\"]").parentElement;
let gradesLoadedPromise = (async function () {
let myGrades = await fetchApiJson(`/users/${getUserId()}/grades`);

Expand Down
63 changes: 61 additions & 2 deletions js/all.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
// Inform user about theme
{
if (localStorage["splus-temp-generatedtheme"]) {
localStorage.removeItem("splus-temp-generatedtheme");

showToast(
"Theme Generated",
"Schoology Plus created a theme that matches your school's theme",
"rgb(0,255,0)",
{
buttons: [
createToastButton("View Themes", "view-themes-button", () => location.href = chrome.runtime.getURL("/theme-editor.html"))
]
}
);
}
}

// Check Schoology domain
{
const BLACKLISTED_DOMAINS = ["asset-cdn.schoology.com"];
let dd = Setting.getValue("defaultDomain");

if (dd !== window.location.host && !BLACKLISTED_DOMAINS.includes(window.location.host)) {
Setting.setValue("defaultDomain", window.location.host);

let bgColor = document.querySelector("#header header").style.backgroundColor;

if (bgColor) {
let t = {
"name": `Auto Generated Theme for ${window.location.host}`,
"version": 2,
"color": {
"custom": {
"primary": bgColor,
"hover": "rgb(2, 79, 125)",
"background": "rgb(2, 79, 125)",
"border": "rgb(2, 79, 125)"
}
},
"logo": {
"preset": "default"
}
};

localStorage["splus-temp-generatedtheme"] = true;

chrome.storage.sync.get({ themes: [] }, s => {
let themes = s.themes.filter(x => x.name !== `Auto Generated Theme for ${window.location.host}`);
themes.push(t);
chrome.storage.sync.set({ themes: themes }, () => {
alert(`Schoology Plus has updated the domain on which it runs. Click OK to reload the page.\nPrevious: ${dd}\nNew: ${window.location.host}`);
location.reload();
});
});
}
}
}

// Page Modifications

document.head.appendChild(createElement("meta", [], { name: "viewport", content: "width=device-width, initial-scale=1" }));
Expand All @@ -8,11 +67,11 @@ bottom.appendChild(createElement("span", ["footer-divider"], { textContent: "|"

document.documentElement.style.setProperty("--default-visibility", "visible");

let verboseModalFooterText = `&copy; Aaron Opell, Glen Husman 2017-2019 | <a href="${getBrowser() == "Chrome" ? `https://chrome.google.com/webstore/detail/${chrome.runtime.id}` : "https://github.com/aopell/SchoologyPlus/releases/latest"}">Schoology Plus v${chrome.runtime.getManifest().version_name || chrome.runtime.getManifest().version}${getBrowser() != "Chrome" || chrome.runtime.getManifest().update_url ? '' : ' dev'}</a> | <a href="https://aopell.github.io/SchoologyPlus/discord.html" title="Get support, report bugs, suggest features, and chat with the Schoology Plus community">Discord Support Server</a> | <a href="https://github.com/aopell/SchoologyPlus">GitHub</a> | <a href="#" id="open-contributors">Contributors</a> | <a href="#" id="open-changelog"> Changelog</a>`;
let verboseModalFooterText = `&copy; Aaron Opell, Glen Husman 2017-2020 | <a href="${getBrowser() == "Chrome" ? `https://chrome.google.com/webstore/detail/${chrome.runtime.id}` : "https://github.com/aopell/SchoologyPlus/releases/latest"}">Schoology Plus v${chrome.runtime.getManifest().version_name || chrome.runtime.getManifest().version}${getBrowser() != "Chrome" || chrome.runtime.getManifest().update_url ? '' : ' dev'}</a> | <a href="https://aopell.github.io/SchoologyPlus/discord.html" title="Get support, report bugs, suggest features, and chat with the Schoology Plus community">Discord Support Server</a> | <a href="https://github.com/aopell/SchoologyPlus">GitHub</a> | <a href="#" id="open-contributors">Contributors</a> | <a href="#" id="open-changelog"> Changelog</a>`;
let modalFooterText = "Schoology Plus";

let frame = document.createElement("iframe");
frame.src = "https://aopell.me/SchoologyPlus/changelog";
frame.src = `https://aopell.me/SchoologyPlus/changelog?version=${chrome.runtime.getManifest().version}`;

let modals = [
new Modal(
Expand Down
24 changes: 17 additions & 7 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ var Logger = {
debug: (() => console.debug.bind(window.console, `%c+`, createLogPrefix("lightgreen")))(),
}

const assignmentNotificationUrl = "https://lms.lausd.net/home/notifications?filter=all";
var assignmentNotificationUrl = "https://lms.lausd.net/home/notifications?filter=all";
var defaultDomain = "lms.lausd.net";

chrome.storage.sync.get({ defaultDomain: "lms.lausd.net" }, s => {
defaultDomain = s.defaultDomain;
assignmentNotificationUrl = `https://${defaultDomain}/home/notifications?filter=all`;
});


Logger.log("Loaded event page");
Logger.log("Adding alarm listener");
Expand All @@ -45,11 +52,11 @@ chrome.notifications.onClicked.addListener(function (id) {
chrome.notifications.clear(id, null);
switch (id) {
case "assignment":
chrome.tabs.create({ url: "https://lms.lausd.net/home/notifications" }, null);
chrome.tabs.create({ url: `https://${defaultDomain}/home/notifications` }, null);
chrome.browserAction.setBadgeText({ text: "" });
break;
default:
chrome.tabs.create({ url: "https://lms.lausd.net" });
chrome.tabs.create({ url: `https://${defaultDomain}` });
break;
}
});
Expand All @@ -60,14 +67,14 @@ chrome.browserAction.onClicked.addListener(function () {
chrome.browserAction.getBadgeText({}, x => {
Logger.log(`Browser action text: "${x}"`);
let n = Number.parseInt(x);
if (n) chrome.tabs.create({ url: "https://lms.lausd.net/home/notifications" }, null);
else chrome.tabs.create({ url: "https://lms.lausd.net" }, null);
if (n) chrome.tabs.create({ url: `https://${defaultDomain}/home/notifications` }, null);
else chrome.tabs.create({ url: `https://${defaultDomain}` }, null);
chrome.browserAction.setBadgeText({ text: "" });
});
});
Logger.log("Adding cookie change listener");
chrome.cookies.onChanged.addListener(function (changeInfo) {
if (changeInfo.cookie.domain == ".lms.lausd.net" && changeInfo.cookie.name.startsWith("SESS")) {
if (changeInfo.cookie.domain == `.${defaultDomain}` && changeInfo.cookie.name.startsWith("SESS")) {
chrome.storage.sync.get({ sessionCookiePersist: "disabled" }, settings => {
let rewriteCookie = false;
if (settings.sessionCookiePersist == "enabled") {
Expand All @@ -88,7 +95,7 @@ chrome.cookies.onChanged.addListener(function (changeInfo) {
let expiryTime = new Date(new Date().setDate(new Date().getDate() + 60));

let cookie = changeInfo.cookie;
cookie.url = "https://lms.lausd.net/";
cookie.url = `https://${defaultDomain}/`;
delete cookie.session;
delete cookie.hostOnly;
cookie.expirationDate = expiryTime.getTime() / 1000;
Expand Down Expand Up @@ -149,6 +156,9 @@ chrome.runtime.onMessage.addListener(
})().then(x => sendResponse(x)).catch(err => sendResponse({ success: false, error: err }));

return true;
} else if (request.type == "updateDefaultDomain" && request.domain !== undefined) {
defaultDomain = request.domain;
assignmentNotificationUrl = `https://${defaultDomain}/home/notifications?filter=all`;
}
}
);
Expand Down
Loading

0 comments on commit eb7e23b

Please sign in to comment.