mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 19:54:39 +00:00
change to singlequotes
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user