// ==UserScript== // @name GO官网文档目录 // @namespace http://tampermonkey.net/ // @version 0.4 // @description GO官网文档目录, 解析cmd和doc两种路径文档 // @author pogusanqian // @match https://golang.google.cn/doc/* // @match https://golang.google.cn/cmd/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/447663/GO%E5%AE%98%E7%BD%91%E6%96%87%E6%A1%A3%E7%9B%AE%E5%BD%95.user.js // @updateURL https://update.greasyfork.icu/scripts/447663/GO%E5%AE%98%E7%BD%91%E6%96%87%E6%A1%A3%E7%9B%AE%E5%BD%95.meta.js // ==/UserScript== (function () { // 创建目录节点 const listWapper = document.body.appendChild(document.createElement('div')); const list = listWapper.appendChild(document.createElement('ul')); // 往目录节点中添加数据 h2表示的时doc路径下的路径, h3表示的时cmd下的路径 const dataNode = location.pathname.startsWith('/doc') ? document.querySelectorAll('article h2') : document.querySelectorAll('article h3'); for (const item of dataNode) { list.insertAdjacentHTML('beforeend', `