mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-06-06 04:25:14 +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 jsonedit from 'gulp-json-editor'
|
||||||
import zip from 'gulp-zip'
|
import zip from 'gulp-zip'
|
||||||
|
|
||||||
import { execFile } from 'child_process'
|
import { execFile, exec } from 'child_process'
|
||||||
|
|
||||||
// script
|
// script
|
||||||
import standard from 'gulp-standard'
|
import standard from 'gulp-standard'
|
||||||
|
@ -62,7 +62,7 @@ function webpackTask (callback) {
|
||||||
chunks: false,
|
chunks: false,
|
||||||
chunkModules: 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
|
// creates extensions for chrome and firefox
|
||||||
gulp.task('pack', (done) => {
|
gulp.task('pack', (done) => {
|
||||||
sequence('default', ['pack:firefox', 'pack:chrome'], done)
|
sequence('default', ['pack:firefox', 'pack:chrome', 'pack:safari'], done)
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('pack:firefox', () => {
|
gulp.task('pack:firefox', () => {
|
||||||
|
@ -113,6 +113,7 @@ gulp.task('pack:firefox', () => {
|
||||||
.pipe(manifest)
|
.pipe(manifest)
|
||||||
.pipe(jsonedit(function (json) {
|
.pipe(jsonedit(function (json) {
|
||||||
if (json.content_scripts) {
|
if (json.content_scripts) {
|
||||||
|
// tweak the manifest so Firefox can read it
|
||||||
json.applications = {
|
json.applications = {
|
||||||
gecko: {
|
gecko: {
|
||||||
id: 'fimfic2epub@mozilla.org'
|
id: 'fimfic2epub@mozilla.org'
|
||||||
|
@ -137,3 +138,14 @@ gulp.task('pack:chrome', (done) => {
|
||||||
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
|
#!/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
|
rm -f extension.crx
|
||||||
|
|
||||||
|
|
13
src/main.js
13
src/main.js
|
@ -33,7 +33,9 @@ let tidyOptions = {
|
||||||
'alt-text': 'Image',
|
'alt-text': 'Image',
|
||||||
'wrap': '0',
|
'wrap': '0',
|
||||||
'quiet': 'yes',
|
'quiet': 'yes',
|
||||||
'show-warnings': 0
|
'show-warnings': 0,
|
||||||
|
'newline': 'LF',
|
||||||
|
'tidy-mark': 'no'
|
||||||
}
|
}
|
||||||
|
|
||||||
let mimeMap = {
|
let mimeMap = {
|
||||||
|
@ -42,13 +44,8 @@ let mimeMap = {
|
||||||
'image/gif': 'Images/*.gif'
|
'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]
|
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 storyInfo
|
||||||
let remoteResources = new Map()
|
let remoteResources = new Map()
|
||||||
let chapterContent = []
|
let chapterContent = []
|
||||||
|
@ -210,7 +207,7 @@ function downloadStory () {
|
||||||
|
|
||||||
console.log('Fetching story metadata...')
|
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
|
let data
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(raw)
|
data = JSON.parse(raw)
|
||||||
|
@ -236,7 +233,7 @@ function downloadStory () {
|
||||||
fetchChapters(function () {
|
fetchChapters(function () {
|
||||||
fetchRemoteFiles(zip, function () {
|
fetchRemoteFiles(zip, function () {
|
||||||
remoteResources.forEach((r, url) => {
|
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(
|
chapterContent[r.chapter] = chapterContent[r.chapter].replace(
|
||||||
new RegExp(escapeStringRegexp(r.originalUrl), 'g'),
|
new RegExp(escapeStringRegexp(r.originalUrl), 'g'),
|
||||||
r.dest
|
r.dest
|
||||||
|
|
|
@ -74,6 +74,12 @@ blockquote {
|
||||||
margin-bottom: 1.0em;
|
margin-bottom: 1.0em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#toc [hidden] {
|
#toc {
|
||||||
display: none;
|
ol {
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue