diff --git a/src-tauri/src/app/invoke.rs b/src-tauri/src/app/invoke.rs index 0ce25de..c643698 100644 --- a/src-tauri/src/app/invoke.rs +++ b/src-tauri/src/app/invoke.rs @@ -127,4 +127,4 @@ pub fn update_theme_mode(app: AppHandle, mode: String) { }; let _ = window.set_theme(Some(theme)); } -} \ No newline at end of file +} diff --git a/src-tauri/src/inject/auth.js b/src-tauri/src/inject/auth.js index f48caa2..c045baa 100644 --- a/src-tauri/src/inject/auth.js +++ b/src-tauri/src/inject/auth.js @@ -2,71 +2,71 @@ // Check if URL matches OAuth/authentication patterns function matchesAuthUrl(url, baseUrl = window.location.href) { - try { - const urlObj = new URL(url, baseUrl); - const hostname = urlObj.hostname.toLowerCase(); - const pathname = urlObj.pathname.toLowerCase(); - const fullUrl = urlObj.href.toLowerCase(); + try { + const urlObj = new URL(url, baseUrl); + const hostname = urlObj.hostname.toLowerCase(); + const pathname = urlObj.pathname.toLowerCase(); + const fullUrl = urlObj.href.toLowerCase(); - // Common OAuth providers and paths - const oauthPatterns = [ - /accounts\.google\.com/, - /accounts\.google\.[a-z]+/, - /login\.microsoftonline\.com/, - /github\.com\/login/, - /facebook\.com\/.*\/dialog/, - /twitter\.com\/oauth/, - /appleid\.apple\.com/, - /\/oauth\//, - /\/auth\//, - /\/authorize/, - /\/login\/oauth/, - /\/signin/, - /\/login/, - /servicelogin/, - /\/o\/oauth2/, - ]; + // Common OAuth providers and paths + const oauthPatterns = [ + /accounts\.google\.com/, + /accounts\.google\.[a-z]+/, + /login\.microsoftonline\.com/, + /github\.com\/login/, + /facebook\.com\/.*\/dialog/, + /twitter\.com\/oauth/, + /appleid\.apple\.com/, + /\/oauth\//, + /\/auth\//, + /\/authorize/, + /\/login\/oauth/, + /\/signin/, + /\/login/, + /servicelogin/, + /\/o\/oauth2/, + ]; - const isMatch = oauthPatterns.some( - (pattern) => - pattern.test(hostname) || - pattern.test(pathname) || - pattern.test(fullUrl), - ); + const isMatch = oauthPatterns.some( + (pattern) => + pattern.test(hostname) || + pattern.test(pathname) || + pattern.test(fullUrl), + ); - if (isMatch) { - console.log("[Pake] OAuth URL detected:", url); - } - - return isMatch; - } catch (e) { - return false; + if (isMatch) { + console.log("[Pake] OAuth URL detected:", url); } + + return isMatch; + } catch (e) { + return false; + } } // Check if URL is an OAuth/authentication link function isAuthLink(url) { - return matchesAuthUrl(url); + return matchesAuthUrl(url); } // Check if this is an OAuth/authentication popup function isAuthPopup(url, name) { - // Check for known authentication window names - const authWindowNames = [ - "AppleAuthentication", - "oauth2", - "oauth", - "google-auth", - "auth-popup", - "signin", - "login", - ]; + // Check for known authentication window names + const authWindowNames = [ + "AppleAuthentication", + "oauth2", + "oauth", + "google-auth", + "auth-popup", + "signin", + "login", + ]; - if (authWindowNames.includes(name)) { - return true; - } + if (authWindowNames.includes(name)) { + return true; + } - return matchesAuthUrl(url); + return matchesAuthUrl(url); } // Export functions to global scope diff --git a/src-tauri/src/inject/theme_refresh.js b/src-tauri/src/inject/theme_refresh.js index 041ad28..b86d7dc 100644 --- a/src-tauri/src/inject/theme_refresh.js +++ b/src-tauri/src/inject/theme_refresh.js @@ -62,16 +62,25 @@ document.addEventListener("DOMContentLoaded", () => { // This is useful when the site relies purely on CSS media queries without classes. if (!detected) { const bodyBg = window.getComputedStyle(document.body).backgroundColor; - const htmlBg = window.getComputedStyle(document.documentElement).backgroundColor; - + const htmlBg = window.getComputedStyle( + document.documentElement, + ).backgroundColor; + // Check body first, then html if (bodyBg && bodyBg !== "rgba(0, 0, 0, 0)" && bodyBg !== "transparent") { mode = isDarkColor(bodyBg) ? "dark" : "light"; - } else if (htmlBg && htmlBg !== "rgba(0, 0, 0, 0)" && htmlBg !== "transparent") { + } else if ( + htmlBg && + htmlBg !== "rgba(0, 0, 0, 0)" && + htmlBg !== "transparent" + ) { mode = isDarkColor(htmlBg) ? "dark" : "light"; } else { // Strategy 3: System Preference (Last Resort) - if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) { + if ( + window.matchMedia && + window.matchMedia("(prefers-color-scheme: dark)").matches + ) { mode = "dark"; } } @@ -91,7 +100,9 @@ document.addEventListener("DOMContentLoaded", () => { setTimeout(updateTheme, 100); // Watch for system theme changes - window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", updateTheme); + window + .matchMedia("(prefers-color-scheme: dark)") + .addEventListener("change", updateTheme); // Watch for DOM changes // We observe attributes for class changes, and also style changes just in case @@ -102,12 +113,12 @@ document.addEventListener("DOMContentLoaded", () => { observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "data-theme", "style"], - subtree: false + subtree: false, }); - - observer.observe(document.body, { - attributes: true, + + observer.observe(document.body, { + attributes: true, attributeFilter: ["class", "data-theme", "style"], - subtree: false + subtree: false, }); });