diff --git a/main.js b/main.js index 1778d26..84f00d1 100644 --- a/main.js +++ b/main.js @@ -110,6 +110,7 @@ let pendingNavigate = null; // { view, url } — cross-domain redirect awaiting function getProxySession() { if (!proxySession) { proxySession = session.fromPartition('persist:proxy'); + proxySession.setUserAgent(app.userAgentFallback); enableBlockingInSession(proxySession); } return proxySession; @@ -118,6 +119,7 @@ function getProxySession() { function getDirectSession() { if (!directSession) { directSession = session.fromPartition('persist:direct'); + directSession.setUserAgent(app.userAgentFallback); directSession.setProxy({ proxyRules: 'direct://' }); enableBlockingInSession(directSession); } @@ -981,6 +983,19 @@ ipcMain.on('action', (_event, action) => { // --- App lifecycle --- app.whenReady().then(async () => { + // Strip Electron/app tokens from User-Agent: Google blocks Electron's default UA + // with "Поддержка JavaScript отключена" on accounts.google.com. We keep the Chrome + // version Electron advertises (sufficient for modern features) but remove the + // Electron/X.X.X and ESH-Media/X.X.X identifiers. + const cleanUserAgent = app.userAgentFallback + .replace(/Electron\/[\d.]+\s*/g, '') + .replace(/ESH-Media\/[\d.]+\s*/g, '') + .replace(/\s+/g, ' ') + .trim(); + console.log('[ua]', cleanUserAgent); + app.userAgentFallback = cleanUserAgent; + session.defaultSession.setUserAgent(cleanUserAgent); + // Add Referer to image requests so hotlink protection doesn't block them session.defaultSession.webRequest.onBeforeSendHeaders( { urls: ['https://*/*', 'http://*/*'] }, diff --git a/package.json b/package.json index 8ce5c61..bf8be00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ESH-Media", - "version": "1.0.1", + "version": "1.0.2", "private": true, "main": "main.js", "scripts": { diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 6d54132..eb30ab3 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -21,6 +21,7 @@ const Header: React.FC = ({ activeApp, setActiveApp, onAppsChange, const [rightDisabled, setRightDisabled] = useState(true) const [refreshDisabled, setRefreshDisabled] = useState(true) const [showSettings, setShowSettings] = useState(false) + const [currentUrl, setCurrentUrl] = useState('') const timeoutRef = useRef | null>(null) const activeAppRef = useRef(activeApp) useEffect(() => { activeAppRef.current = activeApp }, [activeApp]) @@ -36,6 +37,7 @@ const Header: React.FC = ({ activeApp, setActiveApp, onAppsChange, setLeftDisabled(app.historyPosition === 0) setRightDisabled(app.historyPosition === app.history.length - 1) setRefreshDisabled(false) + setCurrentUrl(app.history[app.historyPosition] || '') }) return () => { offCloseApp(); offWebButtons() } }, [setActiveApp]) @@ -149,12 +151,9 @@ const Header: React.FC = ({ activeApp, setActiveApp, onAppsChange, } useEffect(() => { - if (!appOpen) { setIsBookmarked(false); return } - window.electron?.getCurrentPage().then((page: any) => { - if (!page) return - setIsBookmarked(bookmarks.some(b => b.url === page.url)) - }) - }, [activeApp, bookmarks, appOpen]) + if (!appOpen || !currentUrl) { setIsBookmarked(false); return } + setIsBookmarked(bookmarks.some(b => b.url === currentUrl)) + }, [currentUrl, bookmarks, appOpen]) return ( <>