ROpdebee / mb-userscripts

Collection of userscripts for MusicBrainz
MIT License
119 stars 9 forks source link

Support other languages on ISWCNet #18

Closed clorirdrix closed 3 years ago

clorirdrix commented 3 years ago

Hi, I'm trying to use your script, (chrome latest version with Tampermonkey) and when I click "copy work code" on ISWC, it doesnt get any info at all and when I tried to paste with the button it always report "Log - No data found. Did you copy anything?" Is there something I don't do right, sorry I might not be an Issue, probably an error on my part.

Also, I've tried with Firefox (greasemonky) and Vivaldi (violentmonkey)... always the same issue

ROpdebee commented 3 years ago

Hi! Is there anything logged in the tab's console? Which language are you using on ISWCNet?

clorirdrix commented 3 years ago

Ok, I figured it was the french language that was problematic. Thanks for the input, works like a charm now!

ROpdebee commented 3 years ago

Cool! I'm going to keep this open as a reminder to either fix the script on non-English pages, or clarify that it only works on English pages.

jesus2099 commented 3 years ago

I confirm this. I don't know why I cannot switch to English at the moment, so the Copy work codes button is above Title variations instead of above Work codes and clicking it says (console):

Uncaught TypeError: Cannot read property 'innerText' of null

https://iswcnet.cisac.org/search?iswc=T7035811088 https://iswcnet.cisac.org/search?iswc=T7035820512

I tried to fix but it's ECMAScript 6.

findDivByText

This function could take an array of texts with all possible values.

English Spanish French
Agency Work Codes: Códigos de Obra de Agencias: Codes Oeuvre de l’Agence:
Archived ISWCs ? ?

Please give me a work that has some Archived ISWCs so I can tell how it is in French. :)

ROpdebee commented 3 years ago

Sorry, I completely overlooked your reply 😳

I've done some digging, it turns out it's possible to just get the correct translations automatically by requesting https://iswcnet.cisac.org/configuration/GetLocalizedStrings?culture=fr (and es for Spanish, I guess). That seems like a more reliable option to go with here, but thanks for the offer to translate :)

Ultimately I'd prefer to use IDs and class names, but they seem generated (like ViewMore_grid__tmv_Y) and I'm not sure whether it's safe to rely on them not changing often.

ROpdebee commented 3 years ago

Actually, it seems translations are stored in localStorage.strings, so it could possibly just use that.