mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-05-12 16:33:38 +12:00
some polishing
This commit is contained in:
parent
cbfb55e49b
commit
a4804519c0
|
@ -12,7 +12,7 @@ import filter from 'gulp-filter'
|
|||
import jsonedit from 'gulp-json-editor'
|
||||
import zip from 'gulp-zip'
|
||||
|
||||
import { execFile } from 'child_process'
|
||||
import { execFile, exec } from 'child_process'
|
||||
|
||||
// script
|
||||
import standard from 'gulp-standard'
|
||||
|
@ -62,7 +62,7 @@ function webpackTask (callback) {
|
|||
chunks: false,
|
||||
chunkModules: false
|
||||
}))
|
||||
callback()
|
||||
sequence(['pack:firefox', 'pack:chrome', 'pack:safari'], callback)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ gulp.task('watch', (done) => {
|
|||
|
||||
// creates extensions for chrome and firefox
|
||||
gulp.task('pack', (done) => {
|
||||
sequence('default', ['pack:firefox', 'pack:chrome'], done)
|
||||
sequence('default', ['pack:firefox', 'pack:chrome', 'pack:safari'], done)
|
||||
})
|
||||
|
||||
gulp.task('pack:firefox', () => {
|
||||
|
@ -113,6 +113,7 @@ gulp.task('pack:firefox', () => {
|
|||
.pipe(manifest)
|
||||
.pipe(jsonedit(function (json) {
|
||||
if (json.content_scripts) {
|
||||
// tweak the manifest so Firefox can read it
|
||||
json.applications = {
|
||||
gecko: {
|
||||
id: 'fimfic2epub@mozilla.org'
|
||||
|
@ -137,3 +138,14 @@ gulp.task('pack:chrome', (done) => {
|
|||
done()
|
||||
})
|
||||
})
|
||||
|
||||
gulp.task('pack:safari', (done) => {
|
||||
exec('cp -r extension/ fimfic2epub.safariextension', [], (error, stdout, stderr) => {
|
||||
// gutil.log('[pack:chrome]', stdout)
|
||||
if (error || stderr) {
|
||||
done(new gutil.PluginError('pack:safari', stderr, {showStack: false}))
|
||||
return
|
||||
}
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
CHROME=`command -v chrome || command -v chromium`
|
||||
CHROME=`command -v chrome || command -v chromium || command -v "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"`
|
||||
|
||||
rm -f extension.crx
|
||||
|
||||
|
|
13
src/main.js
13
src/main.js
|
@ -33,7 +33,9 @@ let tidyOptions = {
|
|||
'alt-text': 'Image',
|
||||
'wrap': '0',
|
||||
'quiet': 'yes',
|
||||
'show-warnings': 0
|
||||
'show-warnings': 0,
|
||||
'newline': 'LF',
|
||||
'tidy-mark': 'no'
|
||||
}
|
||||
|
||||
let mimeMap = {
|
||||
|
@ -42,13 +44,8 @@ let mimeMap = {
|
|||
'image/gif': 'Images/*.gif'
|
||||
}
|
||||
|
||||
// const STORY_ID = 180690 // bbcode test tags
|
||||
// const STORY_ID = 931 // pink eyes
|
||||
// const STORY_ID = 119190 // fallout equestria
|
||||
const STORY_ID = document.location.pathname.match(/^\/story\/(\d*)/)[1]
|
||||
|
||||
let apiUrl = 'https://www.fimfiction.net/api/story.php?story=' + STORY_ID
|
||||
|
||||
let storyInfo
|
||||
let remoteResources = new Map()
|
||||
let chapterContent = []
|
||||
|
@ -210,7 +207,7 @@ function downloadStory () {
|
|||
|
||||
console.log('Fetching story metadata...')
|
||||
|
||||
fetchRemote(apiUrl, function (raw, type) {
|
||||
fetchRemote('https://www.fimfiction.net/api/story.php?story=' + STORY_ID, function (raw, type) {
|
||||
let data
|
||||
try {
|
||||
data = JSON.parse(raw)
|
||||
|
@ -236,7 +233,7 @@ function downloadStory () {
|
|||
fetchChapters(function () {
|
||||
fetchRemoteFiles(zip, function () {
|
||||
remoteResources.forEach((r, url) => {
|
||||
if (r.chapter && r.originalUrl && r.dest) {
|
||||
if (typeof r.chapter !== 'undefined' && r.originalUrl && r.dest) {
|
||||
chapterContent[r.chapter] = chapterContent[r.chapter].replace(
|
||||
new RegExp(escapeStringRegexp(r.originalUrl), 'g'),
|
||||
r.dest
|
||||
|
|
|
@ -74,6 +74,12 @@ blockquote {
|
|||
margin-bottom: 1.0em;
|
||||
}
|
||||
|
||||
#toc [hidden] {
|
||||
display: none;
|
||||
#toc {
|
||||
ol {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue