Skip to content

Commit

Permalink
fix: #583
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Nov 10, 2024
1 parent 9be0594 commit 7039262
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 1 addition & 2 deletions common/modules/anilist.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ class AnilistClient {
credentials: 'omit',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Referer: 'https://anilist.co'
Accept: 'application/json'
},
body: JSON.stringify({
query: query.replace(/\s/g, '').replaceAll(' ', ' '),
Expand Down
6 changes: 5 additions & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"directories": {
"buildResources": "buildResources"
},
"electronDist": "electron-dist",
"asarUnpack": "**/*.node",
"electronDist": "./electron-dist",
"protocols": {
"name": "miru",
"schemes": [
Expand All @@ -58,6 +58,9 @@
}
],
"appId": "com.github.thaunknown.miru",
"electronLanguages": [
"en-US"
],
"productName": "Miru",
"files": [
"build/**/*",
Expand Down Expand Up @@ -115,6 +118,7 @@
"nsis": {
"allowToChangeInstallationDirectory": true,
"oneClick": false,
"perMachine": true,
"artifactName": "${os}-${name}-${version}-installer.${ext}"
}
}
Expand Down
13 changes: 10 additions & 3 deletions electron/src/main/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'node:path'
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 { development } from './util.js'
Expand Down Expand Up @@ -64,7 +64,7 @@ export default class App {
ipcMain.on('maximize', () => {
const focusedWindow = this.mainWindow
focusedWindow?.isMaximized() ? focusedWindow.unmaximize() : focusedWindow.maximize()
});
})
app.on('before-quit', e => {
if (this.destroyed) return
e.preventDefault()
Expand Down Expand Up @@ -117,6 +117,13 @@ export default class App {
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
this.mainWindow.webContents.on('render-process-gone', async (e, { reason }) => {
if (reason === 'crashed') {
Expand Down Expand Up @@ -158,4 +165,4 @@ export default class App {
this.destroyed = true
if (!this.updater.install(forceRunAfter)) app.quit()
}
}
}

0 comments on commit 7039262

Please sign in to comment.