Skip to content

Commit afeba0e

Browse files
committed
Fix compatibility
1 parent a183af1 commit afeba0e

File tree

9 files changed

+40
-20
lines changed

9 files changed

+40
-20
lines changed

Diff for: .github/workflows/build-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup Node.js
1515
uses: actions/setup-node@v1
1616
with:
17-
node-version: 14.x
17+
node-version: 18.x
1818

1919
- run: yarn
2020
- run: yarn --cwd functions

Diff for: .github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Node.js
1313
uses: actions/setup-node@v1
1414
with:
15-
node-version: 14.x
15+
node-version: 18.x
1616

1717
- run: yarn
1818
- run: yarn --cwd functions

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"lint": "tsc --noEmit && eslint --ext .ts --fix src/",
77
"test": "vitest",
88
"build": "vite build",
9-
"watch": "yarn build --watch",
9+
"watch": "cross-env NODE_ENV=development yarn build --watch",
1010
"serve": "web-ext --config web-ext.config.js run --start-url open.spotify.com",
1111
"serve:chromium": "yarn run serve -- -t chromium",
1212
"start": "concurrently npm:watch npm:serve:chromium",

Diff for: public/_locales/en/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
},
227227

228228
"pageEditorAddLyrics2": {
229-
"message": "upload",
229+
"message": "choose",
230230
"description": "Paste or upload lyrics"
231231
},
232232

Diff for: public/_locales/zh/messages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
},
177177

178178
"pageEditorAddLyrics2": {
179-
"message": "上传"
179+
"message": "选择"
180180
},
181181

182182
"pageEditorAddLyrics3": {

Diff for: src/background.ts

+16-12
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,20 @@ browser.runtime.onInstalled.addListener(({ reason }) => {
158158
}
159159
});
160160

161-
if (!isFirefox) {
162-
browser.scripting.registerContentScripts([
163-
{
164-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
165-
// @ts-ignore
166-
world: 'MAIN',
167-
id: 'page',
168-
runAt: 'document_start',
169-
matches: browser.runtime.getManifest().content_scripts![0].matches,
170-
js: [isRateTest ? 'page/rate.js' : 'page/index.js'],
171-
},
172-
]);
161+
if (isProd && !isFirefox) {
162+
browser.scripting
163+
.registerContentScripts([
164+
{
165+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
166+
// @ts-ignore
167+
world: 'MAIN',
168+
id: 'page',
169+
runAt: 'document_start',
170+
matches: browser.runtime.getManifest().content_scripts![0].matches,
171+
js: [isRateTest ? 'page/rate.js' : 'page/index.js'],
172+
},
173+
])
174+
.catch(() => {
175+
//
176+
});
173177
}

Diff for: src/content.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { runtime } from 'webextension-polyfill';
22

3-
import { Message, Event, isFirefox, isRateTest } from './common/constants';
3+
import { Message, Event, isFirefox, isRateTest, isProd } from './common/constants';
44

55
runtime.onMessage.addListener((msg: Message) => {
66
window.postMessage(msg, '*');
@@ -30,7 +30,7 @@ window.addEventListener('message', ({ data }) => {
3030
}
3131
});
3232

33-
if (isFirefox) {
33+
if (!isProd || isFirefox) {
3434
// Firefox CSP Issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1267027
3535
const script = document.createElement('script');
3636
script.src = runtime.getURL(isRateTest ? 'page/rate.js' : 'page/index.js');

Diff for: src/options/index.ts

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// https://bugs.chromium.org/p/chromium/issues/detail?id=390807
22
import '@webcomponents/webcomponentsjs';
33
import { render, html } from '@mantou/gem/lib/element';
4+
import { kebabToCamelCase } from '@mantou/gem/lib/utils';
45

56
import { isWebApp } from '../common/constants';
67
import { fontStyle } from '../common/font';
@@ -43,4 +44,18 @@ if (!isWebApp) {
4344
window.addEventListener('error', (e) => {
4445
captureException(e);
4546
});
47+
} else {
48+
// https://bugs.chromium.org/p/chromium/issues/detail?id=390807
49+
// hack content script custom element
50+
Object.defineProperty(HTMLElement.prototype, 'attachInternals', {
51+
value: function attachInternals() {
52+
return {
53+
states: {
54+
has: (v: string) => kebabToCamelCase(v) in this.dataset,
55+
add: (v: string) => (this.dataset[kebabToCamelCase(v)] = ''),
56+
delete: (v: string) => delete this.dataset[kebabToCamelCase(v)],
57+
},
58+
};
59+
},
60+
});
4661
}

Diff for: src/page/editor/app.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ export class EditorApp extends GemElement<State> {
319319
.button:hover {
320320
opacity: 1;
321321
}
322-
.text-button:hover {
322+
.text-button:hover,
323+
.title a:hover {
323324
border-bottom: 1px solid;
324325
}
325326
table {

0 commit comments

Comments
 (0)