Bilibili Level SVG

提供Bilibili等级(LV0-LV6及硬核会员)的SVG元素获取函数。

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/584803/1863155/Bilibili%20Level%20SVG.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Аўтар
ryxel
Версія
1.0.0
Створаны
29.06.2026
Абноўлены
29.06.2026
Памер
11.5 КБ
Ліцэнзія
MIT

一个获取 Bilibili 等级(LV0 ~ LV6 及硬核会员) SVG 元素的 JavaScript 库。

调用 getLevelSvg 函数并传入对应的等级(支持数字或字符串 0~6,硬核会员传入 'h'),即可返回解析后的 SVGElement DOM 元素。由于原始 SVG 未指定宽高,获取后需要自行设置尺寸才能正常显示。若传入无效等级则返回 null

// 使用示例
const lv6Svg = getLevelSvg(6);   // 返回 LV6 的 SVG 元素
const hcSvg = getLevelSvg('h');  // 返回硬核会员的 SVG 元素

// 必须设置尺寸,否则图标无法正常显示
lv6Svg.style.height = '20px';
lv6Svg.style.width = 'auto';

document.querySelector('.user-level-container').appendChild(lv6Svg);