mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-09-18 18:27:33 +12:00
firefox extension support!
This commit is contained in:
parent
0587849429
commit
ea35fe3c50
6 changed files with 57 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ node_modules/
|
|||
extension/fimfic2epub.js
|
||||
extension.crx
|
||||
extension.pem
|
||||
extension.xpi
|
||||
|
|
|
@ -21,7 +21,9 @@ function fetch (url, cb, type) {
|
|||
x.send()
|
||||
}
|
||||
|
||||
chrome.extension.onMessage.addListener(function (request, sender, sendResponse) {
|
||||
let onMessage = chrome.extension.onMessage ? chrome.extension.onMessage : chrome.runtime.onMessage
|
||||
|
||||
onMessage.addListener(function (request, sender, sendResponse) {
|
||||
fetch(request, sendResponse, 'blob')
|
||||
return true
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
"name": "fimfic2epub",
|
||||
"description": "",
|
||||
"version": "1.0",
|
||||
"version": "1.0.1",
|
||||
|
||||
"background": {
|
||||
"scripts": ["eventPage.js"],
|
||||
|
|
|
@ -9,6 +9,11 @@ import watch from 'gulp-watch'
|
|||
import lazypipe from 'lazypipe'
|
||||
import filter from 'gulp-filter'
|
||||
|
||||
import jsonedit from 'gulp-json-editor'
|
||||
import zip from 'gulp-zip'
|
||||
|
||||
import { execFile } from 'child_process'
|
||||
|
||||
// script
|
||||
import standard from 'gulp-standard'
|
||||
import webpack from 'webpack'
|
||||
|
@ -95,3 +100,40 @@ gulp.task('default', (done) => {
|
|||
gulp.task('watch', (done) => {
|
||||
sequence('default', ['watch:lint', 'watch:webpack'], done)
|
||||
})
|
||||
|
||||
// creates extensions for chrome and firefox
|
||||
gulp.task('pack', (done) => {
|
||||
sequence('default', ['pack:firefox', 'pack:chrome'], done)
|
||||
})
|
||||
|
||||
gulp.task('pack:firefox', () => {
|
||||
let manifest = filter('extension/manifest.json', {restore: true})
|
||||
|
||||
return gulp.src('extension/**/*')
|
||||
.pipe(manifest)
|
||||
.pipe(jsonedit(function (json) {
|
||||
if (json.content_scripts) {
|
||||
json.applications = {
|
||||
gecko: {
|
||||
id: 'fimfic2epub@mozilla.org'
|
||||
}
|
||||
}
|
||||
delete json.background.persistent
|
||||
}
|
||||
return json
|
||||
}))
|
||||
.pipe(manifest.restore)
|
||||
.pipe(zip('extension.xpi'))
|
||||
.pipe(gulp.dest('./'))
|
||||
})
|
||||
|
||||
gulp.task('pack:chrome', (done) => {
|
||||
execFile('./packchrome.sh', [], (error, stdout, stderr) => {
|
||||
// gutil.log('[pack:chrome]', stdout)
|
||||
if (error || stderr) {
|
||||
done(new gutil.PluginError('pack:chrome', stderr, {showStack: false}))
|
||||
return
|
||||
}
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"name": "fimfic2epub.js",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "",
|
||||
"author": "djazz",
|
||||
"scripts": {
|
||||
"pack": "./pack.sh"
|
||||
"pack": "gulp pack -p"
|
||||
},
|
||||
"dependencies": {
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
|
@ -26,9 +26,11 @@
|
|||
"exports-loader": "^0.6.3",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-filter": "^4.0.0",
|
||||
"gulp-json-editor": "^2.2.1",
|
||||
"gulp-standard": "^7.0.1",
|
||||
"gulp-util": "^3.0.7",
|
||||
"gulp-watch": "^4.3.8",
|
||||
"gulp-zip": "^3.2.0",
|
||||
"lazypipe": "^1.0.1",
|
||||
"raw-loader": "^0.5.1",
|
||||
"run-sequence": "^1.2.1",
|
||||
|
@ -39,8 +41,7 @@
|
|||
},
|
||||
"standard": {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true
|
||||
"browser": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
PATH=node_modules/.bin:$PATH
|
||||
|
||||
gulp -p
|
||||
|
||||
CHROME=`command -v chrome || command -v chromium`
|
||||
|
||||
rm -f extension.crx
|
||||
|
@ -11,15 +7,17 @@ rm -f extension.crx
|
|||
code=-1
|
||||
|
||||
if [ ! -f extension.pem ]; then
|
||||
echo "Packing chrome extension and generating private key..."
|
||||
echo "Packaging Chrome extension and generating private key..."
|
||||
"${CHROME}" --pack-extension=extension
|
||||
code=$?
|
||||
else
|
||||
echo "Packing chrome extension with existing key..."
|
||||
echo "Packaging Chrome extension with existing key..."
|
||||
"${CHROME}" --pack-extension=extension --pack-extension-key=extension.pem
|
||||
code=$?
|
||||
fi
|
||||
|
||||
if [ ! -f extension.crx ]; then
|
||||
echo "Something went wrong, Chrome error code ${code}"
|
||||
>&2 echo "Something went wrong, Chrome error code ${code}"
|
||||
exit $code
|
||||
fi
|
||||
|
Loading…
Reference in a new issue