Ferium add command for modrinth

2022/6/6 19:57:03

目前为 2022-06-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Ferium add command for modrinth
  3. // @namespace Violentmonkey Scripts
  4. // @match https://modrinth.com/mods
  5. // @license MIT
  6. // @grant none
  7. // @version 0.1.0
  8. // @author -
  9. // @description 2022/6/6 19:57:03
  10. // ==/UserScript==
  11.  
  12. const observer = new MutationObserver((mutations, observer) => {
  13. for(const mutation of mutations) {
  14. if (mutation.type === 'childList' && mutation.target.id === 'search-results') {
  15. for(const node of mutation.addedNodes) {
  16. if(node.className === 'project-card card') {
  17. const buttons = node.querySelector('.right-side .buttons')
  18. const title = node.querySelector('.title a').href.match(/.*\/(.*)/)[1]
  19. buttons.innerHTML += `<button class="iconified-button" onclick='navigator.clipboard.writeText("ferium add ${title}");this.innerText="Copied!"' title="ferium add ${title}">Ferium</button>`
  20. }
  21. }
  22. }
  23. }
  24. });
  25. observer.observe(document.body, { attributes: false, childList: true, subtree: true });