mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
[CodeFactor] Apply fixes
This commit is contained in:
16 files changed
+25
-25
No files matched your search
+1
-1
@@ -50,7 +50,7 @@ function apiBase(): string {
|
||||
function reloadSeqtaPages() {
|
||||
const result = browser.tabs.query({});
|
||||
function open(tabs: any) {
|
||||
for (let tab of tabs) {
|
||||
for (const tab of tabs) {
|
||||
if (tab.title?.includes("SEQTA Learn") || tab.title?.includes("SEQTA Engage")) {
|
||||
browser.tabs.reload(tab.id);
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ const fetchAssessmentName = async (
|
||||
};
|
||||
|
||||
try {
|
||||
let payload = await fetchAssessments("/seqta/student/assessment/list/past");
|
||||
let title = searchAssessment(payload);
|
||||
const payload = await fetchAssessments("/seqta/student/assessment/list/past");
|
||||
const title = searchAssessment(payload);
|
||||
if (title) return title;
|
||||
|
||||
await delay(NOTIFICATIONS_RATE_LIMIT.baseDelay);
|
||||
|
||||
@@ -15,7 +15,7 @@ let vectorIndex: EmbeddingIndex | null = null;
|
||||
let isInitialized = false;
|
||||
let initializationFailed = false;
|
||||
let currentAbortController: AbortController | null = null;
|
||||
let loadedItemIds = new Set<string>();
|
||||
const loadedItemIds = new Set<string>();
|
||||
|
||||
function isFirefoxWorker(): boolean {
|
||||
try {
|
||||
|
||||
@@ -283,7 +283,7 @@ export function searchDynamicItems(
|
||||
|
||||
// For short queries, always do a simple substring match to supplement Fuse.js results
|
||||
// This ensures we catch partial word matches like "SAT" in "SAT 1: Differential Calculus"
|
||||
let additionalMatches: IndexItem[] = [];
|
||||
const additionalMatches: IndexItem[] = [];
|
||||
if (isShortQuery) {
|
||||
// Always do substring search for short queries to catch partial word matches
|
||||
for (const item of dynamicIdToItemMap.values()) {
|
||||
|
||||
@@ -158,7 +158,7 @@ function average(nums: number[]): number {
|
||||
|
||||
function slugSubjectKey(name: string, keyBySubject: Map<string, string>): string {
|
||||
if (keyBySubject.has(name)) return keyBySubject.get(name)!;
|
||||
let base =
|
||||
const base =
|
||||
name
|
||||
.trim()
|
||||
.replace(/[^\w]+/g, "_")
|
||||
|
||||
@@ -22,7 +22,7 @@ export function mergePayloadIntoRoster(
|
||||
const senderId = payload.sender.seqtaId;
|
||||
if (!allowedSeqtaIds.has(senderId)) return index;
|
||||
|
||||
let next: ClassRosterIndex = { ...index };
|
||||
const next: ClassRosterIndex = { ...index };
|
||||
const refs = classRefsFromTimetableItems(payload.classes);
|
||||
const updatedAt = Date.now();
|
||||
const member: RosterMember = {
|
||||
|
||||
@@ -879,7 +879,7 @@ export function AppendElementsToDisabledPage() {
|
||||
verboseInfo("[BetterSEQTA+] Appending elements to disabled page");
|
||||
AddBetterSEQTAElements();
|
||||
|
||||
let settingsStyle = document.createElement("style");
|
||||
const settingsStyle = document.createElement("style");
|
||||
settingsStyle.innerHTML = /* css */ `
|
||||
.addedButton {
|
||||
position: absolute !important;
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ function registerFetchSeqtaAppLinkListener() {
|
||||
});
|
||||
}
|
||||
|
||||
var IsSEQTAPage = false;
|
||||
let IsSEQTAPage = false;
|
||||
|
||||
/** Loaded on demand by SEQTA.ts for pages with the SEQTA copyright comment. */
|
||||
export function boot() {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function ColorLuminance(color: any, lum = 0) {
|
||||
if (color.toLowerCase().includes("gradient")) {
|
||||
let gradient = color;
|
||||
|
||||
let uniqueColorSet = new Set();
|
||||
const uniqueColorSet = new Set();
|
||||
|
||||
let match;
|
||||
while ((match = colorRegex.exec(color)) !== null) {
|
||||
@@ -31,7 +31,7 @@ export default function ColorLuminance(color: any, lum = 0) {
|
||||
}
|
||||
|
||||
// Adjust luminance for each unique color stop
|
||||
for (let colorStop of uniqueColorSet) {
|
||||
for (const colorStop of uniqueColorSet) {
|
||||
const adjustedColor = adjustLuminance(colorStop, lum);
|
||||
gradient = gradient.replace(new RegExp(colorStop as string, "gi"), adjustedColor);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ function applyColorsWith(selectedColor: string) {
|
||||
}
|
||||
}
|
||||
|
||||
let alliframes = document.getElementsByTagName("iframe");
|
||||
const alliframes = document.getElementsByTagName("iframe");
|
||||
|
||||
for (let i = 0; i < alliframes.length; i++) {
|
||||
const element = alliframes[i];
|
||||
|
||||
@@ -6,7 +6,7 @@ export function GetThresholdOfColor(color: any) {
|
||||
|
||||
// Check if the color string is a gradient (linear or radial)
|
||||
if (color.includes("gradient")) {
|
||||
let gradientThresholds = [];
|
||||
const gradientThresholds = [];
|
||||
|
||||
// Find and replace all instances of RGBA in the gradient
|
||||
let match;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CreateElement } from "@/seqta/utils/createEnable/CreateElement";
|
||||
|
||||
export function FilterUpcomingAssessments(subjectoptions: any) {
|
||||
for (const item in subjectoptions) {
|
||||
let subjectdivs = document.querySelectorAll(`[data-subject="${item}"]`);
|
||||
const subjectdivs = document.querySelectorAll(`[data-subject="${item}"]`);
|
||||
|
||||
for (let i = 0; i < subjectdivs.length; i++) {
|
||||
const element = subjectdivs[i];
|
||||
@@ -15,7 +15,7 @@ export function FilterUpcomingAssessments(subjectoptions: any) {
|
||||
}
|
||||
(element.parentNode! as HTMLElement).classList.remove("hidden");
|
||||
|
||||
let children = element.parentNode!.parentNode!.children;
|
||||
const children = element.parentNode!.parentNode!.children;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const element = children[i];
|
||||
if (element.hasAttribute("data-hidden")) {
|
||||
@@ -45,8 +45,8 @@ export function FilterUpcomingAssessments(subjectoptions: any) {
|
||||
}
|
||||
|
||||
function AddPlaceHolderToParent(parent: any, numberofassessments: any) {
|
||||
let textcontainer = CreateElement("div", "upcoming-blank");
|
||||
let textblank = CreateElement("p", "upcoming-hiddenassessment");
|
||||
const textcontainer = CreateElement("div", "upcoming-blank");
|
||||
const textblank = CreateElement("p", "upcoming-hiddenassessment");
|
||||
let s = "";
|
||||
if (numberofassessments > 1) {
|
||||
s = "s";
|
||||
|
||||
@@ -28,17 +28,17 @@ function createNewShortcut(link: any, icon: any, viewBox: any, title: any) {
|
||||
const container = document.getElementById("shortcuts");
|
||||
if (!container) return;
|
||||
|
||||
let shortcut = document.createElement("a");
|
||||
const shortcut = document.createElement("a");
|
||||
shortcut.setAttribute("href", link);
|
||||
shortcut.setAttribute("target", "_blank");
|
||||
let shortcutdiv = document.createElement("div");
|
||||
const shortcutdiv = document.createElement("div");
|
||||
shortcutdiv.classList.add("shortcut");
|
||||
|
||||
let image = stringToHTML(
|
||||
const image = stringToHTML(
|
||||
`<svg style="width:39px;height:39px" viewBox="${viewBox}"><path fill="currentColor" d="${icon}" /></svg>`,
|
||||
).firstChild;
|
||||
(image! as HTMLElement).classList.add("shortcuticondiv");
|
||||
let text = document.createElement("p");
|
||||
const text = document.createElement("p");
|
||||
text.textContent = title;
|
||||
shortcutdiv.append(image as HTMLElement);
|
||||
shortcutdiv.append(text);
|
||||
|
||||
@@ -222,7 +222,7 @@ export async function syncLessonsToCalendar(
|
||||
verboseLog(`[BetterSEQTA+] ${provider.label} remote event list failed:`, err);
|
||||
}
|
||||
|
||||
let staleEntries = entriesToPrune(
|
||||
const staleEntries = entriesToPrune(
|
||||
eventMap,
|
||||
request.origin,
|
||||
mode,
|
||||
|
||||
@@ -6,7 +6,7 @@ export function CreateElement(
|
||||
innerHTML?: string,
|
||||
style?: string,
|
||||
) {
|
||||
let element = document.createElement(type);
|
||||
const element = document.createElement(type);
|
||||
if (class_ !== undefined) {
|
||||
element.classList.add(class_);
|
||||
}
|
||||
|
||||
@@ -325,11 +325,11 @@ async function callHomeTimetable(date: string, change?: any) {
|
||||
|
||||
GetLessonColours().then((colours) => {
|
||||
for (let i = 0; i < lessonArray.length; i++) {
|
||||
let subjectname =
|
||||
const subjectname =
|
||||
lessonArray[i].type == "tutorial"
|
||||
? `timetable.tutor.${lessonArray[i].tutorID}`
|
||||
: `timetable.subject.colour.${lessonArray[i].code}`;
|
||||
let subject = colours.find((element: any) => element.name === subjectname);
|
||||
const subject = colours.find((element: any) => element.name === subjectname);
|
||||
|
||||
if (!subject) {
|
||||
lessonArray[i].colour = "--item-colour: #8e8e8e;";
|
||||
|
||||
Reference in new issue
Block a user