mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-09-28 15:21:34 +12:00
small fixes
This commit is contained in:
parent
f3301facda
commit
7a95d40c77
3 changed files with 12 additions and 7 deletions
|
@ -16,7 +16,9 @@ export async function cleanMarkup (html) {
|
||||||
}
|
}
|
||||||
|
|
||||||
html = twemoji.parse(html, {ext: '.svg', folder: 'svg'})
|
html = twemoji.parse(html, {ext: '.svg', folder: 'svg'})
|
||||||
|
|
||||||
// replace HTML entities with decimal entities
|
// replace HTML entities with decimal entities
|
||||||
|
html = html.replace(/\xA0/g, ' ')
|
||||||
html = html.replace(/ /g, ' ')
|
html = html.replace(/ /g, ' ')
|
||||||
html = html.replace(/ /g, ' ')
|
html = html.replace(/ /g, ' ')
|
||||||
|
|
||||||
|
@ -50,7 +52,7 @@ export async function cleanMarkup (html) {
|
||||||
html = html.replace(matchLink, (match, head, url, tail) => {
|
html = html.replace(matchLink, (match, head, url, tail) => {
|
||||||
if (url.substring(0, 1) !== '#' && url.substring(0, 2) !== '//' && url.substring(0, 4) !== 'http') {
|
if (url.substring(0, 1) !== '#' && url.substring(0, 2) !== '//' && url.substring(0, 4) !== 'http') {
|
||||||
if (url.substring(0, 1) === '/') {
|
if (url.substring(0, 1) === '/') {
|
||||||
url = 'http://www.fimfiction.net' + entities.decode(url)
|
url = 'https://fimfiction.net' + entities.decode(url)
|
||||||
} else {
|
} else {
|
||||||
// do something else
|
// do something else
|
||||||
}
|
}
|
||||||
|
@ -86,7 +88,10 @@ export async function cleanMarkup (html) {
|
||||||
let data = []
|
let data = []
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(raw).items
|
data = JSON.parse(raw).items
|
||||||
} catch (e) { }
|
} catch (e) {}
|
||||||
|
if (!data) {
|
||||||
|
data = []
|
||||||
|
}
|
||||||
data.forEach((video) => {
|
data.forEach((video) => {
|
||||||
cache.set(video.id, video.snippet)
|
cache.set(video.id, video.snippet)
|
||||||
completeCount++
|
completeCount++
|
||||||
|
@ -100,7 +105,7 @@ export async function cleanMarkup (html) {
|
||||||
|
|
||||||
function replaceYouTube (match, id) {
|
function replaceYouTube (match, id) {
|
||||||
let youtubeId = id
|
let youtubeId = id
|
||||||
let thumbnail = 'http://img.youtube.com/vi/' + youtubeId + '/hqdefault.jpg'
|
let thumbnail = 'https://img.youtube.com/vi/' + youtubeId + '/hqdefault.jpg'
|
||||||
let youtubeUrl = 'https://youtube.com/watch?v=' + youtubeId
|
let youtubeUrl = 'https://youtube.com/watch?v=' + youtubeId
|
||||||
let title = 'Youtube Video'
|
let title = 'Youtube Video'
|
||||||
let caption = ''
|
let caption = ''
|
||||||
|
|
|
@ -56,10 +56,10 @@ function fetchBackground (url, responseType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function fetchRemote (url, responseType) {
|
export default function fetchRemote (url, responseType) {
|
||||||
if (url.indexOf('//') === 0) {
|
if (url.startsWith('//')) {
|
||||||
url = 'http:' + url
|
url = 'https:' + url
|
||||||
}
|
}
|
||||||
if (!isNode && document.location.protocol === 'https:' && url.indexOf('http:') === 0) {
|
if (!isNode && document.location.protocol === 'https:' && url.startsWith('http:')) {
|
||||||
return fetchBackground(url, responseType)
|
return fetchBackground(url, responseType)
|
||||||
}
|
}
|
||||||
return fetch(url, responseType).then((data) => {
|
return fetch(url, responseType).then((data) => {
|
||||||
|
|
|
@ -11,6 +11,6 @@ export default function htmlWordCount (html) {
|
||||||
let count = 0
|
let count = 0
|
||||||
try {
|
try {
|
||||||
count = matchWords(text).length
|
count = matchWords(text).length
|
||||||
} catch (err) {}
|
} catch (err) { count = 0 }
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue