
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
js-use-core
Advanced tools
JavaScript Comprehensive tool library, including full screen, copy and paste functions
🚩 支持 JS(浏览器)、Vue(兼容 Vue2)、React、Node.js 多端环境
一个现代化的 JavaScript 综合工具库,提供全屏、剪贴板、文件处理、字体管理、URL 操作、设备检测和 User Agent 解析等功能。采用统一的架构设计,支持 TypeScript,具有完善的错误处理和性能监控。
initialize()
npm install js-use-core
从 v1.3.0 开始,所有管理器都支持自动初始化,无需手动调用 initialize()
方法:
import {
FullscreenManager,
ClipboardManager,
FontManager,
UrlManager,
DeviceDetector,
UA
} from 'js-use-core';
// 全屏管理 - 直接使用,自动初始化
const fullscreen = new FullscreenManager();
await fullscreen.request(); // 自动处理初始化
// 剪贴板操作 - 直接使用,自动初始化
const clipboard = new ClipboardManager();
await clipboard.copyText('Hello World!'); // 自动处理初始化
// 字体管理 - 直接使用,自动初始化
const fontManager = new FontManager();
const result = await fontManager.check('Arial'); // 自动处理初始化
// URL 操作 - 同步操作,立即可用
const urlManager = new UrlManager('https://example.com');
urlManager.addQuery({ page: 1, size: 10 });
// 设备检测 - 直接使用,自动初始化
const device = new DeviceDetector();
const info = await device.getDeviceInfo(); // 自动处理初始化
// User Agent 解析 - 静态方法,无需初始化
const ua = UA.parse(navigator.userAgent);
console.log(ua.browser.name, ua.browser.version);
如果需要确保初始化完成,可以使用 ready()
方法:
const clipboard = new ClipboardManager();
await clipboard.ready(); // 等待初始化完成
// 现在可以安全使用所有功能
提供跨浏览器兼容的全屏 API,支持元素全屏、状态监听和错误处理。
import { FullscreenManager } from 'js-use-core';
const fullscreen = new FullscreenManager({
enablePerformanceMonitoring: true,
timeout: 5000
});
// 直接使用,自动初始化
await fullscreen.request(document.getElementById('video'));
支持文本、HTML、文件的复制和粘贴,具有权限管理和降级处理。
import { ClipboardManager } from 'js-use-core';
const clipboard = new ClipboardManager({
enablePermissionCheck: true,
enableFallback: true
});
// 直接使用,自动初始化
await clipboard.copyText('要复制的文本');
const text = await clipboard.readText();
字体加载检测、动态字体管理和跨域处理。
import { FontManager } from 'js-use-core';
const fontManager = new FontManager({
timeout: 3000,
enableCache: true
});
// 直接使用,自动初始化
await fontManager.addFont('CustomFont', '/fonts/custom.woff2');
const result = await fontManager.check(['Arial', 'CustomFont']);
文件读取、写入、下载和上传功能。
import { FileManager } from 'js-use-core';
const fileManager = new FileManager();
// 直接使用,自动初始化
const content = await fileManager.readFile(file);
URL 解析、构建和查询参数处理。
import { UrlManager } from 'js-use-core';
const url = new UrlManager('https://example.com/api');
url.addQuery({ page: 1, filter: 'active' });
console.log(url.toString());
设备类型检测、操作系统识别和浏览器检测。
import { DeviceDetector } from 'js-use-core';
const device = new DeviceDetector();
// 直接使用,自动初始化
const info = await device.getDeviceInfo();
console.log({
isMobile: info.isMobile,
isTablet: info.isTablet,
os: info.os,
browser: info.browser
});
User Agent 字符串解析、版本比较和生成。
import { UA } from 'js-use-core';
const ua = UA.parse(navigator.userAgent);
const isModern = UA.satisfies(ua, 'Chrome >= 100');
console.log(ua.browser.name, ua.browser.version);
DOM 操作、浏览器兼容性和通用工具函数。
import { isElement, debounce, throttle } from 'js-use-core';
if (isElement(element)) {
// DOM 操作
}
const debouncedFn = debounce(callback, 300);
const throttledFn = throttle(callback, 100);
浏览器 | 版本 | 支持 |
---|---|---|
Chrome | 66+ | ✅ |
Firefox | 63+ | ✅ |
Safari | 13.1+ | ✅ |
Edge | 79+ | ✅ |
IE | 不支持 | ❌ |
所有管理器都支持统一的基础配置:
const options = {
debug: false, // 调试模式
timeout: 5000, // 操作超时时间
retries: 2, // 重试次数
cache: true, // 启用缓存
cacheTTL: 30000 // 缓存过期时间
};
好消息! 从 v1.3.0 开始,所有管理器都支持自动初始化,使用更加简单:
// v1.3.0+ 推荐方式 - 自动初始化
const clipboard = new ClipboardManager();
await clipboard.copyText('hello'); // 直接使用,自动处理初始化
// 旧方式仍然支持(向后兼容)
const clipboard = new ClipboardManager();
await clipboard.initialize(); // 可选,但不是必需的
await clipboard.copyText('hello');
// 旧版本
import { fullscreen } from 'js-use-core';
// 新版本 - 自动初始化
import { FullscreenManager } from 'js-use-core';
const fullscreen = new FullscreenManager();
await fullscreen.request(); // 直接使用
initialize()
ready()
方法 - 等待初始化完成详细迁移指南请参考 MIGRATION_GUIDE.md
欢迎贡献代码!请查看 CONTRIBUTING.md 了解详情。
# 克隆项目
git clone https://github.com/chao921125/js-use-core.git
# 安装依赖
npm install
# 运行测试
npm test
# 构建项目
npm run build
MIT License - 详见 LICENSE 文件
FAQs
JavaScript Comprehensive tool library, including full screen, copy and paste functions
The npm package js-use-core receives a total of 72 weekly downloads. As such, js-use-core popularity was classified as not popular.
We found that js-use-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.