Open in PlayMB

MusicBrainz の recording を PlayMB で開くリンクを追加

  1. // ==UserScript==
  2. // @name Open in PlayMB
  3. // @namespace http://rokoucha.net/
  4. // @version 1.0.1
  5. // @description MusicBrainz の recording を PlayMB で開くリンクを追加
  6. // @author rokoucha
  7. // @license MIT
  8. // @match https://musicbrainz.org/recording/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=musicbrainz.org
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict'
  15.  
  16. const target = document.querySelector('.subheader')
  17. if(!target) return
  18.  
  19. const [[_, mbid]] = [...document.location.pathname.matchAll('/recording/([^/]+)')]
  20.  
  21. const openPlayMBLink = document.createElement('a')
  22. openPlayMBLink.textContent = 'Open in PlayMB'
  23. openPlayMBLink.href = `https://playmb.rinsuki.net/recording/${mbid}`
  24. openPlayMBLink.target = '_blank'
  25.  
  26. target.after(openPlayMBLink)
  27. })()