This commit is contained in:
ThaUnknown 2024-11-10 16:01:03 +01:00
parent 9be05949fc
commit 7039262404
3 changed files with 16 additions and 6 deletions

View file

@ -259,8 +259,7 @@ class AnilistClient {
credentials: 'omit', credentials: 'omit',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Accept: 'application/json', Accept: 'application/json'
Referer: 'https://anilist.co'
}, },
body: JSON.stringify({ body: JSON.stringify({
query: query.replace(/\s/g, '').replaceAll(' ', ' '), query: query.replace(/\s/g, '').replaceAll(' ', ' '),

View file

@ -42,8 +42,8 @@
"directories": { "directories": {
"buildResources": "buildResources" "buildResources": "buildResources"
}, },
"electronDist": "electron-dist",
"asarUnpack": "**/*.node", "asarUnpack": "**/*.node",
"electronDist": "./electron-dist",
"protocols": { "protocols": {
"name": "miru", "name": "miru",
"schemes": [ "schemes": [
@ -58,6 +58,9 @@
} }
], ],
"appId": "com.github.thaunknown.miru", "appId": "com.github.thaunknown.miru",
"electronLanguages": [
"en-US"
],
"productName": "Miru", "productName": "Miru",
"files": [ "files": [
"build/**/*", "build/**/*",
@ -115,6 +118,7 @@
"nsis": { "nsis": {
"allowToChangeInstallationDirectory": true, "allowToChangeInstallationDirectory": true,
"oneClick": false, "oneClick": false,
"perMachine": true,
"artifactName": "${os}-${name}-${version}-installer.${ext}" "artifactName": "${os}-${name}-${version}-installer.${ext}"
} }
} }

View file

@ -1,7 +1,7 @@
import { join } from 'node:path' import { join } from 'node:path'
import process from 'node:process' import process from 'node:process'
import { BrowserWindow, MessageChannelMain, Notification, app, dialog, ipcMain, nativeImage, powerMonitor, shell } from 'electron' import { BrowserWindow, MessageChannelMain, Notification, app, dialog, ipcMain, nativeImage, powerMonitor, session, shell } from 'electron'
import electronShutdownHandler from '@paymoapp/electron-shutdown-handler' import electronShutdownHandler from '@paymoapp/electron-shutdown-handler'
import { development } from './util.js' import { development } from './util.js'
@ -64,7 +64,7 @@ export default class App {
ipcMain.on('maximize', () => { ipcMain.on('maximize', () => {
const focusedWindow = this.mainWindow const focusedWindow = this.mainWindow
focusedWindow?.isMaximized() ? focusedWindow.unmaximize() : focusedWindow.maximize() focusedWindow?.isMaximized() ? focusedWindow.unmaximize() : focusedWindow.maximize()
}); })
app.on('before-quit', e => { app.on('before-quit', e => {
if (this.destroyed) return if (this.destroyed) return
e.preventDefault() e.preventDefault()
@ -117,6 +117,13 @@ export default class App {
this.mainWindow.webContents.openDevTools() this.mainWindow.webContents.openDevTools()
} }
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
if (details.url.startsWith('https://graphql.anilist.co')) {
details.requestHeaders.Referer = 'https://anilist.co'
}
callback({ cancel: false, requestHeaders: details.requestHeaders })
})
let crashcount = 0 let crashcount = 0
this.mainWindow.webContents.on('render-process-gone', async (e, { reason }) => { this.mainWindow.webContents.on('render-process-gone', async (e, { reason }) => {
if (reason === 'crashed') { if (reason === 'crashed') {
@ -158,4 +165,4 @@ export default class App {
this.destroyed = true this.destroyed = true
if (!this.updater.install(forceRunAfter)) app.quit() if (!this.updater.install(forceRunAfter)) app.quit()
} }
} }