Skip to content

Commit 6badc97

Browse files
committed
feat: upgrade to Manifest V3 in Chrome
BREAKING CHANGE: browser versions older than Chrome 123, Edge 123, Firefox 115 and Opera 109 are no longer supported
1 parent c330587 commit 6badc97

30 files changed

+13463
-15731
lines changed

.browserslistrc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[chrome]
2-
Chrome >= 92
3-
Edge >= 92
4-
Opera >= 78
2+
Chrome >= 123
3+
Edge >= 123
4+
Opera >= 109
55

66
[edge]
7-
Edge >= 92
7+
Edge >= 123
88

99
[firefox]
10-
Firefox >= 91
11-
FirefoxAndroid >= 91
10+
Firefox >= 115

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
contents: read
1111
steps:
1212
- name: Clone repository
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
persist-credentials: 'false'
1616
- name: Setup Node.js
17-
uses: actions/setup-node@v3
17+
uses: actions/setup-node@v4
1818
with:
1919
node-version-file: '.nvmrc'
2020
cache: 'npm'
@@ -29,7 +29,7 @@ jobs:
2929
run: sha256sum artifacts/*/*
3030
if: startsWith(github.ref, 'refs/tags/v')
3131
- name: Upload artifacts
32-
uses: actions/upload-artifact@v3
32+
uses: actions/upload-artifact@v4
3333
if: startsWith(github.ref, 'refs/tags/v')
3434
with:
3535
name: artifacts
@@ -44,14 +44,14 @@ jobs:
4444
contents: write
4545
steps:
4646
- name: Download artifacts
47-
uses: actions/download-artifact@v3
47+
uses: actions/download-artifact@v4
4848
with:
4949
name: artifacts
5050
path: artifacts/
5151
- name: Hash artifacts
5252
run: sha256sum artifacts/*/*
5353
- name: Create GitHub release
54-
uses: softprops/action-gh-release@v1
54+
uses: softprops/action-gh-release@v2
5555
with:
5656
tag_name: ${{ github.ref_name }}
5757
name: ${{ github.ref_name }}

.github/workflows/label-actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
action:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: dessant/label-actions@v3
15+
- uses: dessant/label-actions@v4

.github/workflows/lockdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
action:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: dessant/repo-lockdown@v3
14+
- uses: dessant/repo-lockdown@v4
1515
with:
1616
pr-comment: 'This project does not accept pull requests. Please use issues to report bugs or suggest new features.'
1717
process-only: 'prs'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.assets/
2+
/app/
23
/artifacts/
34
/dist/
45

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.16.0
1+
20.12.2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ your autoplay settings between sessions.
4141

4242
## License
4343

44-
Copyright (c) 2018-2023 Armin Sebastian
44+
Copyright (c) 2018-2024 Armin Sebastian
4545

4646
This software is released under the terms of the GNU General Public License v3.0.
4747
See the [LICENSE](LICENSE) file for further information.

babel.config.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
const path = require('node:path');
22

3-
const corejsVersion = require(path.join(
4-
path.dirname(require.resolve('core-js')),
5-
'package.json'
6-
)).version;
3+
const corejsVersion = require(
4+
path.join(path.dirname(require.resolve('core-js')), 'package.json')
5+
).version;
76

87
module.exports = function (api) {
8+
api.cache(true);
9+
910
const presets = [
1011
[
1112
'@babel/env',
@@ -24,11 +25,7 @@ module.exports = function (api) {
2425
new RegExp(`node_modules\\${path.sep}(?!(vueton|wesa)\\${path.sep}).*`)
2526
];
2627

27-
const parserOpts = {plugins: ['importAssertions']};
28-
29-
if (api.env('production')) {
30-
plugins.push('lodash');
31-
}
28+
const parserOpts = {plugins: ['importAttributes']};
3229

3330
return {presets, plugins, ignore, parserOpts};
3431
};

gulpfile.js

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const targetEnv = process.env.TARGET_ENV || 'chrome';
2222
const isProduction = process.env.NODE_ENV === 'production';
2323
const enableContributions =
2424
(process.env.ENABLE_CONTRIBUTIONS || 'true') === 'true';
25+
26+
const mv3 = ['chrome'].includes(targetEnv);
27+
2528
const distDir = path.join(__dirname, 'dist', targetEnv);
2629

2730
function initEnv() {
@@ -45,12 +48,17 @@ function js(done) {
4548
}
4649

4750
function html() {
48-
return src(
49-
enableContributions
50-
? 'src/**/*.html'
51-
: ['src/**/*.html', '!src/contribute/*.html'],
52-
{base: '.'}
53-
)
51+
const htmlSrc = ['src/**/*.html'];
52+
53+
if (mv3) {
54+
htmlSrc.push('!src/background/*.html');
55+
}
56+
57+
if (!enableContributions) {
58+
htmlSrc.push('!src/contribute/*.html');
59+
}
60+
61+
return src(htmlSrc, {base: '.'})
5462
.pipe(gulpif(isProduction, htmlmin({collapseWhitespace: true})))
5563
.pipe(dest(distDir));
5664
}
@@ -70,7 +78,10 @@ async function images(done) {
7078
// Chrome Web Store does not correctly display optimized icons
7179
if (isProduction && targetEnv !== 'chrome') {
7280
await new Promise(resolve => {
73-
src(path.join(distDir, 'src/assets/icons/app/*.png'), {base: '.'})
81+
src(path.join(distDir, 'src/assets/icons/app/*.png'), {
82+
base: '.',
83+
encoding: false
84+
})
7485
.pipe(imagemin())
7586
.pipe(dest('.'))
7687
.on('error', done)
@@ -79,7 +90,10 @@ async function images(done) {
7990
}
8091

8192
await new Promise(resolve => {
82-
src('src/assets/icons/@(app|misc)/*.@(png|svg)', {base: '.'})
93+
src('src/assets/icons/@(app|misc)/*.@(png|svg)', {
94+
base: '.',
95+
encoding: false
96+
})
8397
.pipe(gulpif(isProduction, imagemin()))
8498
.pipe(dest(distDir))
8599
.on('error', done)
@@ -88,7 +102,10 @@ async function images(done) {
88102

89103
if (enableContributions) {
90104
await new Promise(resolve => {
91-
src('node_modules/vueton/components/contribute/assets/*.@(png|svg)')
105+
src(
106+
'node_modules/vueton/components/contribute/assets/*.@(png|webp|svg)',
107+
{encoding: false}
108+
)
92109
.pipe(gulpif(isProduction, imagemin()))
93110
.pipe(dest(path.join(distDir, 'src/contribute/assets')))
94111
.on('error', done)
@@ -108,7 +125,8 @@ async function fonts(done) {
108125

109126
await new Promise(resolve => {
110127
src(
111-
'node_modules/@fontsource/roboto/files/roboto-latin-@(400|500|700)-normal.woff2'
128+
'node_modules/@fontsource/roboto/files/roboto-latin-@(400|500|700)-normal.woff2',
129+
{encoding: false}
112130
)
113131
.pipe(dest(path.join(distDir, 'src/assets/fonts/files')))
114132
.on('error', done)
@@ -169,22 +187,28 @@ function manifest() {
169187
.pipe(dest(distDir));
170188
}
171189

172-
function license() {
190+
function license(done) {
173191
let year = '2018';
174192
const currentYear = new Date().getFullYear().toString();
175193
if (year !== currentYear) {
176194
year = `${year}-${currentYear}`;
177195
}
178196

179-
const notice = `Autoplay Settings for YouTube
197+
let notice = `Autoplay Settings for YouTube
180198
Copyright (c) ${year} Armin Sebastian
199+
`;
181200

201+
if (['safari', 'samsung'].includes(targetEnv)) {
202+
writeFileSync(path.join(distDir, 'NOTICE'), notice);
203+
done();
204+
} else {
205+
notice = `${notice}
182206
This software is released under the terms of the GNU General Public License v3.0.
183207
See the LICENSE file for further information.
184208
`;
185-
186-
writeFileSync(path.join(distDir, 'NOTICE'), notice);
187-
return src('LICENSE').pipe(dest(distDir));
209+
writeFileSync(path.join(distDir, 'NOTICE'), notice);
210+
return src('LICENSE').pipe(dest(distDir));
211+
}
188212
}
189213

190214
function zip(done) {

0 commit comments

Comments
 (0)