Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Intra 42, version 3 #15

Merged
merged 47 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
039c2be
add todo list
FreekBes Mar 26, 2022
79d38e8
version bump
FreekBes Mar 26, 2022
0d9d0a9
add minimum required browser versions
FreekBes Mar 26, 2022
fff9ef8
add intellisense for chrome extensions
FreekBes Mar 26, 2022
03ba476
not done, but important push
FreekBes Mar 26, 2022
0352b95
add to todo list
FreekBes Mar 26, 2022
f8d51c5
split up background script
FreekBes Mar 26, 2022
d40d0c3
now using new storage system & fix inject.js injected many times
FreekBes Mar 27, 2022
d80f6f6
bugfixes in options synchronization
FreekBes Mar 27, 2022
b5c6d3d
options page now listens to theme changes
FreekBes Mar 27, 2022
0151d27
bugfixes internal css
FreekBes Mar 27, 2022
1ffd8fc
move options page to server-side
FreekBes Mar 27, 2022
2a923f3
reorganized files and added console wrapper
FreekBes Mar 27, 2022
fd69894
var to let and const
FreekBes Mar 27, 2022
f36fc72
add sync.js to admin pages
FreekBes Mar 27, 2022
789262f
pre-release 1
FreekBes Mar 27, 2022
b8629cb
fix improvedStorage undefined
FreekBes Mar 27, 2022
13f1a83
fix automatic redirect not working
FreekBes Mar 28, 2022
57a5c32
font fixes
FreekBes Mar 28, 2022
8fbb6c6
add useful.js and font fixes
FreekBes Mar 28, 2022
0ae1e0b
fix flash of white when loading options page
FreekBes Mar 28, 2022
7450e17
theme fixes
FreekBes Mar 28, 2022
e98a72f
fix internal css issues
FreekBes Mar 28, 2022
10239ad
restructure javascript files
FreekBes Mar 28, 2022
fda9668
remove from todo list
FreekBes Mar 28, 2022
6902b4b
fix egg easter egg
FreekBes Mar 28, 2022
57381d0
add @IzaakVellinga sponsor title
FreekBes Mar 29, 2022
ce5ad70
Bugfix theming on notification list
FreekBes Apr 1, 2022
8c53518
Merge branch 'v3' of github.com:FreekBes/improved_intra into v3
FreekBes Apr 1, 2022
21ea2d8
fixed customized banners flashing in and out of existence
FreekBes Apr 1, 2022
fef11a0
remove dark intra reference
FreekBes Apr 4, 2022
e1cb6fa
add peer
FreekBes Apr 5, 2022
f1c1ef3
futura class font-family fix windows
FreekBes Apr 5, 2022
39a3816
add peer to tooltip and bg-images
FreekBes Apr 5, 2022
aeb6d3d
fixBlackHoleContainer no longer being called if no goals container
FreekBes Apr 5, 2022
a2a50dc
fix #8 (split up monit.js)
FreekBes Apr 5, 2022
bbddb1f
fix logtimes chart first month sometimes not displayed
FreekBes Apr 5, 2022
c699b03
add sum of monthly logtime
FreekBes Apr 5, 2022
280fcca
pre-release 2 of v3
FreekBes Apr 5, 2022
ebb3e40
add README to each server dir
FreekBes Apr 10, 2022
3d5f7ae
fix limited width of body on server pages
FreekBes Apr 10, 2022
1efd714
fixed security issue
FreekBes Apr 10, 2022
88b23fc
add README for server
FreekBes Apr 10, 2022
ad15d16
deleted todo-list
FreekBes Apr 10, 2022
ad85ba3
version bump
FreekBes Apr 10, 2022
7e938b7
Merge branch 'main' into v3
FreekBes Apr 10, 2022
1cd0223
remove custom titles from coalition scores page
FreekBes Apr 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
*.crx
server/nogit.php
server/test.php
server/settings/*
server/banners/*
server/db/*.json
server/settings/*.json
server/banners/*.jpeg
server/banners/*.png
server/banners/*.webp
server/banners/*.jpg
server/banners/*.bmp
server/banners/*.gif
server/banners/*.mp4
temp.js
201 changes: 0 additions & 201 deletions background.js

This file was deleted.

125 changes: 125 additions & 0 deletions background/comm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* comm.js :+: :+: */
/* +:+ */
/* By: fbes <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/03/26 23:57:53 by fbes #+# #+# */
/* Updated: 2022/03/26 23:57:53 by fbes ######## odam.nl */
/* */
/* ************************************************************************** */

const incognitoPortName = "incog_comm";
const normalPorts = [];
const incognitoPorts = [];

// message only ports in non-incognito context
function messageNormalPorts(msg) {
for (let i = 0; i < normalPorts.length; i++) {
normalPorts[i].postMessage(msg);
}
}

// message only ports in incognito context
function messageIncognitoPorts(msg) {
for (let i = 0; i < incognitoPorts.length; i++) {
incognitoPorts[i].postMessage(msg);
}
}

// message all ports
function messageAllPorts(msg) {
messageNormalPorts(msg);
messageIncognitoPorts(msg);
}

// message ports of specified type
function messagePortsOfType(type, msg) {
if (type == "incognito") {
messageIncognitoPorts(msg);
}
else {
messageNormalPorts(msg);
}
}

// detect if port is incognito or not
function isIncognitoPort(port) {
return (port.name == incognitoPortName);
}

// resync on port message function
function resyncOnPortMessage(incognitoSession) {
const type = (incognitoSession ? "incognito" : "normal");
const improvedStorage = (incognitoSession ? incognitoStorage : normalStorage);

improvedStorage.get("username").then(function(data) {
if (data["username"]) {
getSettingsFromSyncServer(improvedStorage, data["username"])
.then(function() {
iConsole.log("Settings successfully retrieved from server. Stored a copy locally in " + type + " storage.");
messagePortsOfType(type, { action: "resynced" });
})
.catch(function(err) {
iConsole.error(err);
resetOptions(improvedStorage).then(function() {
messagePortsOfType(type, { action: "resynced" });
});
});
}
else {
iConsole.warn("Could not resync, as no username was given to sync from");
}
});
}

// port message listener
function portMessageListener(msg, port) {
switch(msg["action"]) {
case "ping":
port.postMessage({ action: "pong" });
break;
case "resync":
resyncOnPortMessage(isIncognitoPort(port));
break;
case "options-changed":
if (isIncognitoPort(port)) {
messageIncognitoPorts({ action: "options-changed", settings: msg["settings"] });
}
else {
messageNormalPorts({ action: "options-changed", settings: msg["settings"] })
}
break;
default:
iConsole.log("Unknown action received over port: ", msg["action"]);
break;
}
}

chrome.runtime.onConnect.addListener(function(port) {
// add port to array of ports depending on the name
if (port.name == incognitoPortName) {
incognitoPorts.push(port);
}
else {
normalPorts.push(port);
}

// remove port from array of ports on closure
port.onDisconnect.addListener(function(port) {
const normalIndex = normalPorts.indexOf(port);
const incognitoIndex = incognitoPorts.indexOf(port);

if (incognitoIndex > -1) {
incognitoPorts.splice(incognitoIndex, 1);
}
else if (normalIndex > -1) {
normalPorts.splice(normalIndex, 1);
}
});

// run specific functions on specific messages
// basically treating messages as commands
port.onMessage.addListener(portMessageListener);
});
31 changes: 31 additions & 0 deletions background/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* main.js :+: :+: */
/* +:+ */
/* By: fbes <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/03/26 23:54:09 by fbes #+# #+# */
/* Updated: 2022/03/26 23:54:09 by fbes ######## odam.nl */
/* */
/* ************************************************************************** */

function resyncOptions() {
setOptionsIfUnset(normalStorage);
setOptionsIfUnset(incognitoStorage);
fetchUserSettings(normalStorage);
}

chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == "install") {
iConsole.log("First install.");
resyncOptions();
}
else if (details.reason == "update") {
iConsole.log("An update has been installed.");
resetLastSyncTimestamp(normalStorage);
resetLastSyncTimestamp(incognitoStorage);
removeUnusedOptions();
resyncOptions();
}
});
Loading