Skip to content

Commit 3e005a1

Browse files
committed
Produce MV2 build for Firefox instead
1 parent 32a2134 commit 3e005a1

File tree

12 files changed

+828
-45
lines changed

12 files changed

+828
-45
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = {
4242
'@typescript-eslint/no-confusing-void-expression': 'off',
4343
'@typescript-eslint/no-floating-promises': 'off',
4444
'@typescript-eslint/no-non-null-assertion': 'off',
45+
'@typescript-eslint/no-unsafe-argument': 'off',
4546
'@typescript-eslint/no-unused-expressions': 'off',
4647

4748
'linebreak-style': [

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111

1212
## Building from Source
1313

14-
### ⚠️ WARNING ⚠️
15-
16-
For legacy reasons, we have a `mv2` branch for Firefox support while the `main` branch houses the main MV3 version.
17-
18-
TODO: we need to confirm whether the MV2 variant is still required for modern versions of Firefox.
19-
2014
### Development
2115

2216
> Note: The repo expects a Linux or Unix-like environment. If you are on Windows, use WSL.

src/components/Hyperchat.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
return port;
346346
});
347347
348-
return () => $port?.destroy && $port?.destroy();
348+
return () => $port?.destroy?.();
349349
};
350350
351351
onMount(onLoad);

src/manifest.json

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"manifest_version": 3,
2+
"{{chrome}}.manifest_version": 3,
3+
"{{firefox}}.manifest_version": 2,
34
"name": "HyperChat [Improved YouTube Chat]",
45
"version": "0.0.0",
56
"homepage_url": "https://livetl.app/hyperchat",
@@ -11,7 +12,7 @@
1112
"permissions": [
1213
"storage"
1314
],
14-
"host_permissions": [
15+
"{{chrome}}.host_permissions": [
1516
"https://www.youtube.com/live_chat*",
1617
"https://www.youtube.com/live_chat_replay*",
1718
"https://studio.youtube.com/live_chat*",
@@ -25,9 +26,12 @@
2526
"https://studio.youtube.com/live_chat*",
2627
"https://studio.youtube.com/live_chat_replay*"
2728
],
28-
"js": [
29+
"{{chrome}}.js": [
2930
"scripts/chat-injector.ts"
3031
],
32+
"{{firefox}}.js": [
33+
"scripts/mv2/chat-injector.ts"
34+
],
3135
"css": [
3236
"stylesheets/titlebar.css"
3337
],
@@ -47,25 +51,36 @@
4751
"all_frames": true
4852
}
4953
],
50-
"{{firefox}}.background": {
51-
"scripts": ["scripts/chat-background.ts"]
52-
},
5354
"{{chrome}}.background": {
5455
"service_worker": "scripts/chat-background.ts"
5556
},
56-
"action": {
57+
"{{firefox}}.background": {
58+
"scripts": ["scripts/mv2/chat-background.ts"],
59+
"persistent": true
60+
},
61+
"{{chrome}}.action": {
5762
"default_icon": {
5863
"48": "assets/logo-48.png",
5964
"128": "assets/logo-128.png"
6065
},
6166
"default_popup": "options.html"
6267
},
63-
"web_accessible_resources": [
68+
"{{firefox}}.browser_action": {
69+
"default_icon": {
70+
"48": "assets/logo-48.png",
71+
"128": "assets/logo-128.png"
72+
},
73+
"default_popup": "options.html"
74+
},
75+
"{{chrome}}.web_accessible_resources": [
6476
{
6577
"resources": ["*"],
6678
"matches": ["<all_urls>"]
6779
}
6880
],
81+
"{{firefox}}.web_accessible_resources": [
82+
"*"
83+
],
6984
"options_ui": {
7085
"page": "options.html",
7186
"open_in_tab": true

src/scripts/chat-background.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const noUpdateKeys = new Set(['hc.bytes.used', 'hc.bytes.update']);
44
const oneDay = 1000 * 60 * 60 * 24;
55

66
const storageget = (key: string): any => chrome.storage.local.get(key).then(r => r[key]);
7-
const defaultTo0 = (value: any): number => isNaN(value) ? 0 : value;
7+
const defaultTo0 = (value: any): number => Number.isNaN(value) ? 0 : value;
88

99
chrome.action.onClicked.addListener(() => {
1010
if (isLiveTL) {
@@ -52,7 +52,7 @@ chrome.storage.local.onChanged.addListener(changes => {
5252
// avoid top-level async
5353
// see https://stackoverflow.com/a/53024910
5454
(async () => {
55-
const toWrite = {};
55+
const toWrite: Record<string, any> = {};
5656
const data = await Promise.all([
5757
storageget('hc.bytes.used'),
5858
storageget('hc.bytes.lastupdate')

src/scripts/chat-injector.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import {
1111
setTheme
1212
} from '../ts/messaging';
1313

14-
// const isFirefox = navigator.userAgent.includes('Firefox');
15-
1614
const hcWarning = 'An existing HyperChat button has been detected. This ' +
1715
'usually means both LiveTL and standalone HyperChat are enabled. ' +
1816
'LiveTL already includes HyperChat, so please enable only one of them.\n\n' +
@@ -121,19 +119,6 @@ const chatLoaded = async (): Promise<void> => {
121119
ytcItemList.outerHTML = `
122120
<iframe id="hyperchat" src="${source}" style="border: 0px; width: 100%; height: 100%;"/>
123121
`;
124-
// const hyperchat = document.querySelector('#hyperchat') as HTMLIFrameElement;
125-
// if (!hyperchat) {
126-
// console.error('Failed to find #hyperchat');
127-
// return;
128-
// }
129-
// if (isFirefox || isLiveTL) {
130-
// const scale = 0.8;
131-
// const inverse = `${Math.round((1 / scale) * 10000) / 100}%`;
132-
// hyperchat.style.transformOrigin = '0px 0px';
133-
// hyperchat.style.minWidth = inverse;
134-
// hyperchat.style.minHeight = inverse;
135-
// hyperchat.style.transform = `scale(${scale})`;
136-
// }
137122

138123
// Remove ticker element
139124
const ytcTicker = document.querySelector('#ticker');

0 commit comments

Comments
 (0)