1
0
mirror of https://github.com/LibreScore/dl-librescore synced 2024-09-14 23:50:34 +02:00

fix: cli invalid url error and incorrect authorization URL

feat: update user agent
This commit is contained in:
Peter Njeim 2024-06-05 14:33:13 -03:00
parent 5f72b4f8e6
commit aa4fc038e0
3 changed files with 17 additions and 11 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "dl-librescore",
"version": "0.35.0",
"version": "0.35.16",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dl-librescore",
"version": "0.35.0",
"version": "0.35.16",
"license": "MIT",
"dependencies": {
"@librescore/fonts": "^0.4.1",

View File

@ -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 =
@ -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;
}
@ -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": {

View File

@ -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 => {