From cab4f0502d0db0a8f892451ec6b1ee02a460961b Mon Sep 17 00:00:00 2001 From: GooseOb Date: Fri, 10 May 2024 17:10:54 +0200 Subject: [PATCH] replace match by exec --- build-config.ts | 4 +--- index.ts | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/build-config.ts b/build-config.ts index d731461..faffd63 100644 --- a/build-config.ts +++ b/build-config.ts @@ -3,9 +3,7 @@ import { BunBuildUserscriptConfig } from 'bun-build-userscript'; const define: Record = {}; -const raw = (await readFile('index.ts', 'utf8')).match( - /declare const[^;]+?;/ -)[0]; +const raw = /declare const[^;]+?;/.exec(await readFile('index.ts', 'utf8'))[0]; const pattern = /(\S+):\s*([^,;]+)/g; diff --git a/index.ts b/index.ts index 3cf489e..6e76d26 100644 --- a/index.ts +++ b/index.ts @@ -225,9 +225,9 @@ const $ = (id: string) => document.getElementById(id) as T; const getChannelUsername = (aboveTheFold: HTMLElement) => - aboveTheFold - .querySelector('.ytd-channel-name > a') - .href.match(/(?<=@|\/c\/).+?$/)[0]; + /(?<=@|\/c\/).+?$/.exec( + aboveTheFold.querySelector('.ytd-channel-name > a').href + )[0]; const getPlr = () => $('movie_player'); const getAboveTheFold = () => $('above-the-fold'); @@ -286,7 +286,6 @@ const ytMenu: YtMenu = { }, findInItem(item, callback) { return findInNodeList(this.openItem(item), callback); - // for (const btn of this.openItem(item)) if (callback(btn)) return btn; }, };