-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from docentYT/development
v4.0.0
- Loading branch information
Showing
20 changed files
with
505 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node | ||
{ | ||
"name": "Node.js", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-18-bookworm", | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "npm install" | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [4.0.0] - 2023-10-16 | ||
|
||
### Added | ||
|
||
- Settings caching to display the average faster. | ||
- Dev container for contributors. | ||
|
||
### Fixed | ||
- NaN average if the only assessments were non-numerical. | ||
|
||
### Changed | ||
|
||
- Settings UI. | ||
- Many functions were rewritten from scratch. | ||
- Readme file. | ||
|
||
### Removed | ||
|
||
- Console logs. | ||
- Unused css styling. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,2 @@ | ||
const filter = { | ||
url: [ | ||
{ | ||
urlMatches: "https://synergia.librus.pl/przegladaj_plan_lekcji" | ||
}, | ||
{ | ||
urlMatches: "http://synergia.librus.pl/przegladaj_plan_lekcji" | ||
}, | ||
], | ||
}; | ||
|
||
chrome.webNavigation.onCreatedNavigationTarget.addListener(async (details) => { | ||
let nextWeekAtWeekend; | ||
await chrome.storage.sync.get(["nextWeekAtWeekend"]).then((result) => {nextWeekAtWeekend = result.nextWeekAtWeekend ?? true}); | ||
if (!nextWeekAtWeekend) return; | ||
chrome.scripting.executeScript({ | ||
target: { tabId: details.tabId }, | ||
files: ["przegladaj_plan_lekcji.inject-script.js"], | ||
world: "MAIN" | ||
}); | ||
}, filter); | ||
import "./src/background/messageHandler" | ||
import "./src/background/przegladaj_plan_lekcji_injector" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"use strict"; | ||
import storage from "./Storage"; | ||
|
||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { | ||
if (request.message == "saveSettings") { | ||
storage.save(request.body); | ||
} | ||
else if (request.message == "getSetting") { | ||
(async () => { | ||
sendResponse(await storage.get(request.key)); | ||
})(); | ||
return true; | ||
} | ||
}) |
20 changes: 20 additions & 0 deletions
20
extensions/combined/src/background/przegladaj_plan_lekcji_injector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"use strict"; | ||
import storage from "./Storage"; | ||
|
||
const filter = { | ||
url: [ | ||
{ | ||
hostSuffix: "synergia.librus.pl", | ||
pathPrefix: "/przegladaj_plan_lekcji" | ||
} | ||
], | ||
}; | ||
|
||
chrome.webNavigation.onCreatedNavigationTarget.addListener(async (details) => { | ||
if (!await storage.get("nextWeekAtWeekend")) return; | ||
chrome.scripting.executeScript({ | ||
target: { tabId: details.tabId }, | ||
files: ["przegladaj_plan_lekcji.inject-script.js"], | ||
world: "MAIN" | ||
}); | ||
}, filter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"use strict"; | ||
// https://stackoverflow.com/questions/1479319/simplest-cleanest-way-to-implement-a-singleton-in-javascript | ||
let storage = (function () { | ||
// Private methods | ||
const corrrectSettingsObject = { | ||
plus: 0.5, | ||
minus: 0.25, | ||
tylkoLiczDoSredniej: true, | ||
schowajZachowanie: true, | ||
ignoreCorrectedGrades: true, | ||
nextWeekAtWeekend: true | ||
}; | ||
const correctSettingsObjectLength = Object.keys(corrrectSettingsObject).length; | ||
|
||
let cache = {}; | ||
|
||
function checkSettingsObject(settingsObject) { | ||
let settingsObjectLength = Object.keys(settingsObject).length; | ||
if (settingsObjectLength != correctSettingsObjectLength) { | ||
throw new Error(`Settings object length is ${settingsObjectLength}. Expected ${correctSettingsObjectLength}`) | ||
} | ||
|
||
Object.keys(corrrectSettingsObject).forEach((property) => { | ||
if (!settingsObject.hasOwnProperty(property)) { | ||
throw new Error(`Settings object has no ${property} property.`) | ||
}; | ||
}) | ||
|
||
return true; | ||
} | ||
|
||
// Public methods | ||
return { | ||
save: function (settingsObject) { | ||
if (checkSettingsObject(settingsObject)) { | ||
chrome.storage.sync.set(settingsObject); | ||
cache = settingsObject; | ||
} else { | ||
throw new Error("Incorrect settings object"); | ||
} | ||
}, | ||
|
||
get: async function (key) { | ||
if (cache[key]) { | ||
return cache[key]; | ||
} else { | ||
await chrome.storage.sync.get([key]).then((result) => {cache[key] = result[key] ?? corrrectSettingsObject[key] }); | ||
return cache[key]; | ||
} | ||
} | ||
} | ||
}) | ||
|
||
Object.freeze(storage); | ||
|
||
module.exports = storage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
body { | ||
background-color: #282922; | ||
color: white; | ||
width: 300px; | ||
} | ||
|
||
table { | ||
border-collapse: collapse; | ||
font-size: 12px; | ||
} | ||
|
||
tr { | ||
border-bottom: 1px #a4c800 solid; | ||
} | ||
|
||
tr:last-child { | ||
border-bottom: none !important; | ||
} | ||
|
||
tr:hover { | ||
background-color: #303030; | ||
} | ||
|
||
tr:last-child:hover { | ||
background-color: #282922 !important; | ||
} | ||
|
||
input[type=number], input[type=submit] { | ||
background-color: #303030; | ||
color: white; | ||
border-radius: 5px; | ||
border: 1px #a4c800 solid; | ||
width: 50px; | ||
} | ||
|
||
input[type=submit]:hover { | ||
background-color: #a4c800; | ||
} | ||
|
||
input[type=submit] { | ||
margin-top: 5px; | ||
padding: 0px; | ||
height: 25px; | ||
cursor: pointer; | ||
} | ||
|
||
input[type=checkbox] { | ||
height: 25px; | ||
width: 25px; | ||
cursor: pointer; | ||
} | ||
|
||
/* unvisited and visited link */ | ||
a:link, a:visited { | ||
color: #a4c800; | ||
} | ||
|
||
a:hover, a:active { | ||
color: #e2fb72; | ||
} | ||
|
||
footer { | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
margin-top: 10px; | ||
} |
Oops, something went wrong.