diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1c0ab04 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'yarn' + + - name: Install modules + run: yarn + + - name: Build + run: yarn build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7ed8392..f29e93e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -37,7 +37,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/main.yml b/.github/workflows/release.yml similarity index 73% rename from .github/workflows/main.yml rename to .github/workflows/release.yml index 663191a..5cd58f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/release.yml @@ -1,27 +1,35 @@ name: Latest Release Build + on: release: types: - published + jobs: build: env: ADDON_ID: "{14a15c41-13f4-498e-986c-7f00435c4d00}" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - uses: c-hive/gha-yarn-cache@v1 - - uses: actions/setup-node@v3 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: '22' + cache: 'yarn' + - name: Install modules run: yarn + - name: Build Chrome run: | - VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//') yarn build:chrome + # Extract version number from the tag + VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//') + yarn build:chrome yarn package + - name: Upload Chrome package to release uses: svenstaro/upload-release-action@v2 with: @@ -30,10 +38,14 @@ jobs: asset_name: HyperChat-Chrome.zip tag: ${{ github.ref }} overwrite: true + - name: Build Firefox run: | - VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//') yarn build:firefox + # Extract version number from the tag + VERSION=$(echo -n "${{ github.ref }}" | sed 's/[refs\/tagv]//g' | sed 's/-.*//') + yarn build:firefox yarn package + - name: Upload Firefox package to release uses: svenstaro/upload-release-action@v2 with: diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..6a0493c --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +node = "22" diff --git a/src/components/ChatSummary.svelte b/src/components/ChatSummary.svelte index fded6f1..f3b417e 100644 --- a/src/components/ChatSummary.svelte +++ b/src/components/ChatSummary.svelte @@ -10,14 +10,24 @@ let dismissed = false; let shorten = false; + let autoHideTimeout: NodeJS.Timeout | null = null; const classes = 'rounded inline-flex flex-col overflow-visible ' + 'bg-secondary-900 p-2 w-full text-white z-10 shadow'; - const onShorten = () => { shorten = !shorten; }; + const onShorten = () => { + shorten = !shorten; + if (autoHideTimeout) { + clearTimeout(autoHideTimeout); + autoHideTimeout = null; + } + }; $: if (summary) { dismissed = false; shorten = false; + if (summary.showtime) { + autoHideTimeout = setTimeout(() => { shorten = true; }, summary.showtime); + } } const dispatch = createEventDispatcher(); diff --git a/src/scripts/chat-injector.ts b/src/scripts/chat-injector.ts index 45c230f..c023d09 100644 --- a/src/scripts/chat-injector.ts +++ b/src/scripts/chat-injector.ts @@ -1,6 +1,6 @@ import HcButton from '../components/HyperchatButton.svelte'; import { getFrameInfoAsync, isValidFrameInfo, frameIsReplay, checkInjected } from '../ts/chat-utils'; -import { isLiveTL, isAndroid } from '../ts/chat-constants'; +import { isLiveTL } from '../ts/chat-constants'; import { hcEnabled, autoLiveChat } from '../ts/storage'; import { initInterceptor, @@ -150,13 +150,6 @@ const chatLoaded = async (): Promise => { } ytcTicker.remove(); - // Hide input panel on android - if (isAndroid) { - const inputPanel = document.querySelector('#input-panel'); - if (!inputPanel) return; - (inputPanel as HTMLElement).style.display = 'none'; - } - if (await autoLiveChat.get()) { const live = document.querySelector('tp-yt-paper-listbox#menu > :nth-child(2)'); if (!live) { diff --git a/src/ts/chat-constants.ts b/src/ts/chat-constants.ts index ea5ab2a..15085bc 100644 --- a/src/ts/chat-constants.ts +++ b/src/ts/chat-constants.ts @@ -1,27 +1,16 @@ export const isLiveTL = false; -export const isAndroid = false; // DO NOT EDIT THE ABOVE LINE. It is updated by webpack. export const enum Browser { FIREFOX, CHROME, - SAFARI, - ANDROID + SAFARI } export const getBrowser = (): Browser => { if (navigator.userAgent.includes('Firefox')) { return Browser.FIREFOX; } - let w: any; - try { - w = window; - } catch { - w = self; - } - if (isAndroid || w.chrome == null) { - return Browser.ANDROID; - } if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { return Browser.SAFARI; } diff --git a/src/ts/chat-parser.ts b/src/ts/chat-parser.ts index 555e09e..ea3b95f 100644 --- a/src/ts/chat-parser.ts +++ b/src/ts/chat-parser.ts @@ -102,7 +102,7 @@ const parseChatSummary = (renderer: Ytc.AddChatItem, isEphemeral: boolean, banne message: splitRuns[2], }, id: baseRenderer.liveChatSummaryId, - showtime: isEphemeral ? (bannerTimeoutMs / 1000) : 0, + showtime: isEphemeral ? bannerTimeoutMs : 0, }; return item; }