您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Convert maven tab from xml to yml on mvnrepository
// ==UserScript== // @name Convert maven tab from xml to yml // @namespace http://tampermonkey.net/ // @version 0.1 // @description Convert maven tab from xml to yml on mvnrepository // @author eggplants // @homepage https://github.com/eggplants // @match *://mvnrepository.com/artifact/*/*/* // @grant none // @license MIT // ==/UserScript== /*jshint esversion: 6 */ (function () { "use strict"; "use moz"; const findComments = (el) => { let arr = []; for (let i = 0; i < el.childNodes.length; i++) { let node = el.childNodes[i]; if (node.nodeType === 8) { arr.push(node); } else { arr.push.apply(arr, findComments(node)); } } return arr; }; const mvn = document.querySelector("textarea#maven-a"); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(mvn.value, "text/xml"); const comments = findComments(xmlDoc); const dep = xmlDoc.querySelector("dependency"); if (dep !== null) { mvn.value = `# ${ comments.length > 0 ? comments[0].textContent.trim() + "\n" : "" }`; mvn.value += "- {" + Array.from(dep.children) .map((e) => `${e.tagName}: ${e.textContent}`) .join(", ") + "}"; } })();