为了实现Hiddify节点的筛选与属性提取功能,我们可以使用以下脚本。这个脚本将从Hiddify的节点中筛选特定的节点,并提取它们的属性

function extractNodeAttributes() {
    var nodes = document.querySelectorAll('.hiddify');
    var selectedNodes = [];
    var attributes = {};
    // 基本筛选节点
    nodes.forEach(node => {
        if (node.classList.contains('label')) {
            selectedNodes.push(node);
        }
    });
    // 提取selectedNodes中的节点的属性
    selectedNodes.forEach(node => {
        // 提取实体标签
        const entityTags = node.querySelectorAll('.*[*i]*/*[i]');
        // 提取每个实体的值
        entityTags.forEach(t => {
            const entity = t.innerText;
            if (entity) {
                attributes[entity] = null;
                attributes[entity] = attributes[entity] || [];
                attributes[entity].push(entity);
            }
        });
        // 提取标签中的某些属性
        if (node.classList.contains('href')) {
            for (var child of node.querySelectorAll('.child')) {
                if (child.classList.contains('href')) {
                    attributes['href'] = node.querySelectorAll('.href').map(child => child.innerText);
                    attributes['href'] = attributes['href'].join('');
                    attributes['href'] = attributes['href'].trim();
                }
            }
        }
    });
    return selectedNodes;
}

这个脚本的实现步骤如下:

  1. 筛选节点:首先筛选出Hiddify节点中的所有标签节点(.label 类),并存储在 selectedNodes 数组中。

  2. 处理实体标签:遍历筛选出的节点中的实体标签(.[*i]*/*[i]),提取实体的值并存储在 attributes 对象中。

  3. 提取特定属性:对于筛选出的每个节点,遍历其child标签,提取特定属性(如 href)的值,并存储在 attributes 对象中。

这个脚本可以用于筛选Hiddify节点并提取特定属性,帮助用户高效处理网页数据。

为了实现Hiddify节点的筛选与属性提取功能,我们可以使用以下脚本。这个脚本将从Hiddify的节点中筛选特定的节点,并提取它们的属性

@版权声明

转载原创文章请注明转载自星链加速器官网-官方下载 | 极速安全 畅游全球网络|轻松翻墙|魔法上网,网站地址:https://starlinkvpn-m.com/