Skip to content

Commit

Permalink
fix: cli invalid url error and incorrect authorization URL
Browse files Browse the repository at this point in the history
feat: update user agent
  • Loading branch information
PeterNjeim committed Jun 5, 2024
1 parent 5f72b4f commit aa4fc03
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getSuffix = async (scoreUrl: string): Promise<string> => {
let suffixUrl;
if (scoreUrl !== "") {
suffixUrl = (await (await fetch(scoreUrl)).text()).match(
'<link href="(https://musescore.com/static/public/build/musescore(?:_es6)?/20.+?.js)"'
'<link href="(https://musescore.com/static/public/build/musescore.*?(?:_es6)?/20.+?.js)"'
)?.[1]!;
} else {
const suffixElement =
Expand All @@ -20,6 +20,12 @@ const getSuffix = async (scoreUrl: string): Promise<string> => {
) as HTMLLinkElement) ??
(document.head.querySelector(
"link[href^='https://musescore.com/static/public/build/musescore/20']"
) as HTMLLinkElement) ??
(document.head.querySelector(
"link[href^='https://musescore.com/static/public/build/musescore_fonts_es6/20']"
) as HTMLLinkElement) ??
(document.head.querySelector(
"link[href^='https://musescore.com/static/public/build/musescore_fonts/20']"
) as HTMLLinkElement);
suffixUrl = suffixElement?.href;
}
Expand Down Expand Up @@ -61,18 +67,18 @@ const getApiAuthNetwork = async (
if (!fsBtn) {
throw Error;
}
const el =
fsBtn.parentElement?.parentElement?.querySelector(
"button"
) as HTMLButtonElement;
el.click();
const el =
fsBtn.parentElement?.parentElement?.querySelector(
"button"
) as HTMLButtonElement;
el.click();
break;
}
case "mp3": {
const el = document.querySelector(
'button[title="Toggle Play"]'
) as HTMLButtonElement;
el.click();
el.click();
break;
}
case "img": {
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const getIndexPath = (id: number): string => {

const NODE_FETCH_HEADERS = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0",
"Accept-Language": "en-US,en;q=0.8",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.2535.85",
"Accept-Language": "en-US;q=0.8",
};

export const getFetch = (): typeof fetch => {
Expand Down

0 comments on commit aa4fc03

Please sign in to comment.