获取快手网站源代码中的class="top-count"的数据

从快手网站 (https://v.kuaishou.com/dCDGOr) 的源代码中提取class="top-count"的数据并显示在页面上

// ==UserScript==
// @name         获取快手网站源代码中的class="top-count"的数据
// @namespace    http://your-website.com
// @version      1.0
// @description  从快手网站 (https://v.kuaishou.com/dCDGOr) 的源代码中提取class="top-count"的数据并显示在页面上
// @author       Your Name
// @match        https://v.kuaishou.com/dCDGOr
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 使用fetch获取页面内容
    fetch(window.location.href)
        .then(response => response.text())
        .then(data => {
            // 创建一个虚拟DOM元素
            const tempDiv = document.createElement('div');
            tempDiv.innerHTML = data;

            // 查找带有 "top-count" 类名的元素
            const topCountElement = tempDiv.querySelector('.top-count');

            if (topCountElement) {
                const count = topCountElement.textContent.trim();
                console.log('class="top-count" 数据:', count);

                // 创建一个DOM元素来显示数据
                const countElement = document.createElement('div');
                countElement.textContent = 'class="top-count" 数据: ' + count;
                document.body.appendChild(countElement);
            } else {
                console.log('未找到带有 "top-count" 类名的数据');
            }
        })
        .catch(error => {
            console.error('获取源代码时出错:', error);
        });
})();