Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 10361cf3c0 |
15
main.js
15
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://*/*'] },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ESH-Media",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"private": true,
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -21,6 +21,7 @@ const Header: React.FC<HeaderProps> = ({ activeApp, setActiveApp, onAppsChange,
|
||||
const [rightDisabled, setRightDisabled] = useState(true)
|
||||
const [refreshDisabled, setRefreshDisabled] = useState(true)
|
||||
const [showSettings, setShowSettings] = useState(false)
|
||||
const [currentUrl, setCurrentUrl] = useState<string>('')
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const activeAppRef = useRef(activeApp)
|
||||
useEffect(() => { activeAppRef.current = activeApp }, [activeApp])
|
||||
@@ -36,6 +37,7 @@ const Header: React.FC<HeaderProps> = ({ 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<HeaderProps> = ({ 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 (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user