cleaned up old stuff

unused stuff from bettercanvas live service and such
This commit is contained in:
Guy Sandler 2026-08-13 21:09:53 -07:00
parent cfd8a60f84
commit 0325b38a82
5 changed files with 4 additions and 959 deletions

View File

@ -29,7 +29,7 @@ a.option-container {display: block;color:#5ca5f6;font-size: 14px;}
a.option-container:hover {background: #333}
#customDomain {font-size: 12px; background: var(--inputbg); border: none;padding:8px;color: #e2e2e2;margin-top: 6px;border-radius: 7px; font-family: inherit;}
#customDomain {width: 100%; box-sizing: border-box}
#auto_dark_start, #auto_dark_end, #scheduledReminderTime {padding: 3px 5px; font-size:12px;background: var(--inputbg);color:#e2e2e2;border:none;border-radius: 7px;}
#auto_dark_start, #auto_dark_end {padding: 3px 5px; font-size:12px;background: var(--inputbg);color:#e2e2e2;border:none;border-radius: 7px;}
.options-left {margin-right: 8px;}
.options-left, .options-right {width: 50%;}
.customDomain {font-weight:600}

View File

@ -189,18 +189,6 @@
</div>
<span class="option-name" data-i18n="todo_remind">Todo Reminders</span>
</div>
<div class="sub-options">
<div class="sub-option" style="margin-top:5px">
<input type="checkbox" id="scheduledReminder" name="scheduledReminder">
<label for="scheduledReminder" class="sub-text">scheduled reminders</label>
</div>
<div class="timesets">
<div class="timeset">
<input type="time" id="scheduledReminderTime" step="60"></input>
<span class="sub-text" data-i18n="scheduledReminderTime">Show reminders at specific time</span>
</div>
</div>
</div>
</div>
</div>

View File

@ -90,8 +90,6 @@ chrome.runtime.onInstalled.addListener(function () {
"reminders": [],
"reminder_count": 1,
"multi_remind": false,
// "scheduledReminder": false,
// "scheduledReminderTime": { "hour": "09", "minute": "00" },
"id": "",
"new_browser": null,
"gpa_calc_cumulative": false,
@ -223,5 +221,3 @@ async function callNasaApi(dateStr) {
return await response.json().catch(() => null);
}
// chrome.runtime.setUninstallURL("https://diditupe.dev/canvasrefined/goodbye");

View File

@ -340,78 +340,11 @@ let timeCheck = null;
let reminderCheck = null;
let betterSidebarLoading = false;
let dashboardReadyTimer = null;
//let assignmentData = null;
/*
Start
*/
/*
// only works if a course has no quizzes...
function getClassAverages() {
if (true) { // check if option is enabled
let match = current_page.match(/courses\/(?<id>\d*)\/grades/);
if (match) {
let course_grades = getData(`${domain}/api/v1/courses/${match.groups.id}/assignments?include[]=score_statistics&include[]=submission`);
let course_quizzes = getData(`${domain}/api/v1/courses/${match.groups.id}/quizzes`);
let course_groups = getData(`${domain}/api/v1/courses/${match.groups.id}/assignment_groups`);
course_grades.then(grades => {
course_groups.then(groups => {
course_quizzes.then(quizzes => {
let total_weight = 0;
let total_points = 0;
let weights = {};
groups.forEach(group => {
weights[group.id] = group.group_weight;
total_weight += group.group_weight;
});
groups.forEach(group => {
weights[group.id] = total_weight === 0 ? 1 : weights[group.id] / total_weight;
});
let min = 0, lowq = 0, mean = 0, median = 0, upq = 0, max = 0, earned = 0;
grades.forEach(grade => {
if (!grade.score_statistics) return;
console.log("\nthis:", grade.name, grade.score_statistics.lower_q, grade.score_statistics.mean, grade.score_statistics.upper_q);
console.log("totals:", lowq, upq, total_points);
min += grade.score_statistics.min * weights[grade.assignment_group_id];
lowq += grade.score_statistics.lower_q * weights[grade.assignment_group_id];
mean += grade.score_statistics.mean * weights[grade.assignment_group_id];
median += grade.score_statistics.median * weights[grade.assignment_group_id];
upq += grade.score_statistics.upper_q * weights[grade.assignment_group_id];
max += grade.score_statistics.max * weights[grade.assignment_group_id];
total_points += grade.points_possible * weights[grade.assignment_group_id];
earned += grade.submission.score * weights[grade.assignment_group_id];
});
course_quizzes.forEach(quiz => {
// is it even possible to get quiz statistics?
});
// absolute minimum is if the same student got the lowest score on every assignment
// absolute maximum is if the same student got the highest score on every assignment
// it doesn't really tell you much because both are unlikely
console.log("\nabsolute minimum:", min / total_points, "\nabsolute maximum:", max / total_points, "\nlower quartile:", lowq / total_points, "\nmean:", mean / total_points, "\nupper quartile:", upq / total_points);
min = (min / total_points);
lowq = (lowq / total_points);
mean = (mean / total_points);
upq = (upq / total_points);
max = (max / total_points);
earned = (earned / total_points);
console.log(weights);
const width = 150;
let inner = `<td colspan="6" style="padding-bottom: 20px;"><table id="" class=""><thead><tr><th colspan="5">Class Averages</th><th></th></tr></thead><tbody><tr><td>Mean: ${(mean * 100).toFixed(2)}</td><td>Upper Quartile: ${(upq * 100).toFixed(2)}</td><td>Lower Quartile: ${(lowq * 100).toFixed(2)}</td><td colspan="3"><svg viewBox="-1 0 160 30" xmlns="http://www.w3.org/2000/svg" style="float: right; height: 30px; margin-20px; width: 161px; position: relative; margin-right: 30px;" aria-hidden="true"><line class="zero" x1="0" y1="3" x2="0" y2="27" stroke="#556572"></line><line class="possible" x1="150.0" y1="3" x2="150.0" y2="27" stroke="#556572"></line><line class="min" x1="${min * width}" y1="6" x2="${min * width}" y2="24" stroke="#556572" stroke-width="2"></line><line class="bottomQ" x1="${min * width}" y1="15" x2="${lowq * width}" y2="15" stroke="#556572" stroke-width="2"></line><line class="topQ" x1="${upq * width}" y1="15" x2="${max * width}" y2="15" stroke="#556572" stroke-width="2"></line><line class="max" x1="${max * width}" y1="6" x2="${max * width}" y2="24" stroke="#556572" stroke-width="2"></line><rect class="mid50" x="${lowq * width}" y="3" width="22.499999999999986" height="24" stroke="#556572" stroke-width="2" rx="3" fill="none"></rect><line class="median" x1="${mean * width}" y1="3" x2="${mean * width}" y2="27" stroke="#556572" stroke-width="2"></line><rect class="myScore" x="${(earned * width) - 7}" y="8" width="14" height="14" stroke="#224488" stroke-width="2" rx="3" fill="#aabbdd"></rect></svg></td></tr></tbody></table></td>`;
makeElement("tr", document.querySelector("#grades_summary tbody"), { "innerHTML": inner });
});
});
});
}
}
}
*/
/*
Todo Reminders
@ -521,38 +454,11 @@ function showExampleReminder() {
example.querySelector(".canvasrefined-reminder-due").textContent = "This notification will pop up in other pages to remind you of incomplete assignments that are due in less than 6 hours." /*It will notify again at 2 hours if the 'Remind 2x' option is on."*/;
}
// async function ScheduledReminderCheck() {
// let date = new Date();
// let currentHour = date.getHours();
// let currentMinute = date.getMinutes();
// if (options.scheduledReminderTime) {
// let [hour, minute] = options.scheduledReminderTime.split(":");
// if (parseInt(hour) == currentHour && parseInt(minute) == currentMinute) {
// const container = document.getElementById("canvasrefined-reminders") || makeElement("div", document.body, { "id": "canvasrefined-reminders" });
// container.style.display = "flex";
// container.textContent = "";
// const storage = await chrome.storage.sync.get("reminders");
// const now = (new Date()).getTime();
// storage["reminders"].forEach(reminder => {
// if (reminder.d >= now) {
// createReminder(reminder, container);
// }
// });
// }
// }
// }
// function toggleScheduledReminders() {
// clearInterval(reminderCheck);
// if (options.scheduledReminder !== true) return;
// ScheduledReminderCheck();
// reminderCheck = setInterval(ScheduledReminderCheck, 60000);
// }
isDomainCanvasPage();
function isDomainCanvasPage() {
chrome.storage.sync.get(['custom_domain', 'dark_mode', 'dark_preset', 'device_dark', 'remind'/*, 'scheduledReminder', 'scheduledReminderTime'*/], result => {
chrome.storage.sync.get(['custom_domain', 'dark_mode', 'dark_preset', 'device_dark', 'remind'], result => {
options = result;
if (result.custom_domain.length && result.custom_domain[0] !== "") {
for (let i = 0; i < result.custom_domain.length; i++) {
@ -565,15 +471,10 @@ function isDomainCanvasPage() {
// if the code reaches this point, its not a canvas page so run the reminders
setTimeout(reminderWatch, 2000);
setInterval(reminderWatch, 60000);
// toggleScheduledReminders();
// turn the reminders on/off if the option is changed
chrome.storage.onChanged.addListener((changes) => {
Object.keys(changes).forEach(key => {
if (key === "remind") reminderWatch();
if (key === "scheduledReminder" || key === "scheduledReminderTime") {
options[key] = changes[key].newValue;
// toggleScheduledReminders();
}
})
})
} else {
@ -617,7 +518,6 @@ function startExtension() {
watchSubmissionPageButton();
watchProfileLogoutPageButton();
//getClassAverages();
setTimeout(() => runDarkModeFixer(false), 800);
setTimeout(() => runDarkModeFixer(false), 4500);
@ -746,16 +646,9 @@ function applyOptionsChanges(changes) {
case "fitImageToScreen":
applyCustomBackground();
break;
// case "show_updates":
// showUpdateMsg();
// break;
case "remind":
showExampleReminder();
break;
// case "scheduledReminder":
// case "scheduledReminderTime":
// toggleScheduledReminders();
// break;
case "imageSize":
case "cardRoundness":
case "cardSpacing":
@ -1041,10 +934,6 @@ async function applyCustomBackground() {
document.documentElement.appendChild(style);
}
function clearCustomBackground() {
let style = document.querySelector("#canvasrefined-background");
if (style) style.remove();
}
function applyBetterSidebarLayoutFix() {
let style = document.querySelector("#canvasrefined-sidebar-layout-fix") || document.createElement("style");
@ -1171,11 +1060,6 @@ function inspectDarkMode(withOutput = false) {
const r = parseInt(bgcolor.groups["r"]);
const g = parseInt(bgcolor.groups["g"]);
const b = parseInt(bgcolor.groups["b"]);
/*
if (el.classList.contains("no-touch")) {
console.log({ "r": r, "g": g, "b": b }, { "r": r === bg0.r, "g": g === bg0.g, "b": b === bg0.b });
}
*/
if (r > 245 && g > 245 && b > 245 && !(r === bg0.r && g === bg0.g && b === bg0.b) && !(r === lnk.r && g === lnk.g && b === lnk.b)) {
el.style.cssText = (";background:" + options.dark_preset["background-0"] + "!important;color" + options.dark_preset["text-0"] + "!important;") + el.style.cssText;
if (withOutput === true) output += selector + "{background: background-0, color: text-0}\n";
@ -1374,123 +1258,6 @@ async function getCards(api = null) {
Better todo list
*/
// function setAssignmentState(id, updates) {
// let states = options.assignment_states;
// let length = JSON.stringify(states).length;
// // remove the oldest states if the size is approaching the storage limit
// if (length > 7400) {
// let keys = Object.keys(states).sort((a, b) => states[b].expire - states[a].expire);
// keys.splice(-5);
// let newStates = {};
// keys.forEach(key => {
// newStates[key] = states[key];
// });
// states = newStates;
// }
// states[id] = states[id] ? { ...states[id], ...updates } : updates;
// chrome.storage.sync.set({ assignment_states: states }).then(() => { cardAssignments = preloadAssignmentEls(); loadBetterTodo(); loadCardAssignments(); });
// }
function createTodoCreateBtn(location) {
let confirmButton = makeElement("button", location, { "className": "canvasrefined-custom-btn", "textContent": "Create" });
confirmButton.addEventListener("click", () => {
chrome.storage.sync.get("custom_assignments_overflow", overflow => {
chrome.storage.sync.get(overflow["custom_assignments_overflow"], storage => {
let course_id = parseInt(location.querySelector("#canvasrefined-custom-course").value);
const assignment = {
"plannable_id": new Date().getTime(),
"context_name": options.custom_cards[location.querySelector("#canvasrefined-custom-course").value].default,
"plannable": { "title": location.querySelector("#canvasrefined-custom-name").value },
"plannable_date": location.querySelector("#canvasrefined-custom-date").value + "T" + location.querySelector("#canvasrefined-custom-time").value + ":00",
"planner_override": { "marked_complete": false, "custom": true },
"plannable_type": "assignment",
"submissions": { "submitted": false },
"course_id": course_id,
"html_url": `/courses/${course_id}/assignments`
};
/* handling overflow since the limit is 8kb per key */
let found = false;
let reload = () => {
location.classList.toggle("canvasrefined-custom-open");
loadBetterTodo();
loadCardAssignments();
}
/* find the first available overflow with space */
/* or create a new one if all are full */
let findOpenOverflow = (num) => {
let current_overflow = overflow["custom_assignments_overflow"][num];
storage[current_overflow].push(assignment);
chrome.storage.sync.set({ [current_overflow]: storage[current_overflow] }, () => {
/* assuming any error is because the limit is exceeded */
if (chrome.runtime.lastError) {
if (num === overflow["custom_assignments_overflow"].length - 1) {
console.log("all overflows are full! creating new overflow " + (overflow["custom_assignments_overflow"].length + 1));
let new_overflow = "custom_assignments_" + (overflow["custom_assignments_overflow"].length + 1);
overflow["custom_assignments_overflow"].push(new_overflow);
chrome.storage.sync.set({ [new_overflow]: [assignment], "custom_assignments_overflow": overflow["custom_assignments_overflow"] }).then(reload);
} else {
console.log("overflow " + (num + 1) + " full...");
findOpenOverflow(num + 1);
}
} else {
console.log("overflow " + (num + 1) + " has space!");
reload();
}
});
}
findOpenOverflow(0);
});
})
});
}
// better todo html layer 1
// function createTodoHeader(location) {
// let todoHeader = makeElement("h2", location, { "className": "todo-list-header", "style": "display: flex; align-items:center; justify-content:space-between;" });
// //todoHeader.style = "display: flex; align-items:center; justify-content:space-between;";
// if (!options.custom_cards || Object.keys(options.custom_cards).length === 0) return;
// let addFillout = makeElement("div", location, { "className": "canvasrefined-add-assignment" });
// let now = new Date();
// let year = now.getFullYear();
// let month = now.getMonth() + 1;
// let day = now.getDate();
// month = month < 10 ? "0" + month : month;
// day = day < 10 ? "0" + day : day;
// addFillout.innerHTML = '<input type="text" placeholder="Name" id="canvasrefined-custom-name" class="canvasrefined-custom-input"></input><select id="canvasrefined-custom-course" class="canvasrefined-custom-input"><option value="" disabled selected>Select course</option></select><div style="display: flex;gap:5px"><input type="date" id="canvasrefined-custom-date" class="canvasrefined-custom-input"></input><input type="time" id="canvasrefined-custom-time" class="canvasrefined-custom-input" value="23:59"></input></div>';
// addFillout.querySelector("#canvasrefined-custom-date").value = year + "-" + month + "-" + day;
// let selectCourse = document.querySelector("#canvasrefined-custom-course");
// Object.keys(options.custom_cards).forEach(id => {
// let card = options.custom_cards[id];
// let courseName = makeElement("option", selectCourse, { "className": "canvasrefined-select-course-option", "textContent": card.default });
// courseName.value = id;
// });
// createTodoCreateBtn(addFillout);
// let headerText = makeElement("span", todoHeader, { "className": "canvasrefined-todo-header", "textContent": "To Do" });
// let addButton = makeElement("button", todoHeader, { "className": "canvasrefined-custom-btn", "textContent": "+ Add" });
// addButton.addEventListener("click", () => {
// addFillout.classList.toggle("canvasrefined-custom-open");
// });
// headerText.addEventListener("click", () => {
// if (filter === "todo") {
// filter = "done";
// headerText.textContent = "Done";
// } else {
// filter = "todo";
// headerText.textContent = "To Do";
// }
// moreAssignmentCount = 0;
// moreAnnouncementCount = 0;
// loadBetterTodo();
// });
// }
function convertToDueDate(dueAt) {
final = "due ";
@ -2918,20 +2685,6 @@ function updateSidebar(expanded, sidebarList, expander) {
}
}
}
function getCourseLinks() {
const linkList = document.getElementById("section-tabs");
if (!linkList) return [];
const links = linkList.querySelectorAll("a");
const courseLinks = [];
links.forEach(link => {
const url = new URL(link.href).pathname;
courseLinks.push({
name: link.textContent.trim(),
url: url
});
})
return courseLinks;
}
let delay;
let moreAssignmentCount = 0;
@ -3121,84 +2874,8 @@ async function loadBetterTodo() {
});
});
});
} /*else {
// set the item as complete through api
fetch(domain + '/api/v1/planner/overrides' + (item.planner_override ? "/" + item.planner_override.id : ""),
{
method: item.planner_override ? "PUT" : "POST",
headers: {
"content-type": "application/json",
'accept': 'application/json',
'X-CSRF-Token': csrfToken,
},
body: JSON.stringify({ id: item.planner_override ? item.planner_override.id : null, marked_complete: true, plannable_id: item.plannable_id, plannable_type: item.plannable_type })
}).then(resp => {
if (resp.status === 200 || resp.status === 201) {
let container = listItemContainer.parentElement;
container.removeChild(listItemContainer);
assignments.forEach(assignment => {
if (assignment.plannable_id === item.plannable_id) {
item.planner_override = { "marked_complete": true };
}
});
loadBetterTodo();
loadCardAssignments();
}
});
}*/
});
/*
// remove item button
listItemContainer.querySelector(".canvasrefined-todo-complete-btn").addEventListener('click', function () {
if (item.planner_override && item.planner_override.custom && item.planner_override.custom === true) {
// set item as complete locally
chrome.storage.sync.get("custom_assignments_overflow", overflow => {
chrome.storage.sync.get(overflow["custom_assignments_overflow"], storage => {
overflow["custom_assignments_overflow"].forEach(overflow => {
for (let i = 0; i < storage[overflow].length; i++) {
if (storage[overflow][i].plannable_id === item.plannable_id) {
storage[overflow].splice(i, 1);
chrome.storage.sync.set({ [overflow]: storage[overflow] }).then(() => {
let container = listItemContainer.parentElement;
container.removeChild(listItemContainer);
loadBetterTodo();
loadCardAssignments();
});
break;
}
}
});
});
});
} else {
// set the item as complete through api
fetch(domain + '/api/v1/planner/overrides' + (item.planner_override ? "/" + item.planner_override.id : ""),
{
method: item.planner_override ? "PUT" : "POST",
headers: {
"content-type": "application/json",
'accept': 'application/json',
'X-CSRF-Token': csrfToken,
},
body: JSON.stringify({ id: item.planner_override ? item.planner_override.id : null, marked_complete: true, plannable_id: item.plannable_id, plannable_type: item.plannable_type })
}).then(resp => {
if (resp.status === 200 || resp.status === 201) {
let container = listItemContainer.parentElement;
container.removeChild(listItemContainer);
assignmentData.forEach(assignment => {
if (assignment.plannable_id === item.plannable_id) {
item.planner_override = { "marked_complete": true };
}
});
loadBetterTodo();
loadCardAssignments();
}
});
}
});
*/
if (item.plannable_type === "announcement") {
announcementsToInsert.push(listItemContainer);
@ -3208,8 +2885,6 @@ async function loadBetterTodo() {
listItemContainer.classList.add("canvasrefined-todo-item-completed");
}
}
//}
//}
});
@ -3372,13 +3047,6 @@ function toggleDarkMode() {
style.textContent = options.dark_mode === true || options.device_dark ? css : "";
style.className = options.dark_mode === true || options.device_dark ? "canvasrefined-darkmode-enabled" : "";
}
/*
if (options.dark_mode === true || options.device_dark) {
document.body.classList.add("canvasrefined--darkmode--enabled");
} else {
document.body.classList.remove("canvasrefined--darkmode--enabled");
}
*/
runiframeChecker();
}
@ -3414,25 +3082,6 @@ function autoDarkModeCheck() {
}
}
// async function ScheduledReminderCheck() {
// let date = new Date();
// let currentHour = date.getHours();
// let currentMinute = date.getMinutes();
// if (options.scheduledReminderTime) {
// let [hour, minute] = options.scheduledReminderTime.split(":");
// if (parseInt(hour) == currentHour && parseInt(minute) == currentMinute) {
// const container = document.getElementById("canvasrefined-reminders") || makeElement("div", document.body, { "id": "canvasrefined-reminders" });
// container.style.display = "flex";
// container.textContent = "";
// const storage = await chrome.storage.sync.get("reminders");
// const now = (new Date()).getTime();
// storage["reminders"].forEach(reminder => {
// if (reminder.d >= now) {
// createReminder(reminder, container);
// }
// });
// }
// }
// }
@ -3443,12 +3092,6 @@ function toggleAutoDarkMode() {
timeCheck = setInterval(autoDarkModeCheck, 60000);
}
// function toggleScheduledReminders() {
// clearInterval(reminderCheck);
// if (options.scheduled_reminders === false) return; //TODO: add it to the options thing
// ScheduledReminderCheck();
// reminderCheck = setInterval(ScheduledReminderCheck, 60000);
// }
let iframeObserver;
function runiframeChecker() {
@ -3526,18 +3169,6 @@ function insertGrades() {
Card assignments
*/
/*
function setAssignmentStatus(id, status, assignments_done = []) {
if (assignments_done.length > 50) assignments_done = [];
if (status === true) {
assignments_done.push(id);
} else {
const pos = assignments_done.indexOf(id);
if (pos > -1) assignments_done.splice(pos, 1);
}
chrome.storage.sync.set({ assignments_done: assignments_done });
}
*/
function createCardAssignment(assignment) {
let assignmentContainer = document.createElement("div");
@ -3688,59 +3319,6 @@ function loadCardAssignments() {
});
}
/*
function loadCardAssignments2(c = null) {
if (options.assignments_due === true) {
try {
assignments.then(data => {
//assignmentData = assignmentData === null ? data : assignmentData; ????
let items = combineAssignments(data);
let cards = c ? c : document.querySelectorAll('.ic-DashboardCard');
const now = new Date();
cards.forEach(card => {
let count = 0;
let course_id = parseInt(card.querySelector(".ic-DashboardCard__link").href.split("courses/")[1]);
let cardContainer = card.querySelector('.canvasrefined-card-container');
cardContainer.textContent = "";
cardContainer.parentElement.style.display = "block";
items.forEach(assignment => {
let due = new Date(assignment.plannable_date);
// lots of checks to make
// 1. item belongs to card
// 2. haven't exceeded item limit
// 3. assignment hasn't been submitted (if hide completed option is on)
// 4. disallow overdue and item not past due/allow overdue and item hasn't been submitted
// 5. correct item type
// 6. no planner override marking item complete
if (course_id !== assignment.course_id) return;
if (count >= options.num_assignments) return;
if (options.hide_completed === true && assignment.submissions.submitted === true) return;
if ((options.card_overdues !== true && now >= due) || (options.card_overdues === true && assignment.submissions.submitted === true)) return;
if ((assignment.plannable_type !== "assignment" && assignment.plannable_type !== "quiz" && assignment.plannable_type !== "discussion_topic")) return;
if (assignment.planner_override && assignment.planner_override.marked_complete === true) return;
createCardAssignment(cardContainer, assignment, now >= due);
count++;
});
if (count === 0) {
let assignmentContainer = makeElement("div", "canvasrefined-assignment-container", cardContainer);
let assignmentDivLink = makeElement("a", "canvasrefined-assignment-link", assignmentContainer, "None");
}
});
});
} catch (e) {
logError(e);
}
} else {
document.querySelectorAll(".canvasrefined-card-assignment").forEach(card => {
card.style.display = "none";
});
}
}
*/
function setupCardAssignments() {
if (options.assignments_due !== true) return;
@ -3927,14 +3505,6 @@ function calculateGPA2() {
letter = "F";
gpa = options.gpa_calc_bounds["F"].gpa;
}
/*
if (course.id === "cumulative-gpa") {
//gpa = parseFloat(options["cumulative_gpa"]["gr"]);
gpa = 0;
cumulativePoints += parseFloat(options["cumulative_gpa"]["gr"]) * credits;
cumulativeCredits = credits;
} else {
*/
course.querySelector(".canvasrefined-gpa-letter-grade").textContent = letter;
let weightMultiplier = 0;
@ -3947,8 +3517,6 @@ function calculateGPA2() {
qualityPoints += gpa * credits;
weightedQualityPoints += (gpa + weightMultiplier) * credits;
numCredits += credits;
//}
});
@ -4489,16 +4057,6 @@ function applyAestheticChanges() {
document.documentElement.appendChild(style);
}
/*
function changeFullWidth() {
if (options.full_width == null) return;
if (options.full_width === true) {
document.body.classList.add("full-width");
} else {
document.body.classList.remove("full-width");
}
}
*/
function changeGradientCards() {
if (options.gradient_cards === true) {
@ -4684,14 +4242,6 @@ function makeElement(element, location, options, prepend = false) {
}
function makeElement2(element, elclass, location, text) {
let creation = document.createElement(element);
creation.classList.add(elclass);
creation.textContent = text;
location.appendChild(creation);
return creation
}
async function getData(url) {
let response = await fetch(url, {
method: 'GET',
@ -4704,10 +4254,6 @@ async function getData(url) {
return data
}
function hexToHsl(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return rgbToHsl(parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16));
}
function rgbToHex(rgb) {
try {
@ -4799,4 +4345,4 @@ function logError(e) {
const CSRFtoken = function () {
return decodeURIComponent((document.cookie.match('(^|;) *_csrf_token=([^;]*)') || '')[2])
}
}

View File

@ -20,8 +20,6 @@ const syncedSubOptions = [
// "hide_completed",
"num_todo_items",
"hover_preview",
// "scheduledReminder",
// "scheduledReminderTime",
"customCardStyles",
"imageSize",
"cardRoundness",
@ -38,8 +36,6 @@ const syncedSubOptions = [
const localSwitches = [];
const fontsDropdownStateKey = "fonts_dropdown_open";
//const apiurl = "http://localhost:3000";
// const apiurl = "https://canvasrefined.diditupe.dev";
const apiurl = "none";
const defaultOptions = {
@ -129,8 +125,6 @@ const defaultOptions = {
"card_method_date": false,
"card_method_dashboard": true,
"card_limit": 25,
// "scheduledReminder": false,
// "scheduledReminderTime": { "hour": "09", "minute": "00" },
"imageSize": 100,
"cardRoundness": 5,
"cardSpacing": 0,
@ -230,14 +224,6 @@ function setupAutoDarkInput(initial, time) {
});
}
// function setupScheduledReminderInput(initial) {
// let el = document.querySelector('#scheduledReminderTime');
// el.value = initial.hour + ":" + initial.minute;
// el.addEventListener('change', function () {
// let timeinput = { "hour": this.value.split(':')[0], "minute": this.value.split(':')[1] };
// chrome.storage.sync.set({ scheduledReminderTime: timeinput });
// });
// }
function setupCardLimitSlider(initial) {
let el = document.querySelector("#card_limit");
@ -756,7 +742,6 @@ function setup() {
"customBackgroundDaily",
"customBackgroundNasaDaily",
"fitImageToScreen",
// "scheduledReminder",
"customCardStyles",
],
tabs: {
@ -822,10 +807,6 @@ function setup() {
identifier: "custom_styles",
setup: (initial) => setupCustomStyle(initial),
},
// {
// identifier: "scheduledReminderTime",
// setup: (initial) => setupScheduledReminderInput(initial),
// },
{
identifier: "imageSize",
setup: (initial) => setupImageSizeInput(initial),
@ -910,12 +891,6 @@ function setup() {
document.querySelector("#" + option).checked = value;
});
syncCustomBackgroundDailyState(sync.customBackgroundDaily === true || sync.customBackgroundNasaDaily === true);
/*
document.querySelector('#autodark_start').value = result.auto_dark_start["hour"] + ":" + result.auto_dark_start["minute"];
document.querySelector('#autodark_end').value = result.auto_dark_end["hour"] + ":" + result.auto_dark_end["minute"];
document.querySelector("#assignment_date_format").checked = result.assignment_date_format == true;
document.querySelector("#todo_hr24").checked = result.todo_hr24 == true;
*/
toggleDarkModeDisable(sync.auto_dark);
displayBackgroundPresets();
});
@ -931,15 +906,6 @@ function setup() {
});
})
/*
// checkboxes
menu.checkboxes.forEach(checkbox => {
document.querySelector("#" + checkbox).addEventListener('change', function () {
let status = this.checked;
chrome.storage.sync.set(JSON.parse(`{"${checkbox}": ${status}}`));
});
});
*/
// activate tab buttons
document.querySelectorAll(".tab-btn").forEach(btn => {
@ -1044,7 +1010,6 @@ function setup() {
document.querySelectorAll(".export-details input").forEach(input => {
input.addEventListener("change", () => {
chrome.storage.sync.get(syncedSwitches.concat(syncedSubOptions).concat(["dark_preset", "custom_cards", "custom_font", "gpa_calc_bounds"]), async storage => {
//chrome.storage.local.get(["dark_preset"], async local => {
let final = {};
for await (item of document.querySelectorAll(".export-details input")) {
if (item.checked) {
@ -1077,7 +1042,6 @@ function setup() {
}
}
document.querySelector("#export-output").value = JSON.stringify(final);
//});
});
});
});
@ -1144,14 +1108,6 @@ function setup() {
})
});
/*
['autodark_start', 'autodark_end'].forEach(function (timeset) {
document.querySelector('#' + timeset).addEventListener('change', function () {
let timeinput = { "hour": this.value.split(':')[0], "minute": this.value.split(':')[1] };
timeset === "autodark_start" ? chrome.storage.sync.set({ auto_dark_start: timeinput }) : chrome.storage.sync.set({ auto_dark_end: timeinput });
});
});
*/
// activate sidebar tool radio
["#radio-sidebar-image", "#radio-sidebar-gradient", "#radio-sidebar-solid"].forEach(radio => {
@ -1180,8 +1136,6 @@ function setup() {
document.getElementById("theme-search").addEventListener("change", async (e) => {
searchFor = e.target.value;
console.log(searchFor);
// current_page_num = 1;
// displayThemeList(0);
// linear search
let themesToShow = [];
for (let i = 0; i < themes.length; i++) {
@ -1197,7 +1151,6 @@ function setup() {
document.getElementById("save-theme").addEventListener("click", saveCurrentTheme);
// activate submit theme button
// document.getElementById("submit-theme-btn").addEventListener("click", submitTheme);
document.getElementById("submit-theme-btn-1").addEventListener("click", () => {
document.getElementById("submit-popup").classList.add("open");
@ -1230,15 +1183,8 @@ function setup() {
});
// activate theme browser opt out
// document.getElementById("new_browser_out").addEventListener("click", () => {
chrome.storage.sync.set({ "new_browser": false });
current_page_num = 1;
displayThemeList(0);
// displayAlert(false, "Success! You are now viewing the old theme browser. This one will no longer recieve updates, but there is still plenty to choose from.");
// });
// activate theme browser opt in
// document.getElementById("new_browser_in").addEventListener("click", registerUser);
document.querySelectorAll(".theme-sort-btn").forEach(btn => {
btn.addEventListener("click", (e) => {
@ -1256,12 +1202,7 @@ function setup() {
document.getElementById("browser-settings-popup").classList.remove("open");
});
// document.getElementById("reset-optin").addEventListener("click", () => {
// chrome.storage.sync.set({ "new_browser": null });
// document.getElementById("opt-in").style.display = "block";
// });
// document.getElementById("view-submissions-btn").addEventListener("click", displayMySubmissions);
document.getElementById("submit-form-btn").addEventListener("click", displayThemeSubmissionForm);
document.getElementById("gpa-plus-minus").addEventListener("click", () => {
@ -1383,37 +1324,6 @@ function displayThemeSubmissionForm() {
document.getElementById("view-submissions-btn").classList.remove("active");
}
async function displayMySubmissions() { //TODO: remake
const sync = await chrome.storage.sync.get("id");
const res = await fetch(`${apiurl}/api/themes/submissions?id=${sync["id"]}`);
const data = await res.json();
//if (data?.errors !== false) return;
document.getElementById("submit-form").style.display = "none";
document.getElementById("view-submissions").style.display = "block";
document.getElementById("submit-form-btn").classList.remove("active");
document.getElementById("view-submissions-btn").classList.add("active");
const el = document.getElementById("latest-submissions");
el.textContent = "";
if (data.message.length === 0) {
el.textContent = "You haven't submitted any themes yet.";
}
data.message.forEach(theme => {
const container = makeElement("div", el, {"className": "submitted-theme" });
const btn = makeElement("button", container, { "className": "theme-button clickable customization-button", "style": `min-width:105px;max-width:105px;background-image:linear-gradient(rgba(0, 0, 0, 0.44), rgba(0, 0, 0, 0.44)), url(${theme.preview})` });
const title = makeElement("p", btn, { "className": "theme-button-title clickable", "textContent": theme.title });
const credits = makeElement("p", btn, { "className": "theme-button-creator clickable", "textContent": theme.credits });
const details = makeElement("div", container, { "className": "submitted-theme-details" });
const top = makeElement("div", details, { "style": "display:flex;justify-content:space-between;align-items:center" });
const tag = makeElement("span", top, { "className": "submitted-theme-tag", "textContent": theme.approved === 1 ? "Approved" : theme.approved === 0 ? "Pending" : "Rejected", "style": `background: ${theme.approved === 1 ? "#ad3a74" : theme.approved === 0 ? "#514e4e": "#000"}` });
const msg = makeElement("p", details, { "textContent": theme.approved === 1 ? "Looks great! Thanks for submitting" : theme.approved === 0 ? "Your theme is still awaiting approval." : `Your theme was rejected${theme.reason ? (": " + theme.reason) : " because it did not meet the theme guidelines."}`});
const ago = makeElement("span", top, { "className": "submitted-theme-time", "textContent": `${getRelativeDate(new Date(parseInt(theme.time))).time} ago` });
});
}
async function getExport(storage, options) {
let final = {};
@ -1489,7 +1399,6 @@ function themeSortFn(method) {
return themes;
case "Color":
return themes.sort((a, b) => {
//return (colorValues[a.color] || 88) - (colorValues[b.color] || 88)
return (colorValues[a.color] || (a.color !== "whiteblack" && a.color.includes("white") ? 15 : 16)) - (colorValues[b.color] || (b.color !== "whiteblack" && b.color.includes("white") ? 15 : 16))
})
return themes.sort((a, b) => {
@ -1545,110 +1454,8 @@ let searchFor = "";
let current_sort = "Popular";
let allThemes = themeSortFn(current_sort);
//sortThemes(current_sort);
function shortScore(score) {
if (score >= 1400) {
return (Math.floor(score / 1000) + "." + Math.round((score % 1000) / 100)) + "k";
}
return score;
}
let fallback = false;
async function submitTheme() { //TODO: remake
const sync = await chrome.storage.sync.get(null);
// if (sync["new_browser"] !== true) {
// displayAlert(true, "You'll need to opt in to the new browser if you want to submit your theme. If you've opted out and want to opt in, you can scroll down to the bottom of this page and opt back in.");
// return;
// }
const theme = await getExport(sync, [
...syncedSwitches,
...syncedSubOptions,
"custom_cards",
"card_colors",
"dark_preset",
"custom_font",
"gradient_cards",
"disable_color_overlay",
]);
const title = document.getElementById("submit-title");
const credits = document.getElementById("submit-credits");
if (title.value === "") {
displayAlert(true, "The title of your theme can't be empty");
return;
}
if (credits.value === "") {
displayAlert(true, "The credits for your theme can't be empty");
return;
}
const body = JSON.stringify({
"identity": sync["id"],
"title": title.value,
"credits": credits.value,
"theme": JSON.stringify(theme)
});
fetch(`${apiurl}/api/themes/submit`, { //
"method": "POST",
"body": body,
"headers": {
"Content-Type": "application/json",
},
}).then(res => res.json())
.then(data => {
console.log(data);
if (data.errors === false) {
displayAlert(false, "Thanks for submitting your theme! I will try to approve it soon, but not every theme may be accepted.");
document.getElementById("submit-popup").classList.remove("open");
} else {
displayAlert(true, `Submission error: ${data.message} Please contact sandlerguy5@gmail.com if you believe this is incorrect.`);
}
});
}
async function registerUser() { // TODO: remake
try {
let id;
const sync = await chrome.storage.sync.get("id");
if (sync["id"] && sync["id"] !== "") {
id = sync["id"]
} else {
const res = await fetch(`${apiurl}/api/register`);
const data = await res.json();
id = data.id;
}
chrome.storage.sync.set({ "id": id }).then(async () => {
// test to see if the id was set correctly
// don't know why this is happening ??
const test = await chrome.storage.sync.get("id");
if (test["id"] === undefined || test["id"] === "") throw new Error();
// show the new browser
chrome.storage.sync.set({ "new_browser": true }).then(() => {
document.getElementById("opt-in").style.display = "none";
current_page_num = 1;
displayThemeList(0);
displayAlert(false, "Success! You should be able to see the new themes browser now. Enjoy!");
});
}).catch(e => {
displayAlert(true, "There was an error connecting an ID to your account. Please try again, and if this error persists, contact sandlerguy5@gmail.com!");
});
} catch (e) {
console.log(e);
displayAlert(true, "There was an error opting in. Please contact sandlerguy5@gmail.com if this error persists!");
}
}
function saveCurrentTheme() {
const allOptions = syncedSwitches.concat(syncedSubOptions).concat(["dark_preset", "custom_cards", "custom_font", "gpa_calc_bounds", "card_colors"]);
@ -1692,234 +1499,8 @@ function saveCurrentTheme() {
async function displayThemeList(direction = 0) {
// const sync = await chrome.storage.sync.get("new_browser");
// if (sync["new_browser"] === true && fallback === false) {
// displayThemeListNew(direction);
// } else {
displayThemeListOld(direction);
// }
// remove the opt-in notice
// if (sync["new_browser"] !== null && document.getElementById("opt-in")) document.getElementById("opt-in").style.display = "none";
}
function createThemeButton(location, theme) {
let themeBtn = makeElement("button", location, { "className": "theme-button clickable" });
themeBtn.classList.add("customization-button");
if (!themeBtn.style.background) themeBtn.style.backgroundImage = "linear-gradient(#00000070, #00000070), url(" + theme.preview + ")";
if (theme.title) makeElement("p", themeBtn, { "className": "theme-button-title clickable", "textContent": theme.title.replaceAll(" ", "") });
if (theme.credits) makeElement("p", themeBtn, { "className": "theme-button-creator clickable", "textContent": theme.credits });
return themeBtn;
}
function createThemeLikeBtn(location, initial, score, show) {
const likeBtn = makeElement("div", location, {"className": "theme-button-like"});
if (initial === true) {
likeBtn.classList.add("theme-liked");
score += 1;
}
const amount = makeElement("span", likeBtn, { "className": "theme-button-like-amount", "textContent": shortScore(score) });
if (show === true) amount.classList.add("showalways");
likeBtn.innerHTML += `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6.979 3.074a6 6 0 0 1 4.988 1.425l.037 .033l.034 -.03a6 6 0 0 1 4.733 -1.44l.246 .036a6 6 0 0 1 3.364 10.008l-.18 .185l-.048 .041l-7.45 7.379a1 1 0 0 1 -1.313 .082l-.094 -.082l-7.493 -7.422a6 6 0 0 1 3.176 -10.215z" /></svg>`;
return likeBtn;
}
let likeThemeTimeout = false;
function setLikeTimeout() {
if (likeThemeTimeout === true) return;
likeThemeTimeout = true;
setTimeout(() => {
likeThemeTimeout = false;
}, 1000);
}
async function likeTheme(location, code, score) { // TODO: remake
if (likeThemeTimeout === true) return;
const sync = await chrome.storage.sync.get("id");
const local = await chrome.storage.local.get("liked_themes");
const setLikeStatus = (direction) => {
let output = local;
if (direction === -1) {
location.classList.remove("theme-liked");
location.querySelector(".theme-button-like-amount").textContent = shortScore(score);
output = local["liked_themes"].filter(x => x !== code);
} else if (direction === 1) {
location.classList += (" theme-liked animate-like");
location.querySelector(".theme-button-like-amount").textContent = shortScore(score + 1);
output = [...local["liked_themes"], code];
}
return output;
}
// show the updated like status immediately
setLikeStatus(location.classList.contains("theme-liked") ? -1 : 1);
const res = await fetch(`${apiurl}/api/themes/theme/${code}/like`, {
"method": "POST",
"body": JSON.stringify({ "id": sync["id"] }),
"headers": {
"Content-Type": "application/json"
},
});
const data = await res.json();
if (data.errors === false) {
const direction = parseInt(data.message);
// update the like status if there is some disagreement with the server
const update = setLikeStatus(direction);
chrome.storage.local.set({ "liked_themes": update }).then(setLikeTimeout);
} else {
setLikeTimeout();
}
}
async function getAndLoadTheme(code) { // todo: remake
const key = `themes/${code}`;
let output = {};
if (cache[key]) {
output = cache[key];
console.log("got this theme from the cache.");
} else {
const res = await fetch(`${apiurl}/api/themes/theme/${code}`);
const data = await res.json();
output = JSON.parse(data.message.exports);
cache[key] = output;
}
importTheme(output);
}
async function displayThemeListNew(direction) { // TODO: remake
document.getElementById("theme-current-sort").textContent = current_sort;
if (direction === -1 && current_page_num > 1) current_page_num--;
if (direction === 1 && current_page_num < maxPage) current_page_num++;
let themes = [];
let apiLink = `${current_sort.toLowerCase()}?page=${current_page_num}` + (searchFor === "" ? "" : `&searchFor=${searchFor}`);
if (current_sort === "Liked") {
const sync = await chrome.storage.sync.get("id");
const local = await chrome.storage.local.get("liked_themes");
if (sync["id"] && sync["id"] !== "") {
apiLink += `&id=${sync["id"]}`;
maxPage = Math.ceil(local["liked_themes"].length / 28);
} else { // fallback if there is no id
current_page_num = 1;
apiLink = `popular?page=${current_page_num}` + (searchFor === "" ? "" : `&searchFor=${searchFor}`);
}
}
// fetch api, fallback if necessary
if (cache[apiLink]) {
themes = cache[apiLink]["themes"];
maxPage = cache[apiLink]["pages"] || maxPage;
} else {
try {
const res = await fetch(`${apiurl}/api/themes/${apiLink}`, {
method: "get",
headers: {
"Content-Type": "application/json"
},
});
const data = await res.json();
if (data.errors === true) throw new Error(data.message);
themes = data.message.themes;
cache[apiLink] = data.message;
if (data?.message?.pages) {
maxPage = data.message.pages;
}
} catch (e) {
console.log(e);
current_page_num = 1;
fallback = true;
displayAlert(true, "there is no server you should not be seeing this. There was a problem getting themes from the Canvas Refined server, so the old themes browser is being displayed for now.");
displayThemeListOld(0);
return;
}
}
let container = document.getElementById("premade-themes");
container.textContent = "";
const local = await chrome.storage.local.get("liked_themes");
const sync = await chrome.storage.sync.get("browser_show_likes");
themes.forEach(theme => {
const themeBtn = createThemeButton(container, theme);
themeBtn.addEventListener("click", (e) => {
if (!e.target.classList.contains("clickable")) return;
// getAndLoadTheme(theme.code)
});
const liked = local["liked_themes"].includes(theme.code);
// TODO: remake
const likeBtn = createThemeLikeBtn(themeBtn, liked, theme.score, sync["browser_show_likes"]);
// likeBtn.addEventListener("click" , (e) => likeTheme(likeBtn, theme.code, theme.score));
});
if (themes.length === 0) {
container.innerHTML = `<div id="themes-empty">Nothing here</div>`;
}
document.getElementById("premade-themes-pagenum").textContent = current_page_num + " of " + maxPage;
// set the submit theme button to the first custom card image
try {
const sync = await chrome.storage.sync.get("custom_cards");
const exports = await getExport(sync, ["custom_cards"]);
document.getElementById("theme-button-img").style.background = `linear-gradient(#00000070, #00000070), url(${exports["custom_cards"][0]}) no-repeat center center / cover`;
} catch (e) {
console.log(e);
}
displaySavedThemes();
}
function displayThemeListOld(pageDir = 0) {
//const keys = Object.keys(themes);
document.getElementById("theme-current-sort").textContent = current_sort;
const perPage = 24;
const maxPage = Math.ceil(allThemes.length / perPage);
if (pageDir === -1 && current_page_num > 1) current_page_num--;
if (pageDir === 1 && current_page_num < maxPage) current_page_num++;
let container = document.getElementById("premade-themes");
container.textContent = "";
let start = (current_page_num - 1) * perPage, end = start + perPage;
allThemes.forEach((theme, index) => {
if (index < start || index >= end) return;
let themeBtn = makeElement("button", container, { "className": "theme-button" });
themeBtn.classList.add("customization-button");
if (!themeBtn.style.background) themeBtn.style.backgroundImage = "linear-gradient(#00000070, #00000070), url(" + theme.preview + ")";
let split = theme.title.split(" by ");
makeElement("p", themeBtn, {"className": "theme-button-title", "textContent": split[0] });
makeElement("p", themeBtn, {"className": "theme-button-creator", "textContent": split[1] });
themeBtn.addEventListener("click", () => {
const allOptions = syncedSwitches.concat(syncedSubOptions).concat(["dark_preset", "custom_cards", "custom_font", "gpa_calc_bounds", "card_colors"]);
chrome.storage.sync.get(allOptions, sync => {
chrome.storage.local.get(["previous_theme"], async local => {
if (local["previous_theme"] === null) {
let previous = await getExport(sync, allOptions);
chrome.storage.local.set({ "previous_theme": previous });
}
importTheme(theme.exports);
});
});
});
});
document.getElementById("premade-themes-pagenum").textContent = current_page_num + " of " + maxPage;
displaySavedThemes();
}
function displayThemeSearchList(themesToShow, pageDir = 0) {
document.getElementById("theme-current-sort").textContent = current_sort;
@ -2153,73 +1734,7 @@ function setCustomImage(key, val) {
function displayAdvancedCards() {
sendFromPopup("getCards");
chrome.storage.sync.get(["custom_cards", "custom_cards_2"], storage => {
// document.querySelector(".advanced-cards").innerHTML = '<div id="advanced-current"></div><div id="advanced-past"><h2>Past Courses</h2></div>';
// const keys = storage["custom_cards"] ? Object.keys(storage["custom_cards"]) : [];
// if (keys.length > 0) {
// let currentEnrollment = keys.reduce((max, key) => storage["custom_cards"][key]?.eid > max ? storage["custom_cards"][key].eid : max, -1);
// keys.forEach(key => {
// let term = document.querySelector("#advanced-past");
// if (storage["custom_cards"][key].eid === currentEnrollment) {
// term = document.querySelector("#advanced-current");
// }
// let card = storage["custom_cards"][key];
// let card_2 = storage["custom_cards_2"][key] || {};
// if (!card || !card_2 || !card_2["links"] || card_2["links"]["custom"]) {
// console.log(key + " error...");
// console.log("card = ", card, "card_2", card_2, "links", card_2["links"]);
// } else {
// let container = makeElement("div", term, { "className": "custom-card" });
// container.classList.add("option-container");
// container.innerHTML = '<div class="custom-card-header"><p class="custom-card-title"></p><div class="custom-card-hide"><p class="custom-key">Hide</p></div></div><div class="custom-card-inputs"><div class="custom-card-left"><div class="custom-card-image"><span class="custom-key">Image</span></div><div class="custom-card-name"><span class="custom-key">Name</span></div><div class="custom-card-code"><span class="custom-key">Code</span></div></div><div class="custom-links-container"><p class="custom-key">Links</p><div class="custom-links"></div></div></div>';
// let imgInput = makeElement("input", container.querySelector(".custom-card-image"), { "className": "card-input" });
// let nameInput = makeElement("input", container.querySelector(".custom-card-name"), { "className": "card-input" });
// let codeInput = makeElement("input", container.querySelector(".custom-card-code"), { "className": "card-input" });
// let hideInput = makeElement("input", container.querySelector(".custom-card-hide"), { "className": "card-input-checkbox" });
// imgInput.placeholder = "Image url";
// nameInput.placeholder = "Custom name";
// codeInput.placeholder = "Custom code";
// hideInput.type = "checkbox";
// imgInput.value = card.img;
// nameInput.value = card.name;
// codeInput.value = card.code;
// hideInput.checked = card.hidden;
// if (card.img && card.img !== "") container.style.background = "linear-gradient(155deg, #1e1e1eeb 20%, #1e1e1ecc), url(\"" + card.img + "\") center / cover no-repeat";
// imgInput.addEventListener("change", e => {
// setCustomImage(key, e.target.value);
// container.style.background = e.target.value === "" ? "var(--containerbg)" : "linear-gradient(155deg, #1e1e1eeb 20%, #1e1e1ecc), url(\"" + e.target.value + "\") center / cover no-repeat";
// });
// nameInput.addEventListener("change", function (e) { updateCards(key, { "name": e.target.value }) });
// codeInput.addEventListener("change", function (e) { updateCards(key, { "code": e.target.value }) });
// hideInput.addEventListener("change", function (e) { updateCards(key, { "hidden": e.target.checked }) });
// container.querySelector(".custom-card-title").textContent = card.default;
// for (let i = 0; i < 4; i++) {
// let customLink = makeElement("input", container.querySelector(".custom-links"), { "className": "card-input" });
// customLink.value = card_2.links[i].is_default ? "default" : card_2.links[i].path;
// customLink.addEventListener("change", function (e) {
// chrome.storage.sync.get("custom_cards_2", storage => {
// let newLinks = storage.custom_cards_2[key].links;
// if (e.target.value === "" || e.target.value === "default") {
// console.log("this value is empty....")
// //newLinks[i] = { "type": storage.custom_cards_2[key].links.default[i].type, "default": true };
// newLinks[i] = { "default": newLinks[i].default, "is_default": true, "path": newLinks[i].default };
// customLink.value = "default";
// } else {
// //newLinks[i] = { "type": getLinkType(e.target.value), "path": e.target.value, "default": false };
// let val = e.target.value;
// if (!e.target.value.includes("https://") && e.target.value !== "none") val = "https://" + val;
// newLinks[i] = { "default": newLinks[i].default, "is_default": false, "path": val };
// customLink.value = val;
// }
// chrome.storage.sync.set({ "custom_cards_2": { ...storage.custom_cards_2, [key]: { ...storage.custom_cards_2[key], "links": newLinks } } })
// });
// });
// }
// };
// });
// } else {
// document.querySelector(".advanced-cards").innerHTML = `<div class="option-container"><h3>Couldn't find your cards!<br/>You may need to refresh your Canvas page and/or this menu page.<br/><br/>If you're having issues please contact me - sandlerguy5@gmail.com</h3></div>`;
// }
const cardGrid = document.getElementById("card-grid");
if (!cardGrid) {
@ -2634,4 +2149,4 @@ async function sendFromPopup(message, options = {}) {
})
return await response;
}
}