mb-userscripts
mb-userscripts copied to clipboard
refactor: more TypeScript migration
I'm not refactoring these a lot (yet), just migrating to TypeScript so we can benefit from all the benefits. Also removing jQuery where possible (mainly because I've already removed it from the dependencies and don't want to re-add it). Migrating to JSX where it makes sense too. And fixing linter warnings, of course.
Coverage is probably going to take a nosedive but it was a lie anyway. I've tested the new versions manually to ensure they still work.
- [x]
mb_blind_votes.user.js - [x]
mb_bulk_copy_work_codes.user.js - [x]
mb_qol_inline_recording_tracks.user.js - [x]
mb_qol_seed_recording_disambiguation.user.js - [x]
mb_qol_select_all_update_recordings.user.js - [x]
mb_supercharged_caa_edits.user.js - [x]
mb_validate_work_codes.user.js - [ ] Update old scripts so they auto-update to the rewritten version.
- [ ] Update links in README.
I'll probably merge validate work codes into bulk copy work codes and rename the latter too.
Codecov Report
Merging #499 (7014446) into main (d1813bb) will decrease coverage by
24.14%. The diff coverage is4.37%.
@@ Coverage Diff @@
## main #499 +/- ##
===========================================
- Coverage 98.48% 74.34% -24.15%
===========================================
Files 58 63 +5
Lines 1385 1863 +478
Branches 220 293 +73
===========================================
+ Hits 1364 1385 +21
- Misses 13 462 +449
- Partials 8 16 +8
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/lib/MB/URLs.ts | 100.00% <ø> (ø) |
|
| src/lib/util/array.ts | 70.83% <0.00%> (-12.50%) |
:arrow_down: |
| src/lib/util/dom.ts | 70.58% <0.00%> (-18.31%) |
:arrow_down: |
| src/lib/util/xhr.ts | 100.00% <ø> (ø) |
|
| src/mb_blind_votes/index.ts | 0.00% <0.00%> (ø) |
|
| ...mb_enhanced_cover_art_uploads/providers/archive.ts | 100.00% <ø> (ø) |
|
| src/mb_supercharged_caa_edits/constants.ts | 0.00% <0.00%> (ø) |
|
| src/mb_work_code_toolbox/identifiers.ts | 0.00% <0.00%> (ø) |
|
| src/mb_work_code_toolbox/index.ts | 0.00% <0.00%> (ø) |
|
| src/mb_work_code_toolbox/validate.ts | 0.00% <0.00%> (ø) |
|
| ... and 2 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Just wanted to remember you, that there already is https://github.com/ROpdebee/mb-userscripts/tree/wip-blind-edits-rewrite
Yeah, that's a pretty big rewrite though. I'd like to get back to that eventually, but here I'm just focusing on refactoring them enough to get them to pass typechecking, linting, building and eventually deploying.
Also, I don't like bulk copy work codes' implementation. Very messy. 😅
Edit Oooh boy, Supercharged is 1000 lines of pain 😢 Less pain than the work codes, but still pain. Especially that jQuery UI widget.
/deploy-preview
This PR changes 9 built userscript(s):
mb_blind_votes(install preview, changes: 798966f4ea50d50e8e8555c521bb1b7a04eb2e59)mb_caa_dimensions(install preview, changes: 75502d62513ee07efc23374240ba37fb0c9e6d4d)mb_enhanced_cover_art_uploads(install preview, changes: 8a8b157013b451b4d45349e74089c9cd9ab1e952)mb_multi_external_links(install preview, changes: a82b79313e7ec48ed2f5085046f2b4735a5c3945)mb_qol_inline_recording_tracks(install preview, changes: 95bcdbea96145ccde3d7bc5bdea431a0d0e4a2a1)mb_qol_seed_recording_disambiguation(install preview, changes: 3c069b278e8701deac1dc9d35e5230f97537bf2d)mb_qol_select_all_update_recordings(install preview, changes: 124a28fdb451b6009b9bff2d45b6547acae23ed3)mb_supercharged_caa_edits(install preview, changes: 238c2cd0ddb817e1e6ad17c63444c041c23d8484)mb_work_code_toolbox(install preview, changes: ee464d674d57eed2e6430f8768b408cc0376e37c)
I've superficially tested all of these, and tested Supercharged in a bit more depth because the changes were a bit more complicated there. Seems to work fine on my end, but I suggest leaving this open for a while longer to make sure there are no regressions. I'll probably post in the forums too to ask people to try out the previews and report any regressions.
/deploy-preview with latest fixes
/deploy-preview more fixes
So I switched to @include rules over @match rules because the new scripts are still running on too many pages. The @exclude rules weren't working (probably the domain part was bad?) and I've decided that I've had enough of the stupid @match ruleset, which is just.…stupid.
<rant>
I despise the new @include rules, though. I'm no regex hater (I actually quite enjoy them, maybe I'm weird), but it's just not something you want to "show" your users. If anyone now wants to know what pages these scripts are going to run on, they'll be presented with a string of alien civilization-level garbage. They're also much more error-prone (I wish I had addressed #75 before tackling this).
At the same time, the @match scheme imposes stupid limitations. I'm all for the safer domain matching, absolutely, but its path matching is severely limited. Why is there no complement to @match like there is @exclude for @include? Why is there no way to specify "one of these two options here please" without writing a near-identical rule twice? Why the f– does a wildcard (*) match a path separator (/)?! And WHY does it then NOT match the query string (?...) in Tampermonkey?!? I just…can't.
I just want to write *.musicbrainz.org/release/* without matching musicbrainz.org/release/…/edit. Why do I need to write /https?://(\w+\?)?musicbrainz\.org/release/.+?([?#]|$)/ for such a simple match? 😕 Part of me wants to just say @match *.musicbrainz.org/* and add checks to the code to see if we're on a good page or not.
For the record, I know this won't ever improve because there are different implementations and even if they all coordinate and decide to implement that (which is unlikely considering all the userscripts written so far likely expect * to match multiple path parts), the implementations will probably differ anyway and there's likely going to be this one person who cannot upgrade to the newer version and is still stuck on GM3, meaning we still have to support the older patterns anyway.
</rant>
Noting for later: Supercharged is missing some separator on release events, c227924f4119639e917a47ed46afc82ea99628e7 wasn't a good fix.
2005-05-23 (GB)2005-06-06 (DE)
/deploy-preview let's see if this still works? We need to regenerate CAA Dimensions because the preview version was probably updated to a more recent main release while Supercharged is still expecting the new interface (it's very messy currently).