mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-05-03 20:13:50 +12:00
attempt CORS fix
This commit is contained in:
parent
c5d9f00c2f
commit
ecf6e43cfd
|
@ -32,7 +32,7 @@
|
|||
</dict>
|
||||
<key>Whitelist</key>
|
||||
<array>
|
||||
<string>http://www.fimfiction.net/story/*</string>
|
||||
<string>https://fimfiction.net/story/*</string>
|
||||
<string>https://www.fimfiction.net/story/*</string>
|
||||
</array>
|
||||
</dict>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://www.fimfiction.net/*", "http://www.fimfiction.net/*"],
|
||||
"matches": ["https://www.fimfiction.net/*", "https://fimfiction.net/*"],
|
||||
"js": ["build/vendors_fimfic2epub.js", "build/fimfic2epub.js"],
|
||||
"css": ["inject.css"]
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ class FimFic2Epub extends EventEmitter {
|
|||
this.progress(0, 0, 'Fetching chapters...')
|
||||
|
||||
const chapterCount = this.storyInfo.chapters.length
|
||||
const url = 'https://fimfiction.net/story/download/' + this.storyInfo.id + '/html'
|
||||
const url = '/story/download/' + this.storyInfo.id + '/html'
|
||||
|
||||
this.pcache.chapters = fetch(url).then((html) => {
|
||||
let p = Promise.resolve()
|
||||
|
@ -813,7 +813,7 @@ class FimFic2Epub extends EventEmitter {
|
|||
const matchTag = /<a href="([^"]*?)" class="([^"]*?)" title="[^"]*?" data-tag="([^"]*?)".*?>(.*?)<\/a>/g
|
||||
for (;(c = matchTag.exec(tagsHtml));) {
|
||||
const cat = {
|
||||
url: 'https://fimfiction.net' + c[1],
|
||||
url: 'https://www.fimfiction.net' + c[1],
|
||||
className: 'story-tag ' + c[2],
|
||||
name: entities.decode(c[4]),
|
||||
type: c[2].replace('tag-', '')
|
||||
|
@ -829,7 +829,7 @@ class FimFic2Epub extends EventEmitter {
|
|||
let ma = html.match(/This story is a sequel to <a href="([^"]*)">(.*?)<\/a>/)
|
||||
if (ma) {
|
||||
this.storyInfo.prequel = {
|
||||
url: 'https://fimfiction.net' + ma[1],
|
||||
url: 'https://www.fimfiction.net' + ma[1],
|
||||
title: entities.decode(ma[2])
|
||||
}
|
||||
html = html.substring(html.indexOf('<hr />') + 6)
|
||||
|
|
10
src/fetch.js
10
src/fetch.js
|
@ -4,7 +4,7 @@ import isNode from 'detect-node'
|
|||
function fetchNode (url, responseType) {
|
||||
const fetch = require('node-fetch').default
|
||||
if (url.startsWith('/')) {
|
||||
url = 'https://fimfiction.net' + url
|
||||
url = 'https://www.fimfiction.net' + url
|
||||
}
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
|
@ -14,7 +14,7 @@ function fetchNode (url, responseType) {
|
|||
redirect: 'follow',
|
||||
headers: {
|
||||
cookie: 'view_mature=true',
|
||||
referer: 'https://fimfiction.net/',
|
||||
referer: 'https://www.fimfiction.net/',
|
||||
accept: 'Accept: text/*, image/png, image/jpeg' // Fix for not getting webp images from Fimfiction
|
||||
}
|
||||
}).then((response) => {
|
||||
|
@ -30,13 +30,13 @@ export default function fetch (url, responseType) {
|
|||
if (url.startsWith('//')) {
|
||||
url = 'http:' + url
|
||||
}
|
||||
if (url.startsWith('/')) {
|
||||
url = 'https://fimfiction.net' + url
|
||||
}
|
||||
|
||||
if (isNode) {
|
||||
return fetchNode(url, responseType)
|
||||
}
|
||||
if (url.startsWith('/')) {
|
||||
url = window.location.origin + url
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof window.fetch === 'function') {
|
||||
window.fetch(url, {
|
||||
|
|
Loading…
Reference in a new issue