Warning: fopen(/www/sites/update.greasyfork.icu/index/store/forever/33f015579ad069bdfec81f027ab118f9.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript==
// @name 鸿蒙字体
// @namespace 鸿蒙字体
// @version 1.5
// @description 在网页中使用华为鸿蒙字体,优先尝试加载本地字体资源,若不存在则从网络加载。
// @author LWF
// @license MIT
// @match *://*/*
// @exclude *://fanqienovel.com/reader/*
// @exclude *://*.android.google.cn/*
// @exclude *://www.bilibili.com/*
// @run-at document-start
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
// 检查本地是否已安装华为鸿蒙字体,若已安装则直接使用,否则加载网络字体资源
const fontName = 'HarmonyOS Sans';
if (!document.fonts.check(`12px "${fontName}"`)) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://developer.huawei.com/config/commonResource/font/font.css';
document.head.appendChild(link);
}
// 应用字体样式至所有元素
const style = document.createElement('style');
document.head.appendChild(style);
style.textContent = `
* {
font-family: '${fontName}', sans-serif !important;
}
`;
})();