Skip to content

Commit b7a48db

Browse files
committed
Prepare first stable release
Fix bug whereby extension does not refresh blocked sites immediately after profile Added or removed. Also added 1 second delay in SetBlockedSitesLoop in case of rounding problems.
1 parent a5b7de7 commit b7a48db

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Project Ignite
22
Project Ignite is a new Device Manager Application (DMA) for schools developed after [Mobile Guardian was hacked](https://www.channelnewsasia.com/singapore/mobile-guardian-application-remove-cybersecurity-incident-moe-4526676).
33
<br>
4-
Project Ignite focuses on ensuring the **Security** and **Privacy** of students as well as being as **Fail-Proof** as possible. The chrome extension for students is **designed to work even if the server goes offline** after it has been properly set up. Moreover, the chrome extension does not collect any data from students' devices (as of version 0.1).
4+
Project Ignite focuses on ensuring the **Security** and **Privacy** of students as well as being as **Fail-Proof** as possible. The chrome extension for students is **designed to work even if the server goes offline** after it has been properly set up. Moreover, the chrome extension does not collect any data from students' devices (as of version 0.1.0).
55
<br>
6-
The first version of this application was made in less than 3 days and is currently under testing.
6+
The first version unstable of this application was made in less than 3 days.
77
<br><br>
8-
I believe that Singapore needs our own solution for a DMA to accommodate for the various needs of students and teachers. In the future, Project Ignite be more than just a DMA. It will be an all in one software to help teachers facilitate learning through various tools and feature that will keep student intrigued to learning. These features will be synced to the complex timetable schools in Singapore have. It will also come with software to help schools create these complex timetables.
8+
I believe that Singapore needs our own solution for a DMA to accommodate for the various needs of students and teachers. In the future, Project Ignite be more than just a DMA. It will be an all in one software to help teachers facilitate learning through various tools and features that will keep students intrigued to conducted lessons. These features will be synced to the complex timetable schools in Singapore have. It will also come with software to help schools create these complex timetables.
99
<br>
1010
Thus, I plan to further develop this project after my GCE O'Level examinations.<br>
1111
<br>
12-
The server is based off a past project which is based off a tutorial found [here](https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login).
12+
The server is originally based off a past project which is based off a tutorial found [here](https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login).
1313
<br>
1414
This project is made possible thanks to [Free DNS](https://freedns.afraid.org/).
1515

@@ -44,16 +44,16 @@ This full stack application does not collect any personal data nor does it have
4444
- **Future Goals**
4545
- Timetable generation and ability to sync with "Live class" system
4646
- iPad and Windows Client for students using these devices
47-
- Point system linked to "Live Polls". Points can be used in...
47+
- Point system linked to "Live Polls". Points can be used to claim...
4848

4949

5050
## Important Notes
51-
1. **THERE IS A LIMIT OF 5,000 BLOCKED SITES PER STUDENT** due to the usage of `declarativeNetRequest`. As stated in the [documentation](https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest#dynamic-rules):
52-
> An extension can have at least 5000 dynamic rules. This is exposed as the `MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES`.
51+
1. **THERE IS A LIMIT OF 5,000 BLOCKED SITES PER STUDENT** due to the usage of `declarativeNetRequest`. As stated in Chrome's [documentation](https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest#dynamic-rules):
52+
> An extension can have at least 5000 dynamic rules. This is exposed as the `MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES`.
5353
5454
2. The extension checks for updates from the profile every 30 seconds. You can force a refresh by pressing `Refresh Profile` in the options page.
5555

56-
3. **FOR ADMINISTRATORS:** When force installing the extension on students' devices, extension needs access to `file://` URLs and `Site Access` must be set to `On all sites` in order for the extensions to work properly. Please ensure you enforce this rule.<br>
56+
3. **FOR ADMINISTRATORS:** When force installing the extension on students' devices, extension needs access to file URLs and `Site Access` must be set to `On all sites` in order for the extensions to work properly. Please ensure you enforce this rule.<br>
5757
Even if you cannot enforce this setting, it will by default have access to all sites. A full screen popup will annoy students if they attempt to try to change the setting. The extension will also switch to `legacyWebBlocking` to stop students from visiting the blocked webpage should this popup fail to launch.
5858

5959

extension/background.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function areMapsEqual(map1, map2) {
2626

2727

2828
function checkProfileActive(data){
29+
// TODO: Check if it will work with overnight timing
2930
let d = new Date();
3031
if ((data.startHour == data.endHour) && (data.startMin == data.endMin) && (data.enforceDays.includes(d.getDay()))){
3132
return true;
@@ -35,6 +36,27 @@ function checkProfileActive(data){
3536
let secondsEndSince2400 = ((data.endHour*3600) + (data.endMin*60));
3637
return ((data.enforceDays.includes(d.getDay())) && ((secondsStartSince2400 <= secondsNowSince2400) && (secondsEndSince2400 > secondsNowSince2400)))
3738
}
39+
/*function checkProfileActive(enforceDays, enrollTime){
40+
let [startHour, startMin] = enrollTime.start.split(":");
41+
let [endHour, endMin] = enrollTime.end.split(":");
42+
let d = new Date();
43+
if (enforceDays.includes(d.getDay())){
44+
if (enrollTime.start == enrollTime.end){
45+
return true;
46+
}
47+
let secondsNowSince2400 = ((d.getHours()*3600) + (d.getMinutes()*60));
48+
let secondsStartSince2400 = ((startHour*3600) + (startMin*60));
49+
let secondsEndSince2400 = ((endHour*3600) + (endMin*60));
50+
if (secondsStartSince2400 >= secondsEndSince2400){
51+
secondsEndSince2400 += 86400;//Overnight profile. Add 24hrs
52+
}
53+
return ((secondsStartSince2400 <= secondsNowSince2400) && (secondsEndSince2400 > secondsNowSince2400))
54+
55+
}
56+
else {
57+
return false
58+
}
59+
}*/
3860

3961
function enforceBlockedSites(data){
4062
console.log("Enforcing new blockedSites");
@@ -116,7 +138,7 @@ function enforceBlockedSites(data){
116138
}
117139

118140
function setBlockedSites(){
119-
console.log("checking blocked sites changes")
141+
console.log("checking blocked sites changes");
120142
return getClasses().then((classList) => {
121143
let blockedSitesCache = new Map();
122144
let activeProfilesCache = new Map();
@@ -207,7 +229,7 @@ function syncProfiles(){
207229
function setBlockedSitesLoop(){
208230
return setBlockedSites().then(() => {
209231
let now = new Date();
210-
let delay = (60 - now.getSeconds()) * 1000;
232+
let delay = (61 - now.getSeconds()) * 1000;//Runs every minute + 1 second delay just in case
211233
return setTimeout(setBlockedSitesLoop,delay)
212234
});
213235
}
@@ -257,7 +279,13 @@ function relaunchEnforceWindow(windowId) {
257279
}
258280
function fulllscreenEnforceWindow(windowId){
259281
if (windowId === WindowTopRuleData.windowId) {
260-
return chrome.windows.update(windowId, { state: 'fullscreen'});
282+
try{
283+
return chrome.windows.update(windowId, { state: 'fullscreen'});
284+
}
285+
catch(err){
286+
//probably can't find the window
287+
console.log(err);
288+
}
261289
}
262290
}
263291
function relaunchClosedEnforceWindow(windowId) {
@@ -404,11 +432,15 @@ function checkPermissions() {
404432

405433

406434
export function addClass(className){
407-
return getUpdates(className);
435+
return getUpdates(className).then(setBlockedSites);
408436
}
409437

410-
export function removeClass(className){
411-
return chrome.storage.sync.remove(className);
438+
/*export function removeClass(className){
439+
return chrome.storage.sync.remove(className).then(setBlockedSites);
440+
}*/
441+
442+
export function removeClass(){
443+
return chrome.storage.sync.clear().then(setBlockedSites);
412444
}
413445

414446
export function getUpdateHost(){

extension/scripts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function masterPin(){
5151
document.getElementById("removeProfileBtn").classList.add("is-loading");
5252
fetch(updateHost+"/api/v0/masterPin",{cache: "no-cache", method:"post", headers: {'PIN': document.getElementById('maserPinInput').value}}).then((response) => {
5353
if (response.ok) {
54-
chrome.storage.sync.clear().then(()=>{
54+
removeClass().then(()=>{
5555
alert("REMOVAL PROCESS SUCCESS!");
5656
window.location.reload();
5757
});

0 commit comments

Comments
 (0)