// ==UserScript==
// @name Ferium add command for modrinth
// @namespace Violentmonkey Scripts
// @match https://modrinth.com/*
// @license MIT
// @grant none
// @version 0.2.2
// @author -
// @description 2022/6/6 19:57:03
// @downloadURL none
// ==/UserScript==
const observer = new MutationObserver((mutations, observer) => {
for(const mutation of mutations) {
if (mutation.type === 'childList' && mutation.target.id === 'search-results') {
for(const node of mutation.addedNodes) {
const buttons = node.querySelector('.right-side .buttons')
if(node.className === 'project-card card' && !buttons.querySelector('button[title^="ferium"]')) {
const title = node.querySelector('.title a').href.match(/.*\/(.*)/)[1]
buttons.innerHTML += ``
}
}
}
}
});
observer.observe(document.body, { attributes: false, childList: true, subtree: true });
// Mod detail
const tabs = document.querySelector(".navigation.card");
if(tabs) {
const id = location.href.match(/mod\/(.+?)\/?$/)[1]
tabs.innerHTML += `Ferium`
}