您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
12/12/2021, 12:45:13 PM
当前为
// ==UserScript== // @name NPM Package Size from BundlePhobia // @namespace Violentmonkey Scripts // @match https://www.npmjs.com/package/* // @grant GM_xmlhttpRequest // @version 1.1 // @author dutzi // @license MIT // @description 12/12/2021, 12:45:13 PM // ==/UserScript== const interval = setInterval(async () => { const container = document.querySelector('[title="Copy Command to Clipboard"]').parentElement.parentElement if (!container) { return } const el = document.createElement('a') el.innerHTML = 'Fetching stats from BundlePhobia...' container.prepend(el) clearInterval(interval) let prevLocation = ''; setInterval(updateStats, 100) updateStats() function updateStats() { if (prevLocation === window.location.href) { return } prevLocation = window.location.href; const packageName = window.location.href.split('?')[0].split('/').slice(4).join('/') el.href = `https://bundlephobia.com/package/${packageName}` Object.assign(el.style, { textDecoration: 'none', display: 'block', border: '2px solid #65c3f8', color: '#65c3f8', padding: '0.75rem 1rem', borderRadius: '4px', transition: 'all 0.5s ease-out' }) GM_xmlhttpRequest({ method: 'GET', url: `https://bundlephobia.com/api/size?package=${packageName}`, onload: ({response}) => { const data = JSON.parse(response); const { size, gzip } = data; el.innerHTML = `Size: <strong>${size.toLocaleString()}</strong>, Gzipped: <strong>${gzip.toLocaleString()}</strong>` } }) } }, 100)