Skip to content

Commit 8a53145

Browse files
committed
Merge remote-tracking branch 'hc/mv3'
2 parents af6a505 + d338628 commit 8a53145

File tree

12 files changed

+99
-46
lines changed

12 files changed

+99
-46
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
13+
- name: Set up Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: '22'
17+
cache: 'yarn'
18+
19+
- name: Install modules
20+
run: yarn
21+
22+
- name: Build
23+
run: yarn build

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
steps:
3939
- name: Checkout repository
40-
uses: actions/checkout@v2
40+
uses: actions/checkout@v4
4141

4242
# Initializes the CodeQL tools for scanning.
4343
- name: Initialize CodeQL
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
name: Latest Release Build
2+
23
on:
34
release:
45
types:
56
- published
7+
68
jobs:
79
build:
810
env:
911
ADDON_ID: "{20f2dcdf-6f8d-4aeb-862b-b13174475d9c}"
1012
runs-on: ubuntu-latest
1113
steps:
12-
- uses: actions/checkout@v2
13-
with:
14-
submodules: 'recursive'
15-
- uses: c-hive/gha-yarn-cache@v1
16-
- uses: actions/setup-node@v3
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
1719
with:
18-
node-version: 16
20+
node-version: '22'
21+
cache: 'yarn'
22+
1923
- name: Install modules
2024
run: |
2125
sudo apt install jq
2226
yarn
2327
VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//')
2428
jq --arg version $VERSION '.version = $version' src/manifest.json > src/manifest.json.tmp
2529
mv src/manifest.json.tmp src/manifest.json
30+
2631
- name: Build Chrome
2732
run: |
28-
VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//') yarn build:chrome
33+
# Extract version number from the tag
34+
VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//')
35+
yarn build:chrome
2936
yarn package
37+
3038
- name: Upload Chrome package to release
3139
uses: svenstaro/upload-release-action@v2
3240
with:
@@ -35,10 +43,14 @@ jobs:
3543
asset_name: YtcFilter-Chrome.zip
3644
tag: ${{ github.ref }}
3745
overwrite: true
46+
3847
- name: Build Firefox
3948
run: |
40-
VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//') yarn build:firefox
49+
# Extract version number from the tag
50+
VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//')
51+
yarn build:firefox
4152
yarn package
53+
4254
- name: Upload Firefox package to release
4355
uses: svenstaro/upload-release-action@v2
4456
with:

mise.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
node = "22"

src/components/ChatSummary.svelte

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@
1010
1111
let dismissed = false;
1212
let shorten = false;
13+
let autoHideTimeout: NodeJS.Timeout | null = null;
1314
const classes = 'rounded inline-flex flex-col overflow-visible ' +
1415
'bg-secondary-900 p-2 w-full text-white z-10 shadow';
1516
16-
const onShorten = () => { shorten = !shorten; };
17+
const onShorten = () => {
18+
shorten = !shorten;
19+
if (autoHideTimeout) {
20+
clearTimeout(autoHideTimeout);
21+
autoHideTimeout = null;
22+
}
23+
};
1724
1825
$: if (summary) {
1926
dismissed = false;
2027
shorten = false;
28+
if (summary.showtime) {
29+
autoHideTimeout = setTimeout(() => { shorten = true; }, summary.showtime);
30+
}
2131
}
2232
2333
const dispatch = createEventDispatcher();

src/components/HyperchatButton.svelte

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@
6464
</div>
6565

6666
<style>
67-
:global(div#contents.style-scope.yt-live-chat-renderer) {
68-
z-index: 2;
69-
}
70-
7167
#hc-buttons {
7268
float: right;
7369
display: flex;

src/components/PinnedMessage.svelte

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@
1010
1111
let dismissed = false;
1212
let shorten = false;
13+
let autoHideTimeout: NodeJS.Timeout | null = null;
1314
const classes = 'rounded inline-flex flex-col overflow-visible ' +
1415
'bg-secondary-900 p-2 w-full text-white z-10 shadow';
1516
16-
const onShorten = () => { shorten = !shorten; };
17-
17+
const onShorten = () => {
18+
shorten = !shorten;
19+
if (autoHideTimeout) {
20+
clearTimeout(autoHideTimeout);
21+
autoHideTimeout = null;
22+
}
23+
};
24+
1825
$: if (pinned) {
1926
dismissed = false;
2027
shorten = false;
28+
if (pinned.showtime) {
29+
autoHideTimeout = setTimeout(() => { shorten = true; }, pinned.showtime);
30+
}
2131
}
2232
2333
const dispatch = createEventDispatcher();

src/scripts/chat-injector.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { getFrameInfoAsync, isValidFrameInfo, frameIsReplay, createPopup } from '../ts/chat-utils';
1+
import HcButton from '../components/HyperchatButton.svelte';
2+
import { getFrameInfoAsync, isValidFrameInfo, frameIsReplay, checkInjected, createPopup } from '../ts/chat-utils';
23
import { detectForceReload } from '../ts/ytcf-logic';
3-
import { isLiveTL, isAndroid } from '../ts/chat-constants';
4+
import { isLiveTL } from '../ts/chat-constants';
45
import {
5-
// hcEnabled,
6+
hcEnabled,
67
autoLiveChat,
78
filterInBackground,
89
initialSetupDone,
910
autoOpenFilterPanel
1011
} from '../ts/storage';
12+
1113
import {
1214
initInterceptor,
1315
processMessageChunk,
@@ -229,13 +231,6 @@ const chatLoaded = async (): Promise<void> => {
229231
// @ts-ignore
230232
ytcTicker.remove();
231233

232-
// Hide input panel on android
233-
if (isAndroid) {
234-
const inputPanel = document.querySelector('#input-panel');
235-
if (!inputPanel) return;
236-
(inputPanel as HTMLElement).style.display = 'none';
237-
}
238-
239234
if (await autoLiveChat.get()) {
240235
const live = document.querySelector<HTMLElement>('tp-yt-paper-listbox#menu > :nth-child(2)');
241236
if (!live) {

src/ts/chat-constants.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
export const isLiveTL = false;
2-
export const isAndroid = false;
32
// DO NOT EDIT THE ABOVE LINE. It is updated by webpack.
43

54
export const enum Browser {
65
FIREFOX,
76
CHROME,
8-
SAFARI,
9-
ANDROID
7+
SAFARI
108
}
119

1210
export const getBrowser = (): Browser => {
1311
if (navigator.userAgent.includes('Firefox')) {
1412
return Browser.FIREFOX;
1513
}
16-
let w: any;
17-
try {
18-
w = window;
19-
} catch {
20-
w = self;
21-
}
22-
if (isAndroid || w.chrome == null) {
23-
return Browser.ANDROID;
24-
}
2514
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
2615
return Browser.SAFARI;
2716
}

src/ts/chat-parser.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const splitRunsByNewline = (runs: Ytc.ParsedRun[], maxSplit: number = -1): Ytc.P
8585
return acc;
8686
}, [[]]);
8787

88-
const parseChatSummary = (renderer: Ytc.AddChatItem, isEphemeral: boolean, bannerTimeoutMs: number): Ytc.ParsedSummary | undefined => {
88+
const parseChatSummary = (renderer: Ytc.AddChatItem, showtime: number): Ytc.ParsedSummary | undefined => {
8989
if (!renderer.liveChatBannerChatSummaryRenderer) {
9090
return;
9191
}
@@ -112,7 +112,7 @@ const parseChatSummary = (renderer: Ytc.AddChatItem, isEphemeral: boolean, banne
112112
message: splitRuns[2],
113113
},
114114
id: baseRenderer.liveChatSummaryId,
115-
showtime: isEphemeral ? (bannerTimeoutMs / 1000) : 0,
115+
showtime: showtime,
116116
};
117117
return item;
118118
}
@@ -241,8 +241,14 @@ const parseMessageDeletedAction = (action: Ytc.MessageDeletedAction): Ytc.Parsed
241241

242242
const parseBannerAction = (action: Ytc.AddPinnedAction): Ytc.ParsedPinned | Ytc.ParsedSummary | undefined => {
243243
const baseRenderer = action.bannerRenderer.liveChatBannerRenderer;
244+
245+
// fold both auto-disappear and auto-collapse into just collapse for showtime
246+
const showtime = action.bannerProperties?.isEphemeral
247+
? (action.bannerProperties?.bannerTimeoutMs || 0)
248+
: 1000 * (action.bannerProperties?.autoCollapseDelay?.seconds || baseRenderer.bannerProperties?.autoCollapseDelay?.seconds || 0);
249+
244250
if (baseRenderer.contents.liveChatBannerChatSummaryRenderer) {
245-
return parseChatSummary(baseRenderer.contents, action.bannerProperties?.isEphemeral ?? false, action.bannerProperties?.bannerTimeoutMs ?? 0);
251+
return parseChatSummary(baseRenderer.contents, showtime);
246252
}
247253
const parsedContents = parseAddChatItemAction(
248254
{ item: baseRenderer.contents }, true
@@ -257,7 +263,8 @@ const parseBannerAction = (action: Ytc.AddPinnedAction): Ytc.ParsedPinned | Ytc.
257263
baseRenderer.header.liveChatBannerHeaderRenderer.text.runs
258264
),
259265
contents: parsedContents
260-
}
266+
},
267+
showtime: showtime,
261268
};
262269
};
263270

0 commit comments

Comments
 (0)