mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-09-30 09:06:14 +13:00
Merge pull request #21 from Benny-/master
Title page for mature stories should work again on node.
This commit is contained in:
commit
731300070b
3 changed files with 7 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
CHROME=`command -v chrome || command -v chromium || command -v "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"`
|
CHROME=`command -v chrome || command -v chromium || command -v chromium-browser || command -v "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"`
|
||||||
|
|
||||||
rm -f extension.crx
|
rm -f extension.crx
|
||||||
|
|
||||||
|
|
|
@ -544,7 +544,7 @@ class FimFic2Epub extends Emitter {
|
||||||
|
|
||||||
fetchTitlePage () {
|
fetchTitlePage () {
|
||||||
let url = this.storyInfo.url.replace('http://www.fimfiction.net', '')
|
let url = this.storyInfo.url.replace('http://www.fimfiction.net', '')
|
||||||
return fetch(url + '?view_mature=true').then(this.extractTitlePageInfo.bind(this))
|
return fetch(url).then(this.extractTitlePageInfo.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
extractTitlePageInfo (html) {
|
extractTitlePageInfo (html) {
|
||||||
|
|
|
@ -11,7 +11,8 @@ function fetchNode (url, responseType) {
|
||||||
url: url,
|
url: url,
|
||||||
encoding: responseType ? null : 'utf8',
|
encoding: responseType ? null : 'utf8',
|
||||||
headers: {
|
headers: {
|
||||||
referer: 'http://www.fimfiction.net/'
|
referer: 'http://www.fimfiction.net/',
|
||||||
|
Cookie: 'view_mature=true',
|
||||||
}
|
}
|
||||||
}, (error, response, body) => {
|
}, (error, response, body) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -37,11 +38,14 @@ export default function fetch (url, responseType) {
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (typeof window.fetch === 'function') {
|
if (typeof window.fetch === 'function') {
|
||||||
|
const headers = new Headers()
|
||||||
|
headers.append("Cookie", "view_mature=true");
|
||||||
window.fetch(url, {
|
window.fetch(url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
mode: 'cors',
|
mode: 'cors',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
cache: 'default',
|
cache: 'default',
|
||||||
|
headers: headers,
|
||||||
redirect: 'follow'
|
redirect: 'follow'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (responseType === 'blob') {
|
if (responseType === 'blob') {
|
||||||
|
@ -61,7 +65,6 @@ export default function fetch (url, responseType) {
|
||||||
x.responseType = responseType
|
x.responseType = responseType
|
||||||
}
|
}
|
||||||
x.onload = function () {
|
x.onload = function () {
|
||||||
// x.getResponseHeader('content-type')
|
|
||||||
resolve(x.response)
|
resolve(x.response)
|
||||||
}
|
}
|
||||||
x.onerror = function () {
|
x.onerror = function () {
|
||||||
|
|
Loading…
Reference in a new issue