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