您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
// ==UserScript== // @name lodash左侧滚动条滚动到当前查看方法的位置 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://www.lodashjs.com/* // @grant none // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js // @icon https://www.lodashjs.com/icons/favicon-32x32.png // ==/UserScript== (function() { 'use strict'; const name = location.pathname.split('.')[1]; // 当前页面展示的方法名 $(function(){ // document.querySelectorAll('.toc-container code') $('.toc-container code').each((index, item) => { // 获取code标签下的文本 const text = $(item).text(); if (text.includes('_.')) { // 只获取文本中方法名的字段 const str = text.replace(/_./, ''); // 若当前方法和页面url的方法名一致,则设置样式,并让左侧列表容器的滚动条滚动到当前元素 if (str === name) { $(item).css({ 'color': '#00bfff', 'font-size': '1.2em' }); $(item)[0].scrollIntoView({ block: 'center' }); } } }); }) // Your code here... })();