Merge pull request #112 from Serraniel/feature/#32-option-menu

Feature/#32 option menu
This commit is contained in:
Daniel 2020-11-09 17:28:42 +01:00 committed by GitHub
commit 910cfa1b30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 876 additions and 90 deletions

View file

@ -9,6 +9,8 @@ const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const merge = require('merge-stream');
const fs = require('fs');
const factor = require('factor-bundle');
const { debug } = require('console');
const $ = gulpLoadPlugins()
@ -25,6 +27,7 @@ const src = {
styles: 'src/stylesheets',
scripts: 'src/javascript',
images: 'src/images',
html: 'src/html',
}
// Build path
@ -34,6 +37,7 @@ const tmp = {
styles: '.tmp/stylesheets',
scripts: '.tmp/javascript',
images: '.tmp/images',
html: '.tmp/html',
}
// Dist path
@ -44,18 +48,21 @@ const dist = {
styles: 'dist/chrome/stylesheets',
scripts: 'dist/chrome/javascript',
images: 'dist/chrome/images',
html: 'dist/chrome/html',
},
firefox: {
root: 'dist/firefox',
styles: 'dist/firefox/stylesheets',
scripts: 'dist/firefox/javascript',
images: 'dist/firefox/images',
html: 'dist/firefox/html',
},
opera: {
root: 'dist/opera',
styles: 'dist/opera/stylesheets',
scripts: 'dist/opera/javascript',
images: 'dist/opera/images',
html: 'dist/opera/html',
},
zip: 'dist/zips',
}
@ -108,14 +115,33 @@ gulp.task('styles', () => {
})
gulp.task('scripts', () => {
let b = browserify({
entries: `${src.scripts}/index.js`,
debug: isDev
const modules = [
'app',
'settings',
];
const inputs = [];
const streams = [];
modules.forEach(module => {
inputs.push(`${src.scripts}/${module}.js`);
streams.push(source(`${module}.js`));
});
return b.transform('babelify').bundle()
const b = browserify(inputs, { debug: isDev });
let outstream = b
.transform('babelify')
.plugin(factor, { outputs: streams })
.bundle()
.pipe(source('common.js'))
streams.forEach(stream => {
outstream = outstream.pipe($.merge(stream));
});
return outstream
.pipe($.plumber())
.pipe(source('app.js'))
.pipe(buffer())
.pipe($.if(isDev, $.sourcemaps.init({ loadMaps: true })))
.pipe($.terser({ compress: { drop_console: isProd, drop_debugger: isProd } }))
@ -124,7 +150,7 @@ gulp.task('scripts', () => {
showFiles: true,
}))
.pipe($.if(isDev, $.sourcemaps.write()))
.pipe(gulp.dest(`${tmp.scripts}`))
.pipe(gulp.dest(`${tmp.scripts}`));
})
gulp.task('images', () => {
@ -142,6 +168,16 @@ gulp.task('images', () => {
.pipe(gulp.dest(tmp.images))
})
gulp.task('html', () => {
return gulp.src(`${src.html}/**/*`)
.pipe($.plumber())
// any steps for HTML processing?
.pipe($.size({
showFiles: true,
}))
.pipe(gulp.dest(tmp.html))
})
gulp.task('manifests', () => {
const templateFile = `${src.manifests}/manifest.template.json`;
@ -174,6 +210,8 @@ gulp.task('watch', (done) => {
gulp.watch(`${src.images}/**/*`, gulp.series('clean:build', 'images', 'dist:copy', 'dist:zip'))
gulp.watch(`${src.html}/**/*`, gulp.series('clean:build', 'html', 'dist:copy', 'dist:zip'))
gulp.watch(`${src.manifests}/**/*.*`, gulp.series('clean:build', 'manifests', 'dist:copy', 'dist:zip'))
done();
@ -193,7 +231,7 @@ gulp.task('clean', gulp.series('clean:build', 'clean:dist'))
BUILD CLEAN ALL
============================================================================ */
gulp.task('build', gulp.series('manifests', 'images', 'scripts', 'styles'));
gulp.task('build', gulp.series('manifests', 'images', 'scripts', 'styles', 'html'));
gulp.task('build:clean', gulp.series('clean:build', 'manifests', 'images', 'scripts', 'styles'));
@ -215,6 +253,10 @@ gulp.task('dist:chrome', (done) => {
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
.pipe(gulp.dest(dist.chrome.styles)),
// copy html
gulp.src(`${tmp.html}/*.html`)
.pipe(gulp.dest(dist.chrome.html)),
gulp.src(`${tmp.manifests}/chrome*`)
.pipe($.rename('manifest.json'))
.pipe(gulp.dest(dist.chrome.root))
@ -235,6 +277,10 @@ gulp.task('dist:firefox', (done) => {
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
.pipe(gulp.dest(dist.firefox.styles)),
// copy html
gulp.src(`${tmp.html}/*.html`)
.pipe(gulp.dest(dist.firefox.html)),
gulp.src(`${tmp.manifests}/firefox*`)
.pipe($.rename('manifest.json'))
.pipe(gulp.dest(dist.firefox.root))
@ -255,6 +301,10 @@ gulp.task('dist:opera', (done) => {
gulp.src(`${tmp.styles}/*.{min.css,min.css.gz}`)
.pipe(gulp.dest(dist.opera.styles)),
// copy html
gulp.src(`${tmp.html}/*.html`)
.pipe(gulp.dest(dist.opera.html)),
gulp.src(`${tmp.manifests}/opera*`)
.pipe($.rename('manifest.json'))
.pipe(gulp.dest(dist.opera.root))

374
package-lock.json generated
View file

@ -4306,6 +4306,41 @@
"through2": "^2.0.0"
}
},
"deps-topo-sort": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/deps-topo-sort/-/deps-topo-sort-0.2.1.tgz",
"integrity": "sha1-S+ivB0dpcWSciwxIT9fUqHuLASo=",
"dev": true,
"requires": {
"JSONStream": "~0.7.1",
"minimist": "0.0.5",
"through": "~2.3.4"
},
"dependencies": {
"JSONStream": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.7.4.tgz",
"integrity": "sha1-c0KQ5BUR7qfCz+FR+/mlY6l7l4Y=",
"dev": true,
"requires": {
"jsonparse": "0.0.5",
"through": ">=2.2.7 <3"
}
},
"jsonparse": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz",
"integrity": "sha1-MwVCrT8KZUZlt3jz6y2an6UHrGQ=",
"dev": true
},
"minimist": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
"integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=",
"dev": true
}
}
},
"des.js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
@ -5066,6 +5101,228 @@
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
"dev": true
},
"factor-bundle": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/factor-bundle/-/factor-bundle-2.5.0.tgz",
"integrity": "sha1-jqiVfaOddYYoPMPuNTzZkRpF53k=",
"dev": true,
"requires": {
"JSONStream": "~0.8.4",
"browser-pack": "^5.0.1",
"defined": "0.0.0",
"deps-topo-sort": "~0.2.1",
"inherits": "^2.0.1",
"isarray": "0.0.1",
"labeled-stream-splicer": "^1.0.0",
"minimist": "~0.2.0",
"nub": "0.0.0",
"outpipe": "^1.1.0",
"reversepoint": "~0.2.0",
"stream-combiner": "~0.2.1",
"through2": "^0.5.1",
"xtend": "^4.0.0"
},
"dependencies": {
"JSONStream": {
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz",
"integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=",
"dev": true,
"requires": {
"jsonparse": "0.0.5",
"through": ">=2.2.7 <3"
},
"dependencies": {
"jsonparse": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz",
"integrity": "sha1-MwVCrT8KZUZlt3jz6y2an6UHrGQ=",
"dev": true
}
}
},
"browser-pack": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-5.0.1.tgz",
"integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=",
"dev": true,
"requires": {
"JSONStream": "^1.0.3",
"combine-source-map": "~0.6.1",
"defined": "^1.0.0",
"through2": "^1.0.0",
"umd": "^3.0.0"
},
"dependencies": {
"JSONStream": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
"integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==",
"dev": true,
"requires": {
"jsonparse": "^1.2.0",
"through": ">=2.2.7 <3"
}
},
"defined": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz",
"integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
"dev": true
},
"through2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz",
"integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=",
"dev": true,
"requires": {
"readable-stream": ">=1.1.13-1 <1.2.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
}
}
},
"combine-source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.6.1.tgz",
"integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=",
"dev": true,
"requires": {
"convert-source-map": "~1.1.0",
"inline-source-map": "~0.5.0",
"lodash.memoize": "~3.0.3",
"source-map": "~0.4.2"
}
},
"convert-source-map": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz",
"integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=",
"dev": true
},
"defined": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz",
"integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=",
"dev": true
},
"inline-source-map": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.5.0.tgz",
"integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=",
"dev": true,
"requires": {
"source-map": "~0.4.0"
}
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
"labeled-stream-splicer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz",
"integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"isarray": "~0.0.1",
"stream-splicer": "^1.1.0"
}
},
"minimist": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.1.tgz",
"integrity": "sha512-GY8fANSrTMfBVfInqJAY41QkOM+upUTytK1jZ0c8+3HdHrJxBJ3rF5i9moClXTE8uUSnUo8cAsCoxDXvSY4DHg==",
"dev": true
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"source-map": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
"dev": true,
"requires": {
"amdefine": ">=0.0.4"
}
},
"stream-splicer": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-1.3.2.tgz",
"integrity": "sha1-PARBvhW5v04iYnXm3IOWR0VUZmE=",
"dev": true,
"requires": {
"indexof": "0.0.1",
"inherits": "^2.0.1",
"isarray": "~0.0.1",
"readable-stream": "^1.1.13-1",
"readable-wrap": "^1.0.0",
"through2": "^1.0.0"
},
"dependencies": {
"through2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz",
"integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=",
"dev": true,
"requires": {
"readable-stream": ">=1.1.13-1 <1.2.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
}
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
},
"through2": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz",
"integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=",
"dev": true,
"requires": {
"readable-stream": "~1.0.17",
"xtend": "~3.0.0"
},
"dependencies": {
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"xtend": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz",
"integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=",
"dev": true
}
}
}
}
},
"fancy-log": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz",
@ -6074,6 +6331,51 @@
"minimatch": "^3.0.3"
}
},
"gulp-merge": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/gulp-merge/-/gulp-merge-0.1.1.tgz",
"integrity": "sha1-pGLuARd6jqfEYPDqia1ULsdSujc=",
"dev": true,
"requires": {
"through2": "~1.1.1"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
},
"through2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz",
"integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=",
"dev": true,
"requires": {
"readable-stream": ">=1.1.13-1 <1.2.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
}
}
},
"gulp-plumber": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/gulp-plumber/-/gulp-plumber-1.2.1.tgz",
@ -6855,6 +7157,12 @@
"integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=",
"dev": true
},
"indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
"dev": true
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -8369,6 +8677,12 @@
"boolbase": "~1.0.0"
}
},
"nub": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/nub/-/nub-0.0.0.tgz",
"integrity": "sha1-s2m9Mr3eZq9ZYFw7BSC8IZ3MwE8=",
"dev": true
},
"num2fraction": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz",
@ -8607,6 +8921,15 @@
"os-tmpdir": "^1.0.0"
}
},
"outpipe": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz",
"integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=",
"dev": true,
"requires": {
"shell-quote": "^1.4.2"
}
},
"p-cancelable": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz",
@ -10410,6 +10733,41 @@
}
}
},
"readable-wrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/readable-wrap/-/readable-wrap-1.0.0.tgz",
"integrity": "sha1-O1ohHGMeEjA6VJkcgGwX564ga/8=",
"dev": true,
"requires": {
"readable-stream": "^1.1.13-1"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
}
}
},
"readdirp": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz",
@ -10819,6 +11177,12 @@
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
"dev": true
},
"reversepoint": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/reversepoint/-/reversepoint-0.2.1.tgz",
"integrity": "sha1-0qw/9NZlzw/3Ipa3p47nI39lk/U=",
"dev": true
},
"rgb-regex": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/rgb-regex/-/rgb-regex-1.0.1.tgz",
@ -11546,6 +11910,16 @@
}
}
},
"stream-combiner": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz",
"integrity": "sha1-rsjLrBd7Vrb0+kec7YwZEs7lKFg=",
"dev": true,
"requires": {
"duplexer": "~0.1.1",
"through": "~2.3.4"
}
},
"stream-combiner2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz",

View file

@ -48,12 +48,14 @@
"cross-env": "^7.0.2",
"cssnano": "^4.1.10",
"del": "^6.0.0",
"factor-bundle": "^2.5.0",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.1",
"gulp-babel": "^8.0.0",
"gulp-if": "^3.0.0",
"gulp-imagemin": "^7.1.0",
"gulp-load-plugins": "^2.0.5",
"gulp-merge": "^0.1.1",
"gulp-plumber": "^1.2.1",
"gulp-postcss": "^9.0.0",
"gulp-rename": "^2.0.0",

58
src/html/settings.html Normal file
View file

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<title>Aniwatch Plus Settings</title>
<meta charset="utf-8" />
</head>
<body>
<form>
<h1>Aniwatch Plus Settings</h1>
<h2>General Settings</h2>
<hr />
<h3>Website</h3>
<input type="checkbox" id="websiteDisplayQuickSearch" data-default-value="true" />
<label for="websiteDisplayQuickSearch">Enable Quick Search</label><br />
<input type="checkbox" id="websiteShowNotificationsCountInTab" data-default-value="true" />
<label for="websiteShowNotificationsCountInTab">Show notification counter in browser tab</label><br />
<input type="checkbox" id="websiteHideUnusedTabs" data-default-value="true" />
<label for="websiteHideUnusedTabs">Hide tabs without functionality</label><br />
<input type="checkbox" id="websiteOptimizeListAppearance" data-default-value="true" />
<label for="websiteOptimizeListAppearance">Optimize appearance of lists</label><br />
<h3>Anime</h3>
<input type="checkbox" id="animeLanguageDisplay" data-default-value="true" />
<label for="animeLanguageDisplay">Optimize presentation of available subs and dubs</label><br />
<h3>Requests page</h3>
<input type="checkbox" id="requestBeautifyPage" data-default-value="true" />
<label for="requestBeautifyPage">Enhance "Requestes" page</label><br />
<h2>Player Settings</h2>
<hr />
<h3>General</h3>
<input type="checkbox" id="playerAutoplayAfterScreenshot" data-default-value="true" />
<label for="playerAutoplayAfterScreenshot">Autoplay after screenshots</label><br />
<h3>Watch2gether</h3>
<input type="checkbox" id="w2gDisplayCharacterCounter" data-default-value="true" />
<label for="w2gDisplayCharacterCounter">Display character count in chat</label><br />
<br /><br />
<button id="btnSave">Save</button>
<button id="btnReset">Reset</button>
<br />
<i>Please reload aniwatch website after you changed the settings.</i>
<hr />
<i id="version"></i> <i>- <a href="https://github.com/Serraniel/AniwatchPlus/releases">Changelogs</a></i>
</form>
<script src="../javascript/common.min.js"></script>
<script src="../javascript/settings.min.js"></script>
</body>
</html>

View file

@ -9,6 +9,8 @@ import { init as languageDisplay } from './enhancements/languageDisplay';
import { init as notifications } from './enhancements/notifications';
import { init as quickSearch } from './enhancements/quickSearch';
import { init as watch2getherChat } from './enhancements/watch2getherChat';
// css
import { init as cssEnhancements } from './enhancements/cssEnhancements';
// core
initCore();
@ -23,3 +25,6 @@ languageDisplay();
notifications();
quickSearch();
watch2getherChat();
// css
cssEnhancements();

View file

@ -0,0 +1,84 @@
const { assigned } = require("../utils/helpers")
class StorageProviderChromium {
setData(key, value) {
let obj = {};
obj[key] = value;
this.getStorage().set(obj);
}
getData(key, defaultValue, callback) {
this.getStorage().get(key, items => {
if (assigned(items) && assigned(items[key])) {
callback(items[key]);
}
else {
callback(defaultValue);
}
})
}
getStorage() {
if (assigned(chrome.storage.sync)) {
return chrome.storage.sync;
}
return chrome.storage.local;
}
}
class StorageProviderFirefox {
setData(key, value) {
let obj = {};
obj[key] = value;
this.getStorage().set(obj);
}
getData(key, defaultValue, callback) {
let promise = this.getStorage().get(key);
promise.then(items => {
if (assigned(items) && assigned(items[key])) {
callback(items[key]);
}
else {
callback(defaultValue);
}
});
}
getStorage() {
if (assigned(browser.storage.sync)) {
return browser.storage.sync;
}
return browser.storage.local;
}
}
let __storageProvieder;
function createStorageProvider() {
// chrome based browser
if (assigned(chrome?.app)) {
__storageProvieder = new StorageProviderChromium();
}
// firefox
else {
__storageProvieder = new StorageProviderFirefox();
}
}
export function getGlobalStorageProvider() {
if (!assigned(__storageProvieder)) {
createStorageProvider();
}
return __storageProvieder;
}

View file

@ -0,0 +1,44 @@
import { getGlobalStorageProvider } from "../browserApi/storageProvider";
import { assigned } from "../utils/helpers";
// website
export const SETTINGS_websiteDisplayQuickSearch = 'websiteDisplayQuickSearch';
export const SETTINGS_websiteShowNotificationsCountInTab = 'websiteShowNotificationsCountInTab';
export const SETTINGS_websiteHideUnusedTabs = 'websiteHideUnusedTabs';
export const SETTINGS_websiteOptimizeListAppearance = 'websiteOptimizeListAppearance';
// anime
export const SETTINGS_animeLanguageDisplay = 'animeLanguageDisplay';
// requests
export const SETTINGS_requestBeautifyPage = 'requestBeautifyPage';
// player
export const SETTINGS_playerAutoplayAfterScreenshot = 'playerAutoplayAfterScreenshot';
// w2g
export const SETTINGS_w2gDisplayCharacterCounter = 'w2gDisplayCharacterCounter';
class Configuration {
constructor() {
this.settingsCache = new Map();
}
getProperty(key, callback) {
if (this.settingsCache.has(key)) {
callback(this.settingsCache.get(key));
}
else {
// OOOPS // currently all settings are default true. This isn´t a problem but there should be much better soloutions after migration to typescript....
getGlobalStorageProvider().getData(key, true, value => {
this.settingsCache.set(key, value);
callback(value);
});
}
}
}
let __globalConfig;
export function getGlobalConfiguration() {
if (!assigned(__globalConfig)) {
__globalConfig = new Configuration();
}
return __globalConfig;
}

View file

@ -1,3 +1,4 @@
import { getGlobalConfiguration, SETTINGS_playerAutoplayAfterScreenshot } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers';
@ -5,11 +6,15 @@ const SCREENSHOT_TOOLTIP_ID = 'anilyr-screenshots-tooltip';
const PLAYER_ID = 'player';
export function init() {
core.registerScript(node => {
if (helper.isHtmlElement(node) && node.id === SCREENSHOT_TOOLTIP_ID) {
observeScreenshotTooltip(node);
getGlobalConfiguration().getProperty(SETTINGS_playerAutoplayAfterScreenshot, value => {
if (value) {
core.registerScript(node => {
if (helper.isHtmlElement(node) && node.id === SCREENSHOT_TOOLTIP_ID) {
observeScreenshotTooltip(node);
}
}, "^/anime/[0-9]*/[0-9]*$");
}
}, "^/anime/[0-9]*/[0-9]*$");
});
}
function observeScreenshotTooltip(tooltip) {
@ -18,7 +23,7 @@ function observeScreenshotTooltip(tooltip) {
// Switched to invisible
if (!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') {
let player = findPlayer();
if(typeof player !== 'undefined'){
if (typeof player !== 'undefined') {
resumePlayer(player);
}
}

View file

@ -1,16 +1,21 @@
import { getGlobalConfiguration, SETTINGS_requestBeautifyPage } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore';
import * as color from '../utils/colors';
import * as helper from '../utils/helpers';
export function init() {
core.registerScript(node => {
// run the scripts
if (helper.isHtmlElement(node)) {
changeFollowedStarColor(node);
changeBorderColorOwnRequests(node);
removeUnknownUsers(node);
getGlobalConfiguration().getProperty(SETTINGS_requestBeautifyPage, value => {
if (value) {
core.registerScript(node => {
// run the scripts
if (helper.isHtmlElement(node)) {
changeFollowedStarColor(node);
changeBorderColorOwnRequests(node);
removeUnknownUsers(node);
}
}, "/requests");
}
}, "/requests");
});
}
function changeFollowedStarColor(node) {
@ -71,7 +76,7 @@ function removeUnknownUsers(node) {
let parsedDocument = parser.parseFromString(profileData, 'text/html');
lowerDiv.innerHTML = '';
while(parsedDocument.body.hasChildNodes()){
while (parsedDocument.body.hasChildNodes()) {
lowerDiv.appendChild(parsedDocument.body.removeChild(parsedDocument.body.firstChild));
}
}

View file

@ -0,0 +1,61 @@
import { getGlobalConfiguration, SETTINGS_websiteHideUnusedTabs, SETTINGS_websiteOptimizeListAppearance } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers';
export function init() {
getGlobalConfiguration().getProperty(SETTINGS_websiteHideUnusedTabs, value => {
// if disabled, add class to avoid our css optimizations
if (!value) {
let disableFunc = node => {
if (helper.isHtmlElement(node)) {
let disableNode = node => {
node.classList.add('awp-hide-unused-disabled')
}
if (node.tagName === 'MD-TAB-ITEM') {
disableNode(node);
}
else {
node.querySelectorAll('md-tab-item').forEach(node => disableNode(node));
}
}
};
core.registerScript(node => {
disableFunc(node);
}, ".*");
core.runAfterLoad(() => {
disableFunc(document.body);
}, ".*");
}
});
getGlobalConfiguration().getProperty(SETTINGS_websiteOptimizeListAppearance, value => {
// if disabled, add class to avoid our css optimizations
if (!value) {
let disableFunc = node => {
if (helper.isHtmlElement(node)) {
let disableNode = node => {
node.classList.add('awp-list-disabled')
}
if (node.tagName === 'MD-LIST-ITEM') {
disableNode(node);
}
else {
node.querySelectorAll('md-list-item').forEach(node => disableNode(node));
}
}
}
core.registerScript(node => {
disableFunc(node);
}, ".*");
core.runAfterLoad(() => {
disableFunc(document.body);
}, ".*");
}
});
}

View file

@ -1,13 +1,18 @@
import { getGlobalConfiguration, SETTINGS_animeLanguageDisplay } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers';
export function init() {
core.registerScript(node => {
// run the scripts
if (helper.isHtmlElement(node)) {
updateLanguageDisplay(node)
getGlobalConfiguration().getProperty(SETTINGS_animeLanguageDisplay, value => {
if (value) {
core.registerScript(node => {
// run the scripts
if (helper.isHtmlElement(node)) {
updateLanguageDisplay(node)
}
}, "^/anime/[0-9]*$");
}
}, "^/anime/[0-9]*$");
});
}
function updateLanguageDisplay(node) {

View file

@ -1,14 +1,19 @@
import { getGlobalConfiguration, SETTINGS_websiteShowNotificationsCountInTab } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers';
export function init() {
core.runAfterLoad(() => {
updateNotificationsInTitle();
}, ".*");
getGlobalConfiguration().getProperty(SETTINGS_websiteShowNotificationsCountInTab, value => {
if (value) {
core.runAfterLoad(() => {
updateNotificationsInTitle();
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
}, ".*");
core.runAfterLocationChange(() => {
updateNotificationsInTitle();
}, ".*");
}
});
}
function getNotificationCount() {

View file

@ -1,3 +1,4 @@
import { getGlobalConfiguration, SETTINGS_websiteDisplayQuickSearch } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers';
@ -5,9 +6,13 @@ const quickSearchID = 'ea-quickSearch';
const quickSearchLink = 'ea-quickSearchLink';
export function init() {
core.runAfterLoad(() => {
initSearch();
}, ".*");
getGlobalConfiguration().getProperty(SETTINGS_websiteDisplayQuickSearch, value => {
if (value) {
core.runAfterLoad(() => {
initSearch();
}, ".*");
}
});
}
function initSearch() {

View file

@ -1,12 +1,15 @@
import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers';
import { v4 as uuidv4 } from 'uuid';
import { getGlobalConfiguration, SETTINGS_w2gDisplayCharacterCounter } from '../configuration/configuration';
export function init() {
// UPS // runAfterLoad is not what we want...wait for runAfterLocationChange....
core.runAfterLocationChange(() => {
manipulateChatInput();
}, "^/watch2gether/.*$");
getGlobalConfiguration().getProperty(SETTINGS_w2gDisplayCharacterCounter, value => {
if (value) {
core.runAfterLocationChange(() => {
manipulateChatInput();
}, "^/watch2gether/.*$");
}
});
}
function manipulateChatInput() {

View file

@ -0,0 +1,48 @@
import { getGlobalStorageProvider } from "./browserApi/storageProvider";
import { onReady } from "./utils/helpers";
const OPTION_SELECTOR = 'input[type="checkbox"';
function storeOptions() {
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
getGlobalStorageProvider().setData(optionElement.id, optionElement.checked);
});
}
function restoreOptions() {
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
let defaultValue = optionElement.dataset.defaultValue === 'true' ? true : false;
getGlobalStorageProvider().getData(optionElement.id, defaultValue, value => {
optionElement.checked = value;
});
});
}
function resetOptions() {
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
let defaultValue = optionElement.dataset.defaultValue === 'true' ? true : false;
optionElement.checked = defaultValue;
});
}
onReady(() => {
// register Store Button
document.getElementById('btnSave').addEventListener('click', event => {
event.preventDefault();
storeOptions();
});
document.getElementById('btnReset').addEventListener('click', event => {
event.preventDefault();
resetOptions();
storeOptions();
})
// try restore options
restoreOptions();
// update version label
document.getElementById('version').innerText = `v${chrome.runtime.getManifest().version}`
});

View file

@ -5,6 +5,7 @@
"version_name": "$semanticVersion",
"description": "$description",
"permissions": [
"storage",
"*://aniwatch.me/*"
],
"manifest_version": 2,
@ -14,16 +15,23 @@
"48": "images/icon/icon_48.png",
"96": "images/icon/icon_96.png"
},
"content_scripts": [{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}]
"options_ui": {
"page": "html/settings.html",
"open_in_tab": false
},
"content_scripts": [
{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/common.min.js",
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}
]
}

View file

@ -4,6 +4,7 @@
"version": "$version",
"description": "$description",
"permissions": [
"storage",
"*://aniwatch.me/*"
],
"manifest_version": 2,
@ -14,16 +15,23 @@
"48": "images/icon/icon_48.png",
"96": "images/icon/icon_96.png"
},
"content_scripts": [{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}]
"options_ui": {
"page": "html/settings.html",
"open_in_tab": false
},
"content_scripts": [
{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/common.min.js",
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}
]
}

View file

@ -5,6 +5,7 @@
"version_name": "0.3.1 Beta",
"description": "Aniwatch Plus is an unofficial extension which provides several UI improvments for https://aniwatch.me.",
"permissions": [
"storage",
"*://aniwatch.me/*"
],
"manifest_version": 2,
@ -18,16 +19,23 @@
"48": "images/icon/icon_48.png",
"96": "images/icon/icon_96.png"
},
"content_scripts": [{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}]
"options_ui": {
"page": "html/settings.html",
"open_in_tab": false
},
"content_scripts": [
{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/common.min.js",
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}
]
}

View file

@ -5,6 +5,7 @@
"version_name": "$semanticVersion",
"description": "$description",
"permissions": [
"storage",
"*://aniwatch.me/*"
],
"manifest_version": 2,
@ -15,16 +16,23 @@
"48": "images/icon/icon_48.png",
"96": "images/icon/icon_96.png"
},
"content_scripts": [{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}]
"options_ui": {
"page": "html/settings.html",
"open_in_tab": false
},
"content_scripts": [
{
"matches": [
"*://aniwatch.me/*"
],
"js": [
"javascript/common.min.js",
"javascript/app.min.js"
],
"css": [
"stylesheets/aniwatchplus.min.css"
],
"run_at": "document_end"
}
]
}

View file

@ -1,5 +1,5 @@
md-list-item {
&:not(:last-child) {
&:not(:last-child):not(.awp-list-disabled) {
// added important to override aniwatch new introduced border which has a different, more "aggressive" color
// https://canary.discord.com/channels/541683465599451136/543812424541798421/773621830161268756
border-bottom: 1px solid $gray !important;

View file

@ -1,6 +1,6 @@
md-tab-item {
// hide disabled tabs
&.md-disabled {
&.md-disabled:not(.awp-hide-unused-disabled) {
display: none;
}
}