change to singlequotes

This commit is contained in:
SethBurkart123
2023-11-08 11:50:01 +11:00
parent 9919b25493
commit db1349e430
21 changed files with 1576 additions and 1555 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
}, },
"rules": { "rules": {
"indent": ["error", 2], "indent": ["error", 2],
"quotes": ["error", "double"], "quotes": ["error", "single"],
"semi": ["error", "always"] "semi": ["error", "always"]
} }
} }
+24 -24
View File
@@ -1,29 +1,29 @@
// Open the database // Open the database
const openDB = () => { const openDB = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const request = indexedDB.open("MyDatabase", 1); const request = indexedDB.open('MyDatabase', 1);
request.onerror = () => reject(request.error); request.onerror = () => reject(request.error);
request.onsuccess = () => resolve(request.result); request.onsuccess = () => resolve(request.result);
request.onupgradeneeded = (event) => { request.onupgradeneeded = (event) => {
const db = event.target.result; const db = event.target.result;
db.createObjectStore("backgrounds", { keyPath: "id" }); db.createObjectStore('backgrounds', { keyPath: 'id' });
}; };
}); });
}; };
// Modified Read Data from IndexedDB // Modified Read Data from IndexedDB
const readData = async () => { const readData = async () => {
const selectedBackground = localStorage.getItem("selectedBackground"); const selectedBackground = localStorage.getItem('selectedBackground');
if (!selectedBackground) { if (!selectedBackground) {
console.log("No selected background in local storage."); console.log('No selected background in local storage.');
return null; return null;
} }
const db = await openDB(); const db = await openDB();
const tx = db.transaction("backgrounds", "readonly"); const tx = db.transaction('backgrounds', 'readonly');
const store = tx.objectStore("backgrounds"); const store = tx.objectStore('backgrounds');
const request = store.get(selectedBackground); const request = store.get(selectedBackground);
return await new Promise((resolve, reject) => { return await new Promise((resolve, reject) => {
@@ -36,10 +36,10 @@ const updateBackground = async () => {
try { try {
const data = await readData(); const data = await readData();
if (!data) { if (!data) {
console.log("No data found in IndexedDB."); console.log('No data found in IndexedDB.');
const container = document.getElementById("media-container"); const container = document.getElementById('media-container');
const currentMedia = container.querySelector(".current-media"); const currentMedia = container.querySelector('.current-media');
if (currentMedia) { if (currentMedia) {
currentMedia.remove(); currentMedia.remove();
} }
@@ -47,16 +47,16 @@ const updateBackground = async () => {
} }
const url = URL.createObjectURL(data.blob); const url = URL.createObjectURL(data.blob);
const container = document.getElementById("media-container"); const container = document.getElementById('media-container');
// Create new element and set properties // Create new element and set properties
let newElement; let newElement;
if (data.type === "image") { if (data.type === 'image') {
newElement = document.createElement("img"); newElement = document.createElement('img');
newElement.src = url; newElement.src = url;
newElement.alt = "Uploaded content"; newElement.alt = 'Uploaded content';
} else if (data.type === "video") { } else if (data.type === 'video') {
newElement = document.createElement("video"); newElement = document.createElement('video');
newElement.src = url; newElement.src = url;
newElement.autoplay = true; newElement.autoplay = true;
newElement.loop = true; newElement.loop = true;
@@ -64,25 +64,25 @@ const updateBackground = async () => {
} }
// Mark the old element for removal // Mark the old element for removal
const oldElement = container.querySelector(".current-media"); const oldElement = container.querySelector('.current-media');
if (oldElement) { if (oldElement) {
oldElement.classList.remove("current-media"); oldElement.classList.remove('current-media');
oldElement.classList.add("old-media"); oldElement.classList.add('old-media');
} }
// Add the new element and mark it as current // Add the new element and mark it as current
newElement.classList.add("current-media"); newElement.classList.add('current-media');
container.appendChild(newElement); container.appendChild(newElement);
// Delay removal of old element // Delay removal of old element
setTimeout(() => { setTimeout(() => {
const oldMedia = container.querySelector(".old-media"); const oldMedia = container.querySelector('.old-media');
if (oldMedia) { if (oldMedia) {
oldMedia.remove(); oldMedia.remove();
} }
}, 100); // 0.1 second delay }, 100); // 0.1 second delay
} catch (error) { } catch (error) {
console.error("An error occurred:", error); console.error('An error occurred:', error);
} }
}; };
@@ -91,12 +91,12 @@ const main = async () => {
await updateBackground(); // Initial background update await updateBackground(); // Initial background update
// Listen for changes to local storage // Listen for changes to local storage
window.addEventListener("storage", async (event) => { window.addEventListener('storage', async (event) => {
if (event.key === "selectedBackground") { if (event.key === 'selectedBackground') {
await updateBackground(); // Update background if 'selectedBackground' changes await updateBackground(); // Update background if 'selectedBackground' changes
} }
}); });
}; };
// Run the main function when the document is ready // Run the main function when the document is ready
document.addEventListener("DOMContentLoaded", main); document.addEventListener('DOMContentLoaded', main);
+783 -783
View File
File diff suppressed because it is too large Load Diff
+16 -16
View File
@@ -1,24 +1,24 @@
function show(platform, enabled, useSettingsInsteadOfPreferences) { function show(platform, enabled, useSettingsInsteadOfPreferences) {
document.body.classList.add(`platform-${platform}`); document.body.classList.add(`platform-${platform}`);
if (useSettingsInsteadOfPreferences) { if (useSettingsInsteadOfPreferences) {
document.getElementsByClassName('platform-mac state-on')[0].innerText = "BetterSEQTA+s extension is currently on. You can turn it off in the Extensions section of Safari Settings."; document.getElementsByClassName('platform-mac state-on')[0].innerText = 'BetterSEQTA+s extension is currently on. You can turn it off in the Extensions section of Safari Settings.';
document.getElementsByClassName('platform-mac state-off')[0].innerText = "BetterSEQTA+s extension is currently off. You can turn it on in the Extensions section of Safari Settings."; document.getElementsByClassName('platform-mac state-off')[0].innerText = 'BetterSEQTA+s extension is currently off. You can turn it on in the Extensions section of Safari Settings.';
document.getElementsByClassName('platform-mac state-unknown')[0].innerText = "You can turn on BetterSEQTA+s extension in the Extensions section of Safari Settings."; document.getElementsByClassName('platform-mac state-unknown')[0].innerText = 'You can turn on BetterSEQTA+s extension in the Extensions section of Safari Settings.';
document.getElementsByClassName('platform-mac open-preferences')[0].innerText = "Quit and Open Safari Settings…"; document.getElementsByClassName('platform-mac open-preferences')[0].innerText = 'Quit and Open Safari Settings…';
} }
if (typeof enabled === "boolean") { if (typeof enabled === 'boolean') {
document.body.classList.toggle(`state-on`, enabled); document.body.classList.toggle('state-on', enabled);
document.body.classList.toggle(`state-off`, !enabled); document.body.classList.toggle('state-off', !enabled);
} else { } else {
document.body.classList.remove(`state-on`); document.body.classList.remove('state-on');
document.body.classList.remove(`state-off`); document.body.classList.remove('state-off');
} }
} }
function openPreferences() { function openPreferences() {
webkit.messageHandlers.controller.postMessage("open-preferences"); webkit.messageHandlers.controller.postMessage('open-preferences');
} }
document.querySelector("button.open-preferences").addEventListener("click", openPreferences); document.querySelector('button.open-preferences').addEventListener('click', openPreferences);
+579 -558
View File
File diff suppressed because it is too large Load Diff
+53 -53
View File
@@ -2,11 +2,11 @@
export const openDB = () => { export const openDB = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const request = indexedDB.open("MyDatabase", 1); const request = indexedDB.open('MyDatabase', 1);
request.onupgradeneeded = (event) => { request.onupgradeneeded = (event) => {
const db = event.target.result; const db = event.target.result;
db.createObjectStore("backgrounds", { keyPath: "id" }); db.createObjectStore('backgrounds', { keyPath: 'id' });
}; };
request.onsuccess = () => { request.onsuccess = () => {
@@ -14,7 +14,7 @@ export const openDB = () => {
}; };
request.onerror = (event) => { request.onerror = (event) => {
reject("Error opening database: " + event.target.errorCode); reject('Error opening database: ' + event.target.errorCode);
}; };
}); });
}; };
@@ -22,9 +22,9 @@ export const openDB = () => {
export const writeData = async (type, data) => { export const writeData = async (type, data) => {
const db = await openDB(); const db = await openDB();
const tx = db.transaction("backgrounds", "readwrite"); const tx = db.transaction('backgrounds', 'readwrite');
const store = tx.objectStore("backgrounds"); const store = tx.objectStore('backgrounds');
const request = await store.put({ id: "customBackground", type, data }); const request = await store.put({ id: 'customBackground', type, data });
return request.result; return request.result;
}; };
@@ -33,11 +33,11 @@ export const readData = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
openDB() openDB()
.then(db => { .then(db => {
const tx = db.transaction("backgrounds", "readonly"); const tx = db.transaction('backgrounds', 'readonly');
const store = tx.objectStore("backgrounds"); const store = tx.objectStore('backgrounds');
// Retrieve the custom background // Retrieve the custom background
const getRequest = store.get("customBackground"); const getRequest = store.get('customBackground');
// Attach success and error event handlers // Attach success and error event handlers
getRequest.onsuccess = function(event) { getRequest.onsuccess = function(event) {
@@ -45,12 +45,12 @@ export const readData = () => {
}; };
getRequest.onerror = function(event) { getRequest.onerror = function(event) {
console.error("An error occurred:", event); console.error('An error occurred:', event);
reject(event); reject(event);
}; };
}) })
.catch(error => { .catch(error => {
console.error("An error occurred:", error); console.error('An error occurred:', error);
reject(error); reject(error);
}); });
}); });
@@ -59,7 +59,7 @@ export const readData = () => {
function ReloadSEQTAPages() { function ReloadSEQTAPages() {
chrome.tabs.query({}, function (tabs) { chrome.tabs.query({}, function (tabs) {
for (let tab of tabs) { for (let tab of tabs) {
if (tab.title.includes("SEQTA Learn")) { if (tab.title.includes('SEQTA Learn')) {
chrome.tabs.reload(tab.id); chrome.tabs.reload(tab.id);
} }
} }
@@ -68,12 +68,12 @@ function ReloadSEQTAPages() {
// Helper function to handle setting permissions // Helper function to handle setting permissions
const handleAddPermissions = () => { const handleAddPermissions = () => {
if (typeof chrome.declarativeContent !== "undefined") { if (typeof chrome.declarativeContent !== 'undefined') {
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {}); chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {});
} }
chrome.permissions.request( chrome.permissions.request(
{ permissions: ["declarativeContent"], origins: ["*://*/*"] }, { permissions: ['declarativeContent'], origins: ['*://*/*'] },
(granted) => { (granted) => {
if (granted) { if (granted) {
const rules = [ const rules = [
@@ -84,7 +84,7 @@ const handleAddPermissions = () => {
chrome.declarativeContent.onPageChanged.addRules([rule]); chrome.declarativeContent.onPageChanged.addRules([rule]);
}); });
alert("Permissions granted. Reload SEQTA pages to see changes. If this workaround doesn't work, please contact the developer. It will be an easy fix"); alert('Permissions granted. Reload SEQTA pages to see changes. If this workaround doesn\'t work, please contact the developer. It will be an easy fix');
} }
} }
); );
@@ -93,15 +93,15 @@ const handleAddPermissions = () => {
// Main message listener // Main message listener
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
switch (request.type) { switch (request.type) {
case "reloadTabs": case 'reloadTabs':
ReloadSEQTAPages(); ReloadSEQTAPages();
break; break;
case "IndexedDB": case 'IndexedDB':
HandleIntexedDB(request, sendResponse); HandleIntexedDB(request, sendResponse);
return true; return true;
case "currentTab": case 'currentTab':
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, request, function (response) { chrome.tabs.sendMessage(tabs[0].id, request, function (response) {
sendResponse(response); sendResponse(response);
@@ -109,36 +109,36 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
}); });
return true; return true;
case "githubTab": case 'githubTab':
chrome.tabs.create({ url: "github.com/SethBurkart123/EvenBetterSEQTA" }); chrome.tabs.create({ url: 'github.com/SethBurkart123/EvenBetterSEQTA' });
break; break;
case "setDefaultStorage": case 'setDefaultStorage':
SetStorageValue(DefaultValues); SetStorageValue(DefaultValues);
break; break;
case "addPermissions": case 'addPermissions':
handleAddPermissions(); handleAddPermissions();
break; break;
case "sendNews": case 'sendNews':
GetNews(sendResponse); GetNews(sendResponse);
return true; return true;
// eslint-disable-next-line no-unreachable // eslint-disable-next-line no-unreachable
break; break;
default: default:
console.log("Unknown request type"); console.log('Unknown request type');
} }
}); });
function HandleIntexedDB(request, sendResponse) { function HandleIntexedDB(request, sendResponse) {
switch (request.action) { switch (request.action) {
case "write": case 'write':
writeData(request.data.type, request.data.data); writeData(request.data.type, request.data.data);
break; break;
case "read": case 'read':
readData().then((data) => { readData().then((data) => {
sendResponse(data); sendResponse(data);
}); });
@@ -152,9 +152,9 @@ function GetNews(sendResponse) {
const from = const from =
date.getFullYear() + date.getFullYear() +
"-" + '-' +
(date.getMonth() + 1) + (date.getMonth() + 1) +
"-" + '-' +
(date.getDate() - 1); (date.getDate() - 1);
let url = `https://newsapi.org/v2/everything?domains=abc.net.au&from=${from}&apiKey=17c0da766ba347c89d094449504e3080`; let url = `https://newsapi.org/v2/everything?domains=abc.net.au&from=${from}&apiKey=17c0da766ba347c89d094449504e3080`;
@@ -162,8 +162,8 @@ function GetNews(sendResponse) {
fetch(url) fetch(url)
.then((result) => result.json()) .then((result) => result.json())
.then((response) => { .then((response) => {
if (response.code == "rateLimited") { if (response.code == 'rateLimited') {
url += "%00"; url += '%00';
GetNews(); GetNews();
} else { } else {
sendResponse({ news: response }); sendResponse({ news: response });
@@ -181,55 +181,55 @@ const DefaultValues = {
menuitems: {}, menuitems: {},
menuorder: [], menuorder: [],
subjectfilters: {}, subjectfilters: {},
selectedColor: "linear-gradient(40deg, rgba(201,61,0,1) 0%, RGBA(170, 5, 58, 1) 100%)", selectedColor: 'linear-gradient(40deg, rgba(201,61,0,1) 0%, RGBA(170, 5, 58, 1) 100%)',
DarkMode: true, DarkMode: true,
shortcuts: [ shortcuts: [
{ {
name: "YouTube", name: 'YouTube',
enabled: false, enabled: false,
}, },
{ {
name: "Outlook", name: 'Outlook',
enabled: true, enabled: true,
}, },
{ {
name: "Office", name: 'Office',
enabled: true, enabled: true,
}, },
{ {
name: "Spotify", name: 'Spotify',
enabled: false, enabled: false,
}, },
{ {
name: "Google", name: 'Google',
enabled: true, enabled: true,
}, },
{ {
name: "DuckDuckGo", name: 'DuckDuckGo',
enabled: false, enabled: false,
}, },
{ {
name: "Cool Math Games", name: 'Cool Math Games',
enabled: false, enabled: false,
}, },
{ {
name: "SACE", name: 'SACE',
enabled: false, enabled: false,
}, },
{ {
name: "Google Scholar", name: 'Google Scholar',
enabled: false, enabled: false,
}, },
{ {
name: "Gmail", name: 'Gmail',
enabled: false, enabled: false,
}, },
{ {
name: "Netflix", name: 'Netflix',
enabled: false, enabled: false,
}, },
{ {
name: "Education Perfect", name: 'Education Perfect',
enabled: false, enabled: false,
}, },
], ],
@@ -250,8 +250,8 @@ function UpdateCurrentValues() {
function CheckInnerElement(element) { function CheckInnerElement(element) {
for (let i in element) { for (let i in element) {
if (typeof element[i] === "object") { if (typeof element[i] === 'object') {
if (typeof DefaultValues[i].length == "undefined") { if (typeof DefaultValues[i].length == 'undefined') {
NewValue[i] = Object.assign({}, DefaultValues[i], CurrentValues[i]); NewValue[i] = Object.assign({}, DefaultValues[i], CurrentValues[i]);
} else { } else {
// If the object is an array, turn it back after // If the object is an array, turn it back after
@@ -268,8 +268,8 @@ function UpdateCurrentValues() {
} }
CheckInnerElement(DefaultValues); CheckInnerElement(DefaultValues);
if (items["customshortcuts"]) { if (items['customshortcuts']) {
NewValue["customshortcuts"] = items["customshortcuts"]; NewValue['customshortcuts'] = items['customshortcuts'];
} }
SetStorageValue(NewValue); SetStorageValue(NewValue);
@@ -281,7 +281,7 @@ function migrateOldStorage() {
let shouldUpdate = false; // Flag to check if there is anything to update let shouldUpdate = false; // Flag to check if there is anything to update
// Check for the old "Name" field and convert it to "name" // Check for the old "Name" field and convert it to "name"
if (items.shortcuts && items.shortcuts.length > 0 && "Name" in items.shortcuts[0]) { if (items.shortcuts && items.shortcuts.length > 0 && 'Name' in items.shortcuts[0]) {
shouldUpdate = true; shouldUpdate = true;
items.shortcuts = items.shortcuts.map((shortcut) => { items.shortcuts = items.shortcuts.map((shortcut) => {
return { return {
@@ -294,9 +294,9 @@ function migrateOldStorage() {
// Check for "educationperfect" and convert it to "Education Perfect" // Check for "educationperfect" and convert it to "Education Perfect"
if (items.shortcuts && items.shortcuts.length > 0) { if (items.shortcuts && items.shortcuts.length > 0) {
for (let shortcut of items.shortcuts) { for (let shortcut of items.shortcuts) {
if (shortcut.name === "educationperfect" || shortcut.name === "Education Perfect") { if (shortcut.name === 'educationperfect' || shortcut.name === 'Education Perfect') {
shouldUpdate = true; shouldUpdate = true;
shortcut.name = "Education Perfect"; shortcut.name = 'Education Perfect';
} }
} }
} }
@@ -304,16 +304,16 @@ function migrateOldStorage() {
// If there"s something to update, set the new values in storage // If there"s something to update, set the new values in storage
if (shouldUpdate) { if (shouldUpdate) {
chrome.storage.local.set({ shortcuts: items.shortcuts }, function() { chrome.storage.local.set({ shortcuts: items.shortcuts }, function() {
console.log("Migration completed."); console.log('Migration completed.');
}); });
} }
}); });
} }
chrome.runtime.onInstalled.addListener(function (event) { chrome.runtime.onInstalled.addListener(function (event) {
chrome.storage.local.remove(["justupdated"]); chrome.storage.local.remove(['justupdated']);
UpdateCurrentValues(); UpdateCurrentValues();
if ( event.reason == "install", event.reason == "update" ) { if ( event.reason == 'install', event.reason == 'update' ) {
chrome.storage.local.set({ justupdated: true }); chrome.storage.local.set({ justupdated: true });
migrateOldStorage(); migrateOldStorage();
} }
+1 -1
View File
@@ -1 +1 @@
import "./documentload.css"; import './documentload.css';
+1 -1
View File
@@ -1 +1 @@
import "./iframe.css"; import './iframe.css';
+1 -1
View File
@@ -1 +1 @@
import "./injected.css"; import './injected.css';
+1 -1
View File
@@ -6,7 +6,7 @@
*/ */
export function updateBgDurations(speed, minDuration = 0.5, maxDuration = 10) { export function updateBgDurations(speed, minDuration = 0.5, maxDuration = 10) {
// Class names to look for // Class names to look for
const bgClasses = ["bg", "bg2", "bg3"]; const bgClasses = ['bg', 'bg2', 'bg3'];
let reversedValue; let reversedValue;
if (speed.bksliderinput === undefined) { if (speed.bksliderinput === undefined) {
+7 -7
View File
@@ -1,15 +1,15 @@
/* global chrome */ /* global chrome */
export async function appendBackgroundToUI() { export async function appendBackgroundToUI() {
console.log("Starting appendBackgroundToUI..."); console.log('Starting appendBackgroundToUI...');
const parent = document.getElementById("container"); const parent = document.getElementById('container');
// embed background.html // embed background.html
const background = document.createElement("iframe"); const background = document.createElement('iframe');
background.id = "background"; background.id = 'background';
background.classList.add("imageBackground"); background.classList.add('imageBackground');
background.setAttribute("excludeDarkCheck", "true"); background.setAttribute('excludeDarkCheck', 'true');
background.src = chrome.runtime.getURL("backgrounds/background.html"); background.src = chrome.runtime.getURL('backgrounds/background.html');
parent.appendChild(background); parent.appendChild(background);
} }
File diff suppressed because one or more lines are too long
+12 -12
View File
@@ -1,10 +1,10 @@
import localforage from "localforage"; import localforage from 'localforage';
let currentThemeClass = ""; let currentThemeClass = '';
// Utility function to fetch and parse JSON // Utility function to fetch and parse JSON
const fetchJSON = async (url) => { const fetchJSON = async (url) => {
const res = await fetch(url, {cache: "no-store"}); const res = await fetch(url, {cache: 'no-store'});
return await res.json(); return await res.json();
}; };
@@ -48,7 +48,7 @@ const saveToIndexedDB = async (theme, themeName) => {
const applyTheme = async (themeName) => { const applyTheme = async (themeName) => {
const { css, className, images } = await localforage.getItem(`css_${themeName}`); const { css, className, images } = await localforage.getItem(`css_${themeName}`);
const newStyle = document.createElement("style"); const newStyle = document.createElement('style');
newStyle.innerHTML = css; newStyle.innerHTML = css;
document.head.appendChild(newStyle); document.head.appendChild(newStyle);
@@ -80,8 +80,8 @@ const applyTheme = async (themeName) => {
export const listThemes = async () => { export const listThemes = async () => {
const themes = await localforage.keys(); const themes = await localforage.keys();
return { return {
themes: themes.filter((key) => key.startsWith("css_")).map((key) => key.replace("css_", "")), themes: themes.filter((key) => key.startsWith('css_')).map((key) => key.replace('css_', '')),
selectedTheme: await localforage.getItem("selectedTheme") selectedTheme: await localforage.getItem('selectedTheme')
}; };
}; };
@@ -92,7 +92,7 @@ export const downloadTheme = async (themeName, themeUrl) => {
}; };
export const deleteTheme = async (themeName) => { export const deleteTheme = async (themeName) => {
const currentTheme = await localforage.getItem("selectedTheme"); const currentTheme = await localforage.getItem('selectedTheme');
if (currentTheme === themeName) { if (currentTheme === themeName) {
await disableTheme(); await disableTheme();
} }
@@ -107,14 +107,14 @@ export const setTheme = async (themeName, themeUrl) => {
await downloadTheme(themeName, themeUrl); await downloadTheme(themeName, themeUrl);
} }
await localforage.setItem("selectedTheme", themeName); await localforage.setItem('selectedTheme', themeName);
await applyTheme(themeName).catch((error) => { await applyTheme(themeName).catch((error) => {
console.error(`Failed to apply theme: ${error}`); console.error(`Failed to apply theme: ${error}`);
}); });
}; };
export const enableCurrentTheme = async () => { export const enableCurrentTheme = async () => {
const currentTheme = await localforage.getItem("selectedTheme"); const currentTheme = await localforage.getItem('selectedTheme');
if (currentTheme) { if (currentTheme) {
await applyTheme(currentTheme).catch((error) => { await applyTheme(currentTheme).catch((error) => {
@@ -133,11 +133,11 @@ export const disableTheme = async () => {
// Remove current theme's class if it exists // Remove current theme's class if it exists
if (currentThemeClass) { if (currentThemeClass) {
document.body.classList.remove(currentThemeClass); document.body.classList.remove(currentThemeClass);
currentThemeClass = ""; currentThemeClass = '';
} }
// Remove any applied image URLs from the root element // Remove any applied image URLs from the root element
const currentTheme = await localforage.getItem("selectedTheme"); const currentTheme = await localforage.getItem('selectedTheme');
if (currentTheme) { if (currentTheme) {
const themeData = await localforage.getItem(`css_${currentTheme}`); const themeData = await localforage.getItem(`css_${currentTheme}`);
if (themeData && themeData.images) { if (themeData && themeData.images) {
@@ -148,5 +148,5 @@ export const disableTheme = async () => {
} }
// Clear the selected theme from localforage // Clear the selected theme from localforage
localforage.removeItem("selectedTheme"); localforage.removeItem('selectedTheme');
}; };
+3 -3
View File
@@ -1,4 +1,4 @@
import Color from "color"; import Color from 'color';
function adjustLuminance(color, lum) { function adjustLuminance(color, lum) {
let adjustedColor = Color(color.toLowerCase()); let adjustedColor = Color(color.toLowerCase());
@@ -17,7 +17,7 @@ function adjustLuminance(color, lum) {
export default function ColorLuminance(color, lum = 0) { export default function ColorLuminance(color, lum = 0) {
const colorRegex = /rgba?\(([^)]+)\)/gi; // Case-insensitive match for rgb() or rgba() const colorRegex = /rgba?\(([^)]+)\)/gi; // Case-insensitive match for rgb() or rgba()
if (color.toLowerCase().includes("gradient")) { if (color.toLowerCase().includes('gradient')) {
let gradient = color; let gradient = color;
let uniqueColorSet = new Set(); let uniqueColorSet = new Set();
@@ -31,7 +31,7 @@ export default function ColorLuminance(color, lum = 0) {
// Adjust luminance for each unique color stop // Adjust luminance for each unique color stop
for (let colorStop of uniqueColorSet) { for (let colorStop of uniqueColorSet) {
const adjustedColor = adjustLuminance(colorStop, lum); const adjustedColor = adjustLuminance(colorStop, lum);
gradient = gradient.replace(new RegExp(colorStop, "gi"), adjustedColor); gradient = gradient.replace(new RegExp(colorStop, 'gi'), adjustedColor);
} }
return gradient; return gradient;
+25 -25
View File
@@ -1,7 +1,7 @@
/* global chrome */ /* global chrome */
import { GetThresholdOfColor, GetiFrameCSSElement } from "../../../SEQTA.js"; import { GetThresholdOfColor, GetiFrameCSSElement } from '../../../SEQTA.js';
import { lightenAndPaleColor } from "./lightenAndPaleColor.js"; import { lightenAndPaleColor } from './lightenAndPaleColor.js';
import ColorLuminance from "./ColorLuminance.js"; import ColorLuminance from './ColorLuminance.js';
// Helper functions // Helper functions
const setCSSVar = (varName, value) => document.documentElement.style.setProperty(varName, value); const setCSSVar = (varName, value) => document.documentElement.style.setProperty(varName, value);
@@ -14,37 +14,37 @@ export function updateAllColors(storedSetting, newColor = null) {
// Determine the color to use // Determine the color to use
const selectedColor = newColor || storedSetting.selectedColor; const selectedColor = newColor || storedSetting.selectedColor;
DarkMode = (typeof storedSetting?.DarkMode === "boolean") ? storedSetting.DarkMode : DarkMode; DarkMode = (typeof storedSetting?.DarkMode === 'boolean') ? storedSetting.DarkMode : DarkMode;
if (typeof storedSetting === "boolean") { if (typeof storedSetting === 'boolean') {
DarkMode = storedSetting; DarkMode = storedSetting;
} }
// Common properties, always applied // Common properties, always applied
const commonProps = { const commonProps = {
"--better-sub": "#161616", '--better-sub': '#161616',
"--better-alert-highlight": "#c61851", '--better-alert-highlight': '#c61851',
"--better-main": selectedColor '--better-main': selectedColor
}; };
// Mode-based properties, applied if storedSetting is provided // Mode-based properties, applied if storedSetting is provided
let modeProps = {}; let modeProps = {};
if (DarkMode !== null) { if (DarkMode !== null) {
modeProps = DarkMode ? { modeProps = DarkMode ? {
"--background-primary": "#232323", '--background-primary': '#232323',
"--background-secondary": "#1a1a1a", '--background-secondary': '#1a1a1a',
"--text-primary": "white", '--text-primary': 'white',
"--betterseqta-logo": `url(${getChromeURL("icons/betterseqta-light-full.png")})` '--betterseqta-logo': `url(${getChromeURL('icons/betterseqta-light-full.png')})`
} : { } : {
"--background-primary": "#ffffff", '--background-primary': '#ffffff',
"--background-secondary": "#e5e7eb", '--background-secondary': '#e5e7eb',
"--text-primary": "black", '--text-primary': 'black',
"--better-pale": lightenAndPaleColor(selectedColor), '--better-pale': lightenAndPaleColor(selectedColor),
"--betterseqta-logo": `url(${getChromeURL("icons/betterseqta-dark-full.png")})` '--betterseqta-logo': `url(${getChromeURL('icons/betterseqta-dark-full.png')})`
}; };
if (DarkMode) { if (DarkMode) {
document.documentElement.style.removeProperty("--better-pale"); document.documentElement.style.removeProperty('--better-pale');
} }
} }
@@ -52,8 +52,8 @@ export function updateAllColors(storedSetting, newColor = null) {
const rgbThreshold = GetThresholdOfColor(selectedColor); const rgbThreshold = GetThresholdOfColor(selectedColor);
const isBright = rgbThreshold > 210; const isBright = rgbThreshold > 210;
const dynamicProps = { const dynamicProps = {
"--text-color": isBright ? "black" : "white", '--text-color': isBright ? 'black' : 'white',
"--better-light": selectedColor === "#ffffff" ? "#b7b7b7" : ColorLuminance(selectedColor, 0.95) '--better-light': selectedColor === '#ffffff' ? '#b7b7b7' : ColorLuminance(selectedColor, 0.95)
}; };
// Apply all the properties // Apply all the properties
@@ -61,16 +61,16 @@ export function updateAllColors(storedSetting, newColor = null) {
// Set favicon, if storedSetting is provided // Set favicon, if storedSetting is provided
if (DarkMode !== null) { if (DarkMode !== null) {
document.querySelector("link[rel*='icon']").href = getChromeURL("icons/icon-48.png"); document.querySelector('link[rel*=\'icon\']').href = getChromeURL('icons/icon-48.png');
} }
let alliframes = document.getElementsByTagName("iframe"); let alliframes = document.getElementsByTagName('iframe');
let fileref = GetiFrameCSSElement(); let fileref = GetiFrameCSSElement();
for (let i = 0; i < alliframes.length; i++) { for (let i = 0; i < alliframes.length; i++) {
const element = alliframes[i]; const element = alliframes[i];
if (element.getAttribute("excludeDarkCheck") == "true") { if (element.getAttribute('excludeDarkCheck') == 'true') {
continue; continue;
} }
@@ -78,7 +78,7 @@ export function updateAllColors(storedSetting, newColor = null) {
console.log(element.contentDocument.documentElement); console.log(element.contentDocument.documentElement);
element.contentDocument.documentElement.childNodes[1].style.color = element.contentDocument.documentElement.childNodes[1].style.color =
DarkMode ? "black" : "white"; DarkMode ? 'black' : 'white';
element.contentDocument.documentElement.firstChild.appendChild( element.contentDocument.documentElement.firstChild.appendChild(
fileref, fileref,
); );
@@ -87,7 +87,7 @@ export function updateAllColors(storedSetting, newColor = null) {
export function getDarkMode() { export function getDarkMode() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chrome.storage.local.get("DarkMode", (result) => { chrome.storage.local.get('DarkMode', (result) => {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {
return reject(chrome.runtime.lastError); return reject(chrome.runtime.lastError);
} }
+4 -4
View File
@@ -1,8 +1,8 @@
import Color from "color"; import Color from 'color';
export function lightenAndPaleColor(inputColor, lightenFactor = 0.75, paleFactor = 0.55) { export function lightenAndPaleColor(inputColor, lightenFactor = 0.75, paleFactor = 0.55) {
if (inputColor.includes("gradient")) { if (inputColor.includes('gradient')) {
const baseColor = findMatchingColor(inputColor); const baseColor = findMatchingColor(inputColor);
return lightenAndPaleColor(baseColor, lightenFactor, paleFactor); return lightenAndPaleColor(baseColor, lightenFactor, paleFactor);
@@ -44,11 +44,11 @@ function findMatchingColor(cssGradient) {
const colorStops = cssGradient.match(regex); const colorStops = cssGradient.match(regex);
if (!colorStops) { if (!colorStops) {
throw new Error("No valid color stops found in the provided CSS gradient."); throw new Error('No valid color stops found in the provided CSS gradient.');
} }
// Normalize and trim the color stops // Normalize and trim the color stops
const normalizedColorStops = colorStops.map(color => color.toLowerCase().replace(/\s+/g, "")); const normalizedColorStops = colorStops.map(color => color.toLowerCase().replace(/\s+/g, ''));
// Convert the color stops to Color objects // Convert the color stops to Color objects
const colorObjects = normalizedColorStops.map(color => Color(color)); const colorObjects = normalizedColorStops.map(color => Color(color));
+13 -13
View File
@@ -1,7 +1,7 @@
/* global chrome */ /* global chrome */
import { MenuOptionsOpen, OpenMenuOptions, closeSettings } from "../../SEQTA.js"; import { MenuOptionsOpen, OpenMenuOptions, closeSettings } from '../../SEQTA.js';
import { deleteTheme, disableTheme, downloadTheme, listThemes, setTheme } from "../ui/Themes.js"; import { deleteTheme, disableTheme, downloadTheme, listThemes, setTheme } from '../ui/Themes.js';
export class MessageHandler { export class MessageHandler {
constructor() { constructor() {
@@ -11,40 +11,40 @@ export class MessageHandler {
routeMessage(request, sender, sendResponse) { routeMessage(request, sender, sendResponse) {
switch (request.info) { switch (request.info) {
case "EditSidebar": case 'EditSidebar':
this.editSidebar(); this.editSidebar();
break; break;
/* Theme related */ /* Theme related */
case "SetTheme": case 'SetTheme':
console.log(request); console.log(request);
setTheme(request.body.themeName, request.body.themeURL).then(() => { setTheme(request.body.themeName, request.body.themeURL).then(() => {
sendResponse({ status: "success" }); sendResponse({ status: 'success' });
}); });
return true; return true;
case "DownloadTheme": case 'DownloadTheme':
downloadTheme(request.body.themeName, request.body.themeURL).then(() => { downloadTheme(request.body.themeName, request.body.themeURL).then(() => {
sendResponse({ status: "success" }); sendResponse({ status: 'success' });
}); });
return true; return true;
case "ListThemes": case 'ListThemes':
listThemes().then((response) => { listThemes().then((response) => {
sendResponse(response); sendResponse(response);
}); });
return true; return true;
case "DisableTheme": case 'DisableTheme':
disableTheme().then(() => { disableTheme().then(() => {
sendResponse({ status: "success" }); sendResponse({ status: 'success' });
}); });
return true; return true;
case "DeleteTheme": case 'DeleteTheme':
deleteTheme(request.body.themeName).then(() => { deleteTheme(request.body.themeName).then(() => {
sendResponse({ status: "success" }); sendResponse({ status: 'success' });
}); });
return true; return true;
default: default:
console.log("Unknown request info:", request.info); console.log('Unknown request info:', request.info);
} }
} }
+11 -11
View File
@@ -8,9 +8,9 @@ import {
addShortcuts, addShortcuts,
disableNotificationCollector, disableNotificationCollector,
enableNotificationCollector, enableNotificationCollector,
} from "../../SEQTA.js"; } from '../../SEQTA.js';
import { updateBgDurations } from "../ui/Animation.js"; import { updateBgDurations } from '../ui/Animation.js';
import { getDarkMode, updateAllColors } from "../ui/colors/Manager.js"; import { getDarkMode, updateAllColors } from '../ui/colors/Manager.js';
export default class StorageListener { export default class StorageListener {
constructor() { constructor() {
@@ -22,23 +22,23 @@ export default class StorageListener {
Object.keys(changes).forEach((changeKey) => { Object.keys(changes).forEach((changeKey) => {
switch (changeKey) { switch (changeKey) {
case "selectedColor": case 'selectedColor':
this.handleSelectedColorChange(changes.selectedColor.newValue); this.handleSelectedColorChange(changes.selectedColor.newValue);
break; break;
case "shortcuts": case 'shortcuts':
this.handleShortcutsChange( this.handleShortcutsChange(
changes.shortcuts.oldValue, changes.shortcuts.oldValue,
changes.shortcuts.newValue changes.shortcuts.newValue
); );
break; break;
case "DarkMode": case 'DarkMode':
this.darkMode = changes.DarkMode.newValue; this.darkMode = changes.DarkMode.newValue;
console.log(this.darkMode); console.log(this.darkMode);
break; break;
case "customshortcuts": case 'customshortcuts':
if (changes.customshortcuts.newValue) { if (changes.customshortcuts.newValue) {
this.handleCustomShortcutsChange( this.handleCustomShortcutsChange(
changes.customshortcuts.oldValue, changes.customshortcuts.oldValue,
@@ -47,20 +47,20 @@ export default class StorageListener {
} }
break; break;
case "notificationcollector": case 'notificationcollector':
this.handleNotificationCollectorChange(changes.notificationcollector); this.handleNotificationCollectorChange(changes.notificationcollector);
break; break;
case "bksliderinput": case 'bksliderinput':
updateBgDurations(changes.bksliderinput.newValue); updateBgDurations(changes.bksliderinput.newValue);
break; break;
case "animatedbk": case 'animatedbk':
if (changes.animatedbk.newValue) { if (changes.animatedbk.newValue) {
CreateBackground(); CreateBackground();
} else { } else {
RemoveBackground(); RemoveBackground();
document.getElementById("container").style.background = "var(--background-secondary)"; document.getElementById('container').style.background = 'var(--background-secondary)';
} }
break; break;
+4 -4
View File
@@ -1,12 +1,12 @@
import DOMPurify from "dompurify"; import DOMPurify from 'dompurify';
export default function stringToHTML(str, styles = false) { export default function stringToHTML(str, styles = false) {
var parser = new DOMParser(); var parser = new DOMParser();
str = DOMPurify.sanitize(str, { ADD_ATTR: ["onclick"] }); str = DOMPurify.sanitize(str, { ADD_ATTR: ['onclick'] });
var doc = parser.parseFromString(str, "text/html"); var doc = parser.parseFromString(str, 'text/html');
if (styles) { if (styles) {
doc.body.style.cssText = doc.body.style.cssText =
"height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);"; 'height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);';
} }
return doc.body; return doc.body;
} }
+11 -11
View File
@@ -1,20 +1,20 @@
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
export default { export default {
content: [ content: [
"./index.html", './index.html',
"./src/**/*.{js,ts,jsx,tsx}", './src/**/*.{js,ts,jsx,tsx}',
], ],
darkMode: "class", darkMode: 'class',
theme: { theme: {
fontSize: { fontSize: {
"xs": ".65rem", 'xs': '.65rem',
"sm": ".775rem", 'sm': '.775rem',
"base": "0.65rem", 'base': '0.65rem',
"md": "0.65rem", 'md': '0.65rem',
"lg": "1rem", 'lg': '1rem',
"xl": "1.25rem", 'xl': '1.25rem',
"2xl": "1.5rem", '2xl': '1.5rem',
"3xl": "1.875rem", '3xl': '1.875rem',
} }
}, },
plugins: [], plugins: [],
+24 -24
View File
@@ -1,11 +1,11 @@
import path from "path"; import path from 'path';
import MiniCssExtractPlugin from "mini-css-extract-plugin"; import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import CopyWebpackPlugin from "copy-webpack-plugin"; import CopyWebpackPlugin from 'copy-webpack-plugin';
import ESLintPlugin from "eslint-webpack-plugin"; import ESLintPlugin from 'eslint-webpack-plugin';
export default { export default {
target: "web", target: 'web',
node: { node: {
__dirname: true __dirname: true
}, },
@@ -14,22 +14,22 @@ export default {
maxEntrypointSize: 512000, maxEntrypointSize: 512000,
maxAssetSize: 512000, maxAssetSize: 512000,
}, },
devtool: "cheap-module-source-map", devtool: 'cheap-module-source-map',
entry: { entry: {
SEQTA: "./src/SEQTA.js", SEQTA: './src/SEQTA.js',
background: "./src/background.js", background: './src/background.js',
"inject/documentload": "./src/inject/documentload.css", // Entry for CSS 'inject/documentload': './src/inject/documentload.css', // Entry for CSS
"inject/iframe": "./src/inject/iframe.css", // Entry for CSS 'inject/iframe': './src/inject/iframe.css', // Entry for CSS
"inject/injected": "./src/inject/injected.css", // Entry for CSS 'inject/injected': './src/inject/injected.css', // Entry for CSS
}, },
output: { output: {
filename: (pathData) => { filename: (pathData) => {
const name = pathData.chunk.name.replace("inject-", ""); const name = pathData.chunk.name.replace('inject-', '');
return name.includes("inject") ? `inject/${name}.js` : `${name}.js`; return name.includes('inject') ? `inject/${name}.js` : `${name}.js`;
}, },
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
path: path.resolve("build"), path: path.resolve('build'),
publicPath: "", publicPath: '',
}, },
module: { module: {
rules: [ rules: [
@@ -38,7 +38,7 @@ export default {
use: [ use: [
MiniCssExtractPlugin.loader, MiniCssExtractPlugin.loader,
{ {
loader: "css-loader", loader: 'css-loader',
options: { options: {
importLoaders: 1 importLoaders: 1
} }
@@ -47,9 +47,9 @@ export default {
}, },
{ {
test: /\.(png|svg|jpg|jpeg|gif)$/i, test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource", type: 'asset/resource',
generator: { generator: {
filename: "src/[path][name][ext]", filename: 'src/[path][name][ext]',
}, },
}, },
], ],
@@ -57,15 +57,15 @@ export default {
plugins: [ plugins: [
new ESLintPlugin(), new ESLintPlugin(),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: "[name].css" filename: '[name].css'
}), }),
new CopyWebpackPlugin({ new CopyWebpackPlugin({
patterns: [ patterns: [
{ from: "public", to: "." }, { from: 'public', to: '.' },
{ from: "src/inject/preview", to: "inject/preview" }, { from: 'src/inject/preview', to: 'inject/preview' },
{ from: "node_modules/webextension-polyfill/dist/browser-polyfill.js", to: "."}, { from: 'node_modules/webextension-polyfill/dist/browser-polyfill.js', to: '.'},
{ from: "interface/dist/client", to: "client" }, { from: 'interface/dist/client', to: 'client' },
{ from: "interface/dist/index.html", to: "interface/index.html" } { from: 'interface/dist/index.html', to: 'interface/index.html' }
], ],
}), }),
], ],