please God help

This commit is contained in:
Crazypersonalph
2023-12-04 18:41:19 +08:00
parent 35bad217b4
commit 178644f92f
4 changed files with 47 additions and 32 deletions
+1
View File
@@ -31,6 +31,7 @@
},
"dependencies": {
"@types/color": "^3.0.4",
"@types/dompurify": "^3.0.5",
"@types/react": "^18.2.21",
"@types/sortablejs": "^1.15.7",
"@types/webextension-polyfill": "^0.10.7",
+13
View File
@@ -8,6 +8,9 @@ dependencies:
'@types/color':
specifier: ^3.0.4
version: 3.0.6
'@types/dompurify':
specifier: ^3.0.5
version: 3.0.5
'@types/react':
specifier: ^18.2.21
version: 18.2.40
@@ -323,6 +326,12 @@ packages:
'@types/color-convert': 2.0.3
dev: false
/@types/dompurify@3.0.5:
resolution: {integrity: sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==}
dependencies:
'@types/trusted-types': 2.0.7
dev: false
/@types/eslint-scope@3.7.7:
resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==}
dependencies:
@@ -382,6 +391,10 @@ packages:
resolution: {integrity: sha512-PvgWCx1Lbgm88FdQ6S7OGvLIjWS66mudKPlfdrWil0TjsO5zmoZmzoKiiwRShs1dwPgrlkr0N4ewuy0/+QUXYQ==}
dev: false
/@types/trusted-types@2.0.7:
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
dev: false
/@types/webextension-polyfill@0.10.7:
resolution: {integrity: sha512-10ql7A0qzBmFB+F+qAke/nP1PIonS0TXZAOMVOxEUsm+lGSW6uwVcISFNa0I4Oyj0884TZVWGGMIWeXOVSNFHw==}
dev: false
+32 -31
View File
@@ -1197,7 +1197,7 @@ async function AddBetterSEQTAElements(toggle: any) {
// Load darkmode state
const result1 = browser.storage.local.get(['DarkMode'])
function open (result) {
function open (result: any) {
DarkMode = result.DarkMode;
}
result1.then(open, onError)
@@ -1205,12 +1205,12 @@ async function AddBetterSEQTAElements(toggle: any) {
var titlebar = document.createElement('div');
titlebar.classList.add('titlebar');
let container = document.getElementById('content');
container.append(titlebar);
container!.append(titlebar);
var NewButtonStr = '<li class="item" data-key="home" id="homebutton" data-path="/home" data-betterseqta="true"><label><svg style="width:24px;height:24px" viewBox="0 0 24 24"><path fill="currentColor" d="M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z" /></svg><span>Home</span></label></li>';
var NewButton = stringToHTML(NewButtonStr);
var menu = document.getElementById('menu');
var List = menu.firstChild;
List.insertBefore(NewButton.firstChild, List.firstChild);
var List = menu!.firstChild;
List!.insertBefore((NewButton.firstChild!), List!.firstChild);
fetch(`${location.origin}/seqta/student/login`, {
method: 'POST',
@@ -1231,16 +1231,16 @@ async function AddBetterSEQTAElements(toggle: any) {
titlebar.append(
stringToHTML(
'<div class="userInfosvgdiv tooltip"><svg class="userInfosvg" viewBox="0 0 24 24"><path fill="var(--text-primary)" d="M12,19.2C9.5,19.2 7.29,17.92 6,16C6.03,14 10,12.9 12,12.9C14,12.9 17.97,14 18,16C16.71,17.92 14.5,19.2 12,19.2M12,5A3,3 0 0,1 15,8A3,3 0 0,1 12,11A3,3 0 0,1 9,8A3,3 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z"></path></svg><div class="tooltiptext topmenutooltip" id="logouttooltip"></div></div>',
).firstChild,
).firstChild!,
);
var userinfostr = `<div class="userInfo"><div class="userInfoText"><div style="display: flex; align-items: center;"><p class="userInfohouse userInfoCode"></p><p class="userInfoName">${info.userDesc}</p></div><p class="userInfoCode">${UserInitalCode}</p></div></div>`;
var userinfo = stringToHTML(userinfostr).firstChild;
titlebar.append(userinfo);
titlebar.append(userinfo!);
var logoutbutton = document.getElementsByClassName('logout')[0];
var userInfosvgdiv = document.getElementById('logouttooltip');
userInfosvgdiv.appendChild(logoutbutton);
userInfosvgdiv!.appendChild(logoutbutton);
fetch(`${location.origin}/seqta/student/load/message/people`, {
method: 'POST',
@@ -1252,15 +1252,16 @@ async function AddBetterSEQTAElements(toggle: any) {
.then((result) => result.json())
.then((response) => {
let students = response.payload;
var index = students.findIndex(function (person) {
var index = students.findIndex(function (person: any) {
return (
person.firstname == info.userDesc.split(' ')[0] &&
person.surname == info.userDesc.split(' ')[1]
);
});
let houseelement =
let houseelement1 =
document.getElementsByClassName('userInfohouse')[0];
const houseelement = houseelement1 as HTMLElement
if (students[index]?.house) {
houseelement.style.background = students[index].house_colour;
try {
@@ -1288,7 +1289,7 @@ async function AddBetterSEQTAElements(toggle: any) {
var NewsButtonStr = '<li class="item" data-key="news" id="newsbutton" data-path="/news" data-betterseqta="true"><label><svg style="width:24px;height:24px" viewBox="0 0 24 24"><path fill="currentColor" d="M20 3H4C2.89 3 2 3.89 2 5V19C2 20.11 2.89 21 4 21H20C21.11 21 22 20.11 22 19V5C22 3.89 21.11 3 20 3M5 7H10V13H5V7M19 17H5V15H19V17M19 13H12V11H19V13M19 9H12V7H19V9Z" /></svg>News</label></li>';
var NewsButton = stringToHTML(NewsButtonStr);
List.appendChild(NewsButton.firstChild);
List!.appendChild(NewsButton.firstChild!);
editmenu = document.createElement('div');
editmenu.classList.add('editmenu');
@@ -1296,33 +1297,33 @@ async function AddBetterSEQTAElements(toggle: any) {
let svg = stringToHTML(
'<svg style="width:24px;height:24px;padding:5px;" id="editmenu" viewBox="0 0 24 24"><path fill="currentColor" d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" /></svg>',
);
editmenu.append(svg.firstChild);
editmenu.append(svg.firstChild!);
menu.appendChild(editmenu);
menu!.appendChild(editmenu);
let a = document.createElement('div');
a.classList.add('icon-cover');
a.id = 'icon-cover';
menu.appendChild(a);
menu!.appendChild(a);
var editmenu = document.querySelector('#editmenu');
editmenu.addEventListener('click', function () {
editmenu!.addEventListener('click', function () {
if (!MenuOptionsOpen) {
OpenMenuOptions();
}
});
var menuCover = document.querySelector('#icon-cover');
menuCover.addEventListener('click', function () {
menuCover!.addEventListener('click', function () {
location.href = '../#?page=/home';
SendHomePage();
document
.getElementById('menu')
.firstChild.classList.remove('noscroll');
(document!
.getElementById('menu')!
.firstChild! as HTMLElement).classList.remove('noscroll');
});
// Creates the home container when the menu button is pressed
var homebutton = document.getElementById('homebutton');
homebutton.addEventListener('click', function () {
homebutton!.addEventListener('click', function () {
if (!MenuOptionsOpen) {
SendHomePage();
}
@@ -1330,7 +1331,7 @@ async function AddBetterSEQTAElements(toggle: any) {
// Creates the news container when the menu button is pressed
var newsbutton = document.getElementById('newsbutton');
newsbutton.addEventListener('click', function () {
newsbutton!.addEventListener('click', function () {
if (!MenuOptionsOpen) {
SendNewsPage();
}
@@ -1347,14 +1348,14 @@ async function AddBetterSEQTAElements(toggle: any) {
'<button class="addedButton tooltip" id="AddedSettings""><svg width="24" height="24" viewBox="0 0 24 24"><g><g><path d="M23.182,6.923c-.29,0-3.662,2.122-4.142,2.4l-2.8-1.555V4.511l4.257-2.456a.518.518,0,0,0,.233-.408.479.479,0,0,0-.233-.407,6.511,6.511,0,1,0-3.327,12.107,6.582,6.582,0,0,0,6.148-4.374,5.228,5.228,0,0,0,.333-1.542A.461.461,0,0,0,23.182,6.923Z"></path><path d="M9.73,10.418,7.376,12.883c-.01.01-.021.016-.03.025L1.158,19.1a2.682,2.682,0,1,0,3.793,3.793l4.583-4.582,0,0,4.1-4.005-.037-.037A9.094,9.094,0,0,1,9.73,10.418ZM3.053,21.888A.894.894,0,1,1,3.946,21,.893.893,0,0,1,3.053,21.888Z"></path></g></g></svg><div class="tooltiptext topmenutooltip">BetterSEQTA+ Settings</div></button>',
);
var ContentDiv = document.getElementById('content');
ContentDiv.append(SettingsButton.firstChild);
ContentDiv!.append(SettingsButton.firstChild!);
const result = await new Promise(resolve => {
const result: any = await new Promise(resolve => {
const result = browser.storage.local.get();
result.then(resolve, onError)
});
const DarkMode = result.DarkMode;
const DarkMode = result!.DarkMode;
const tooltipString = GetLightDarkModeString(DarkMode);
const svgContent = DarkMode ? '<defs><clipPath id="__lottie_element_80"><rect width="24" height="24" x="0" y="0"></rect></clipPath></defs><g clip-path="url(#__lottie_element_80)"><g style="display: block;" transform="matrix(1,0,0,1,12,12)" opacity="1"><g opacity="1" transform="matrix(1,0,0,1,0,0)"><path fill-opacity="1" d=" M0,-4 C-2.2100000381469727,-4 -4,-2.2100000381469727 -4,0 C-4,2.2100000381469727 -2.2100000381469727,4 0,4 C2.2100000381469727,4 4,2.2100000381469727 4,0 C4,-2.2100000381469727 2.2100000381469727,-4 0,-4z"></path></g></g><g style="display: block;" transform="matrix(1,0,0,1,12,12)" opacity="1"><g opacity="1" transform="matrix(1,0,0,1,0,0)"><path fill-opacity="1" d=" M0,6 C-3.309999942779541,6 -6,3.309999942779541 -6,0 C-6,-3.309999942779541 -3.309999942779541,-6 0,-6 C3.309999942779541,-6 6,-3.309999942779541 6,0 C6,3.309999942779541 3.309999942779541,6 0,6z M8,-3.309999942779541 C8,-3.309999942779541 8,-8 8,-8 C8,-8 3.309999942779541,-8 3.309999942779541,-8 C3.309999942779541,-8 0,-11.3100004196167 0,-11.3100004196167 C0,-11.3100004196167 -3.309999942779541,-8 -3.309999942779541,-8 C-3.309999942779541,-8 -8,-8 -8,-8 C-8,-8 -8,-3.309999942779541 -8,-3.309999942779541 C-8,-3.309999942779541 -11.3100004196167,0 -11.3100004196167,0 C-11.3100004196167,0 -8,3.309999942779541 -8,3.309999942779541 C-8,3.309999942779541 -8,8 -8,8 C-8,8 -3.309999942779541,8 -3.309999942779541,8 C-3.309999942779541,8 0,11.3100004196167 0,11.3100004196167 C0,11.3100004196167 3.309999942779541,8 3.309999942779541,8 C3.309999942779541,8 8,8 8,8 C8,8 8,3.309999942779541 8,3.309999942779541 C8,3.309999942779541 11.3100004196167,0 11.3100004196167,0 C11.3100004196167,0 8,-3.309999942779541 8,-3.309999942779541z"></path></g></g></g>' :
'<defs><clipPath id="__lottie_element_263"><rect width="24" height="24" x="0" y="0"></rect></clipPath></defs><g clip-path="url(#__lottie_element_263)"><g style="display: block;" transform="matrix(1.5,0,0,1.5,7,12)" opacity="1"><g opacity="1" transform="matrix(1,0,0,1,0,0)"><path fill-opacity="1" d=" M0,-4 C-2.2100000381469727,-4 -1.2920000553131104,-2.2100000381469727 -1.2920000553131104,0 C-1.2920000553131104,2.2100000381469727 -2.2100000381469727,4 0,4 C2.2100000381469727,4 4,2.2100000381469727 4,0 C4,-2.2100000381469727 2.2100000381469727,-4 0,-4z"></path></g></g><g style="display: block;" transform="matrix(-1,0,0,-1,12,12)" opacity="1"><g opacity="1" transform="matrix(1,0,0,1,0,0)"><path fill-opacity="1" d=" M0,6 C-3.309999942779541,6 -6,3.309999942779541 -6,0 C-6,-3.309999942779541 -3.309999942779541,-6 0,-6 C3.309999942779541,-6 6,-3.309999942779541 6,0 C6,3.309999942779541 3.309999942779541,6 0,6z M8,-3.309999942779541 C8,-3.309999942779541 8,-8 8,-8 C8,-8 3.309999942779541,-8 3.309999942779541,-8 C3.309999942779541,-8 0,-11.3100004196167 0,-11.3100004196167 C0,-11.3100004196167 -3.309999942779541,-8 -3.309999942779541,-8 C-3.309999942779541,-8 -8,-8 -8,-8 C-8,-8 -8,-3.309999942779541 -8,-3.309999942779541 C-8,-3.309999942779541 -11.3100004196167,0 -11.3100004196167,0 C-11.3100004196167,0 -8,3.309999942779541 -8,3.309999942779541 C-8,3.309999942779541 -8,8 -8,8 C-8,8 -3.309999942779541,8 -3.309999942779541,8 C-3.309999942779541,8 0,11.3100004196167 0,11.3100004196167 C0,11.3100004196167 3.309999942779541,8 3.309999942779541,8 C3.309999942779541,8 8,8 8,8 C8,8 8,3.309999942779541 8,3.309999942779541 C8,3.309999942779541 11.3100004196167,0 11.3100004196167,0 C11.3100004196167,0 8,-3.309999942779541 8,-3.309999942779541z"></path></g></g></g>';
@@ -1366,34 +1367,34 @@ async function AddBetterSEQTAElements(toggle: any) {
</button>
`);
ContentDiv.append(LightDarkModeButton.firstChild);
ContentDiv!.append(LightDarkModeButton.firstChild!);
updateAllColors(DarkMode, result.selectedColor);
document.getElementById('LightDarkModeButton').addEventListener('click', async () => {
const result = await new Promise(resolve => {
document.getElementById('LightDarkModeButton')!.addEventListener('click', async () => {
const result: any = await new Promise(resolve => {
const result = browser.storage.local.get();
result.then(resolve, onError)
});
const newDarkMode = !result.DarkMode;
const newDarkMode = !result!.DarkMode;
browser.storage.local.set({ DarkMode: newDarkMode });
updateAllColors(newDarkMode, result.selectedColor);
const darklightText = document.getElementById('darklighttooliptext');
darklightText.innerText = GetLightDarkModeString(newDarkMode);
darklightText!.innerText = GetLightDarkModeString(newDarkMode);
});
// Locate the menuToggle element
const menuToggle = document.getElementById('menuToggle');
menuToggle.innerHTML = '';
menuToggle!.innerHTML = '';
// Create three divs to act as lines of the hamburger icon
for (let i = 0; i < 3; i++) {
const line = document.createElement('div');
line.className = 'hamburger-line';
menuToggle.appendChild(line);
menuToggle!.appendChild(line);
}
} else {
// Creates settings and dashboard buttons next to alerts
@@ -1401,7 +1402,7 @@ async function AddBetterSEQTAElements(toggle: any) {
'<button class="addedButton" id="AddedSettings""><svg width="24" height="24" viewBox="0 0 24 24"><g style="fill: var(--text-color);"><g><path d="M23.182,6.923c-.29,0-3.662,2.122-4.142,2.4l-2.8-1.555V4.511l4.257-2.456a.518.518,0,0,0,.233-.408.479.479,0,0,0-.233-.407,6.511,6.511,0,1,0-3.327,12.107,6.582,6.582,0,0,0,6.148-4.374,5.228,5.228,0,0,0,.333-1.542A.461.461,0,0,0,23.182,6.923Z"></path><path d="M9.73,10.418,7.376,12.883c-.01.01-.021.016-.03.025L1.158,19.1a2.682,2.682,0,1,0,3.793,3.793l4.583-4.582,0,0,4.1-4.005-.037-.037A9.094,9.094,0,0,1,9.73,10.418ZM3.053,21.888A.894.894,0,1,1,3.946,21,.893.893,0,0,1,3.053,21.888Z"></path></g></g></svg></button>',
);
ContentDiv = document.getElementById('content');
ContentDiv.append(SettingsButton.firstChild);
ContentDiv!.append(SettingsButton.firstChild!);
}
var AddedSettings = document.getElementById('AddedSettings');
+1 -1
View File
@@ -1,6 +1,6 @@
import DOMPurify from 'dompurify';
export default function stringToHTML(str, styles = false) {
export default function stringToHTML(str: string, styles = false) {
var parser = new DOMParser();
str = DOMPurify.sanitize(str, { ADD_ATTR: ['onclick'] });
var doc = parser.parseFromString(str, 'text/html');