feat: fake request referer

This commit is contained in:
DIYgod 2024-04-16 12:14:50 +08:00
parent bd1571b359
commit ec1e12257e
No known key found for this signature in database
2 changed files with 20 additions and 0 deletions

View File

@ -34,6 +34,25 @@ function createWindow(): void {
} else {
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
}
const refererMatchs = [{
url: /^https:\/\/\w+\.sinaimg.cn/,
referer: 'https://weibo.com'
}, {
url: /^https:\/\/i\.pximg\.net/,
referer: 'https://www.pixiv.net'
}]
mainWindow.webContents.session.webRequest.onBeforeSendHeaders(
(details, callback) => {
const refererMatch = refererMatchs.find((item) => item.url.test(details.url))
callback({
requestHeaders: {
...details.requestHeaders,
Referer: refererMatch?.referer || details.url
}
});
},
);
}
// This method will be called when Electron has finished

View File

@ -22,6 +22,7 @@ export const useEntries = ({
}
})).json()
entries.entries = await Promise.all(entries.entries.map(async (entry) => {
entry.content = entry.content.replaceAll('https://pixiv.diygod.me/', 'https://i.pximg.net/');
const parsed = await parseHtml(entry.content)
return {
...entry,