Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
browser-x
Advanced tools
Readme
BrowserX 是一个基于 NodeJS 实现的虚拟浏览器,它的目标是高效的实现 DOM 中最核心的特性,以便开发者能够在 NodeJS 中使用 W3C 标准方法来操作文档与样式。
element.style
、document.styleSheets
、window.getComputedStyle()
以及 CSSOM 相关构造器访问npm install browser-x
返回:Promise
var browser = require('browser-x');
var url = __dirname + '/debug.html';
browser({
url: url,
loadCssFile: true,
silent: false
}, function (errors, window) {
if (errors) {
throw errors;
}
var document = window.document;
var element = document.querySelector('#banner h2');
var fontFamily = window.getComputedStyle(element, '::after').fontFamily;
console.log(fontFamily);
});
{
/**
* 文件基础路径 - 支持本地或远程地址
*/
url: 'about:blank',
/*
* HTML 文本内容
*/
html: null,
/**
* 是否支持加载外部 CSS 文件
*/
loadCssFile: false,
/**
* 是否忽略内部解析错误-关闭它有利于开发调试
* @type {Boolean}
*/
silent: true,
/**
* 请求超时限制
* @type {Number} 毫秒
*/
resourceTimeout: 8000,
/**
* 最大的文件加载数量限制
* @type {Number} 数量
*/
resourceMaxNumber: 64,
/**
* 是否缓存请求成功的资源
* @return {Object}
*/
resourceCache: true,
/**
* 映射资源路径
* @param {String} 旧文件地址
* @return {String} 新文件地址
*/
resourceMap: function(file) {
return file;
},
/**
* 忽略资源
* @param {String} 文件地址
* @return {Boolean} 如果返回`true`则忽略当当前文件的加载
*/
resourceIgnore: function(file) {
return false;
},
/**
* 资源加载前的事件
* @param {String} 文件地址
*/
resourceBeforeLoad: function(file) {
},
/**
* 加载远程资源的自定义请求头
* @param {String} 文件地址
* @return {Object}
*/
resourceRequestHeaders: function(file) {
return {
'accept-encoding': 'gzip,deflate'
};
}
}
loadCssFile
选项)BrowserX 适合做这些事情:
例如:WebFont 压缩工具——font-spider
如果需要更多的 DOM 特性,例如跑基于 DOM 的测试脚本、甚至载入 jQuery 等,那么 jsdom 这个项目可能会更适合你(注意:它没有完整解析样式表)。
FAQs
A partial implementation of the W3C DOM API on top of an HTML5 parser and serializer.
The npm package browser-x receives a total of 120 weekly downloads. As such, browser-x popularity was classified as not popular.
We found that browser-x demonstrated a not healthy version release cadence and project activity because the last version was released 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.