Skip to content

Commit 5a7ab5e

Browse files
committed
feat: add mgtv support, fix all vendor support
1 parent 76fd2c6 commit 5a7ab5e

33 files changed

+8205
-5699
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"prettier.singleQuote": true
3+
}

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.6.0
2+
* Enables default HTTPS server by default.
3+
* Updated vendor support.
4+
* Dropped LeTV support.
5+
* Added MGTV support.
6+
17
0.5.0
28
* Added default HTTPS server support and options.
39

@@ -6,18 +12,18 @@
612
* Switched to SVG icons to get it work on YouTube.
713

814
0.4.2
9-
* Fixed player initialization for Bilibili and ACFun.
15+
* Fixed player initialization for bilibili and ACFun.
1016

1117
0.4.1
12-
* Added support for HTML5 player on Bilibili.
18+
* Added support for HTML5 player on bilibili.
1319

1420
0.4.0
1521
* Added AcFun support.
1622
* Fixed iframe players for Tencent Video.
1723

1824
0.3.4
1925
* Hot fix for connection failure on HTTP sites because of null exception.
20-
* Fixed occasional failure on Bilibili.
26+
* Fixed occasional failure on bilibili.
2127

2228
0.3.3
2329
* Fixed Youku player adaption for specific pages.

Gulpfile.js

Lines changed: 84 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,102 @@
11
var gulp = require('gulp');
22
var replace = require('gulp-replace');
33
var svgo = require('gulp-svgo');
4-
var Datauri = require('datauri');
54
var fs = require('fs');
65
var exec = require('child_process').exec;
76
var pack = require('./package.json');
87
var version = pack.version;
98

10-
gulp.task('icons', function () {
11-
return gulp.src('./assets/icons/*.svg')
9+
gulp.task('icons', function() {
10+
return gulp
11+
.src('./assets/icons/*.svg')
1212
.pipe(svgo())
1313
.pipe(gulp.dest('./dist/icons'));
1414
});
1515

16-
var svgPattern = /\.svg$/
17-
gulp.task('res', ['icons'], function () {
18-
var iconData = fs.readdirSync('./dist/icons').reduce(function (icons, file) {
19-
if (!file.match(svgPattern)) {
20-
return
21-
}
16+
var svgPattern = /\.svg$/;
17+
gulp.task(
18+
'res',
19+
gulp.series('icons', function() {
20+
var iconData = fs.readdirSync('./dist/icons').reduce(function(icons, file) {
21+
if (!file.match(svgPattern)) {
22+
return;
23+
}
2224

23-
var name = file.replace(svgPattern, '');
24-
icons[name] = fs.readFileSync('./dist/icons/' + file, 'utf8');
25-
return icons;
26-
}, {});
25+
var name = file.replace(svgPattern, '');
26+
icons[name] = fs.readFileSync('./dist/icons/' + file, 'utf8');
27+
return icons;
28+
}, {});
2729

28-
return gulp.src('./src/coplay.js')
29-
.pipe(replace('\'__ICONS__\'', JSON.stringify(iconData)))
30-
.pipe(gulp.dest('./extensions/chrome'))
31-
.pipe(gulp.dest('./extensions/firefox/data'));
32-
});
30+
return gulp
31+
.src('./src/coplay.js')
32+
.pipe(replace("'__ICONS__'", JSON.stringify(iconData)))
33+
.pipe(gulp.dest('./extensions/chrome'))
34+
.pipe(gulp.dest('./extensions/firefox'));
35+
})
36+
);
3337

34-
gulp.task('cp', ['res'], function () {
35-
return gulp.src(['./src/*', '!./src/coplay.js'])
36-
.pipe(gulp.dest('./extensions/chrome'))
37-
.pipe(gulp.dest('./extensions/firefox/data'));
38-
});
38+
gulp.task(
39+
'cp',
40+
gulp.series('res', function() {
41+
return gulp
42+
.src(['./src/*', '!./src/coplay.js'])
43+
.pipe(gulp.dest('./extensions/chrome'))
44+
.pipe(gulp.dest('./extensions/firefox'));
45+
})
46+
);
3947

40-
gulp.task('pack-chrome-extension', ['cp'], function (cb) {
41-
var manifestPath = './extensions/chrome/manifest.json';
42-
var manifest = JSON.parse(fs.readFileSync(manifestPath, { encoding: 'utf8' }));
43-
manifest.version = version;
44-
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, ' '));
45-
exec('find . -path \'*/.*\' -prune -o -type f -print | zip ../packed/coplay.zip -@', {
46-
cwd: 'extensions/chrome'
47-
}, function (error, stdout, stderr) {
48-
if (error) {
49-
return cb(error);
50-
} else {
51-
cb();
52-
}
53-
});
54-
});
48+
gulp.task(
49+
'pack-chrome-extension',
50+
gulp.series('cp', function(cb) {
51+
var manifestPath = './extensions/chrome/manifest.json';
52+
var manifest = JSON.parse(
53+
fs.readFileSync(manifestPath, { encoding: 'utf8' })
54+
);
55+
manifest.version = version;
56+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, ' '));
57+
exec(
58+
"find . -path '*/.*' -prune -o -type f -print | zip ../packed/coplay.chrome.zip -@",
59+
{
60+
cwd: 'extensions/chrome'
61+
},
62+
function(error) {
63+
if (error) {
64+
return cb(error);
65+
} else {
66+
cb();
67+
}
68+
}
69+
);
70+
})
71+
);
5572

56-
gulp.task('pack-firefox-addon', ['cp'], function (cb) {
57-
var fxPackPath = './extensions/firefox/package.json';
58-
var fxPack = JSON.parse(fs.readFileSync(fxPackPath, { encoding: 'utf8' }));
59-
fxPack.version = version;
60-
fs.writeFileSync(fxPackPath, JSON.stringify(fxPack, null, ' '));
61-
exec('jpm xpi', {
62-
cwd: 'extensions/firefox'
63-
}, function (error, stdout, stderr) {
64-
if (error) {
65-
return cb(error);
66-
} else {
67-
fs.renameSync('./extensions/firefox/' + pack.name + '.xpi', './extensions/packed/' + pack.name + '.xpi');
68-
cb();
69-
}
70-
});
71-
});
73+
gulp.task(
74+
'pack-firefox-addon',
75+
gulp.series('cp', function(cb) {
76+
var manifestPath = './extensions/firefox/manifest.json';
77+
var manifest = JSON.parse(
78+
fs.readFileSync(manifestPath, { encoding: 'utf8' })
79+
);
80+
manifest.version = version;
81+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, ' '));
82+
exec(
83+
"find . -path '*/.*' -prune -o -type f -print | zip ../packed/coplay.firefox.zip -@",
84+
{
85+
cwd: 'extensions/firefox'
86+
},
87+
function(error) {
88+
if (error) {
89+
return cb(error);
90+
} else {
91+
cb();
92+
}
93+
}
94+
);
95+
})
96+
);
7297

73-
gulp.task('extensions', ['pack-chrome-extension', 'pack-firefox-addon']);
74-
gulp.task('default', ['extensions']);
98+
gulp.task(
99+
'extensions',
100+
gulp.series('pack-chrome-extension', 'pack-firefox-addon')
101+
);
102+
gulp.task('default', gulp.series('extensions'));

0 commit comments

Comments
 (0)