Can the "set recording comments" script be modified to apply disambiguation comments to Works?

Specifically, the Parts of a soundtrack in a Work page. For example, I want to apply “Armored Core: for Answer” too all Works here.

This is the script, but this applies only to Recordings rather than the original Works (I’m guessing it’s if you wanted to add “live 1989” or whatever to the disambiguation comment). Maybe set it to copy the title of the Work page into the Disambiguation Comment field.

1 Like

I think it would be difficult to modify this userscript as it uses an undocumented, internal API of MBS to submit its edits. It was written by @Bitmap who is also one of the developers of MBS itself, so he probably knows whether that’s possible and what has to be done. I think I had already tried to submit a different kind of edit through this internal API and failed many months ago.

But luckily you have the same need as I had two years ago. Back then I modified @loujin’s Replace subwork titles and attributes in Work edit page userscript to add a new function which replaces the disambiguation comments of all subworks (of the currently edited work) with a custom text.

I have never submitted this feature because it’s just a quick and dirty copy-paste-adapt modification which I rarely needed since then, but it should still work. You can install my modified version from here:

Just let me know if the additional feature is useful and I might submit a PR and do some refactoring to clean up redundant code.

5 Likes

THANK YOU. That is exactly what I was looking for. It’s very useful and it seems to work as intended, I recommend a PR. I overlooked that original script, too, so I’ll double-check the rest and see if I need anything else.

1 Like

just a heads-up, an unexpected edit just came from your script… it deleted an ASCAP ID, don’t know why

Edit #89091254 - MusicBrainz.

edit: it seems to happen with all work attributes, Edit #89091422 - MusicBrainz

2 Likes

Yes, a proper work edit must submit all existing values, not only the ones you are changing.

When you debug a userscript that makes some actual edits, you can test it at https://test.musicbrainz.org
Erg well at the moment, the test server seems rather broken, at least on mobile.

3 Likes

@UltimateRiff It’s a general bug, not just one of my modified version. I guess I did not notice it so far because when I used this script the last time, work IDs weren’t really a thing and I had usually set the disambiguation comments on freshly generated works only (which don’t have any data that might be lost).

In any case, this is something which should be fixed in @loujin’s helper script, which only preserves key attributes so far:

Oh, and it has already been reported on GitHub, I just wanted to create an issue myself:

3 Likes

This might need to be updated, it hangs at “Fetching Required Data” now.

I have rebased my customized version on the latest master branch now. Can you check if it is working again or whether there is a general issue that also affects the original version? (I have no example at hand for testing currently, it’s been months since I have used that script.)

Same issue. Here’s what the console says. I’m trying it on this Tekken 7 page.
I noticed that the code says Tampermonkey, so does this not work on Violetmonkey? Maybe that’s why I still had Tampermonkey installed. Lemme try that. Edit: Doesn’t work there either.

Uncaught TypeError: (new RegExp(...)).exec(...) is null
    getEditParams MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:570
    GET MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:534
    onreadystatechange MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:514
    ce instrument.js:223
    r helpers.js:71
    s object.js:37
    oe trycatch.js:127
    ce instrument.js:232
    _request MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:528
    GET MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:532
    getEditParams MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:564
    getWorkEditParams MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:577
    replaceSubworksDisambiguations MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:988
    r helpers.js:71
    setTimeout handler*TVzBjg//e.prototype._wrapTimeFunction/oe trycatch.js:28
    replaceSubworksDisambiguations MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:985
    each Musicbrainz UI enhancements.user.js:374
    each Musicbrainz UI enhancements.user.js:139
    replaceSubworksDisambiguations MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:968
    VMt14jw2bgas MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:1079
    r helpers.js:71
    _wrapEventTarget trycatch.js:74
    ce instrument.js:328
    VMt14jw2bgas MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:1078
    fire Musicbrainz UI enhancements.user.js:3099
    fireWith Musicbrainz UI enhancements.user.js:3211
    ready Musicbrainz UI enhancements.user.js:3417
    completed Musicbrainz UI enhancements.user.js:3433
    r helpers.js:71
    _wrapEventTarget trycatch.js:74
    ce instrument.js:328
    promise Musicbrainz UI enhancements.user.js:3454
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:3461
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:34
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:38
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:9915
    Ut injected-web.js:1
    <anonymous> Musicbrainz UI enhancements.user.js:1
    Ee injected-web.js:1
    post injected-web.js:1
    ScriptData injected-web.js:1
    onHandle injected-web.js:1
    Ie injected-web.js:1
edit:570:57
    getEditParams MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:570
    GET MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:534
    onreadystatechange MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:514
    ce instrument.js:223
    r helpers.js:71
    (Async: EventHandlerNonNull)
    s object.js:37
    oe trycatch.js:127
    ce instrument.js:232
    _request MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:528
    GET MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:532
    getEditParams MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:564
    getWorkEditParams MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:577
    replaceSubworksDisambiguations MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:988
    r helpers.js:71
    (Async: setTimeout handler)
    oe trycatch.js:28
    replaceSubworksDisambiguations MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:985
    each Musicbrainz UI enhancements.user.js:374
    each Musicbrainz UI enhancements.user.js:139
    replaceSubworksDisambiguations MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:968
    VMt14jw2bgas MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:1079
    r helpers.js:71
    (Async: EventListener.handleEvent)
    _wrapEventTarget trycatch.js:74
    ce instrument.js:328
    VMt14jw2bgas MusicBrainz edit: Replace subwork titles, disambiguations and attributes in Work edit page.user.js:1078
    fire Musicbrainz UI enhancements.user.js:3099
    fireWith Musicbrainz UI enhancements.user.js:3211
    ready Musicbrainz UI enhancements.user.js:3417
    completed Musicbrainz UI enhancements.user.js:3433
    r helpers.js:71
    (Async: EventListener.handleEvent)
    _wrapEventTarget trycatch.js:74
    ce instrument.js:328
    promise Musicbrainz UI enhancements.user.js:3454
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:3461
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:34
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:38
    VM37w8mjj5yv Musicbrainz UI enhancements.user.js:9915
    call self-hosted:1359
    Ut injected-web.js:1
    <anonymous> Musicbrainz UI enhancements.user.js:1
    call self-hosted:1359
    Et injected.js:1
    Dt injected.js:1
    InterpretGeneratorResume self-hosted:1822
    AsyncFunctionNext self-hosted:810
    (Async: async)
    call self-hosted:1359
    onHandle injected.js:1
    je injected.js:1
    call self-hosted:1359
    Ee injected-web.js:1
    post injected-web.js:1
    ScriptData injected-web.js:1
    call self-hosted:1359
    onHandle injected-web.js:1
    Ie injected-web.js:1
    call self-hosted:1359
    De injected.js:1
    post injected.js:1
    St injected.js:1
    $t injected.js:1
    AsyncFunctionNext self-hosted:810
    (Async: async)
    <anonymous> injected.js:1
    AsyncFunctionNext self-hosted:810
    (Async: async)
    <anonymous> injected.js:1
    <anonymous> injected.js:1
    inject ExtensionContent.jsm:589
    AsyncFunctionNext self-hosted:810

1 Like

Ah, I think I got it now. The original script received an update which changed the behavior of an internal function for which I had to adapt this additional feature.
Sorry for the trouble, but you have to manually update the script once more, the latest version 2023.3.10 worked successfully with your given example (after I expanded the relationships, otherwise it only edited the visible subworks).

1 Like

Thanks for updating it! I can’t test it myself because I don’t have any more examples, but if you got Tekken 7 working than it’s probably fine.

1 Like

I guess I could have left the unexpanded works for you to test, but I wanted to know whether these could not be edited at all or only when they are expanded :wink:

Anyway, as the feature is clearly useful not only for me, I’ve finally opened a PR to get it included in the official version… after 2 years:

1 Like

Merged, it should be ready for testing

1 Like

@loujin I use lots of your scripts. Very handy. Thank You. But something seems to have happened that means the buttons don’t work for me now.

Vivaldi browser, Windows 10, Violent Monkey.

None of those buttons press in. Before the latest changes I did have half of these working. Now I have lost all the buttons.

Before the latest changes, the buttons didn’t work on “Relation attributes”, but was fine on “Guess Works” and “Dates”

Now since the latest updates all the buttons just don’t press.

What feedback can I try for you? I’ve experimented with killing as many other addons as possible and can’t see any thread as to what may be happening.

The “set relations” script works for me with Vivaldi 5.7 / violentmonkey 2.14 in Linux, I don’t have a way to check Windows.

No useful messages in the console logs (F12)?

What happens if you right-click a button then Developer Tools > Inspect and type “$0.click()” in the console?

1 Like

Is this the log you mean?

helpers.js:88 Uncaught TypeError: Cannot read properties of undefined (reading 'checkedRecordings')
    at guessWork (MusicBrainz relation editor: Guess related works in batch.user.js:974:30)
    at HTMLInputElement.<anonymous> (MusicBrainz relation editor: Guess related works in batch.user.js:1101:9)
    at HTMLInputElement.r (helpers.js:71:23)

That does trigger when I click the button(s) (or type “$0.click()”). The button used to “move” in a 3D way. These now do not move, but those errors appear reliably.

I have recordings\works ticked.

I’ll do a few more experiments… see if I can spot anything.

In Incognito mode, only ViolentMonkey enabled, same thing happens. Did this test to make sure no other extensions involved.

I have next to zero experience in debugging scripts like this so would need some guidance as to where I need look to be helpful.

Edit @ 19:49: Just hit a “update everything” in Violent Monkey… “Guess Work” button is working…
Woo!! … Back soon with more details…

“Guess Work” is now working, but “Set Attribute”/“Clone Dates” puts nothing in the error log, but does add a comment to the comment field. (Which is a little odd as last night they were putting that text in the error log too)

Yes have been noticing Loujin buttons not depressing when clicked, for a long time, not recently.
They take the clicks, but they don’t visually depress. :slight_smile:

Oh in fact, it’s also happening on my scripts, like MASS MERGE, maybe some button CSS changed in MBS, long time ago…

1 Like

Replace subwork script no longer works for me. I don’t know when it broke since I haven’t used it in a while. Windows 10, Violentmonkey, Firefox.

Hmm, Chrome works. So either one of my extensions is blocking it, or it’s something to do with Firefox.

Nevermind, this one doesn’t work on Chrome. Maybe because of the weird release name?