Skip to content

Commit

Permalink
replace match by exec
Browse files Browse the repository at this point in the history
  • Loading branch information
GooseOb committed May 10, 2024
1 parent 2c9e4e5 commit cab4f05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions build-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { BunBuildUserscriptConfig } from 'bun-build-userscript';

const define: Record<string, string> = {};

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;

Expand Down
7 changes: 3 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ const $ = <T extends HTMLElement>(id: string) =>
document.getElementById(id) as T;

const getChannelUsername = (aboveTheFold: HTMLElement) =>
aboveTheFold
.querySelector<HTMLAnchorElement>('.ytd-channel-name > a')
.href.match(/(?<=@|\/c\/).+?$/)[0];
/(?<=@|\/c\/).+?$/.exec(
aboveTheFold.querySelector<HTMLAnchorElement>('.ytd-channel-name > a').href
)[0];

const getPlr = () => $('movie_player');
const getAboveTheFold = () => $('above-the-fold');
Expand Down Expand Up @@ -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;
},
};

Expand Down

0 comments on commit cab4f05

Please sign in to comment.