一键批量导出自己企鹅好友
  an7r1i2Cj68o 23小时前 10 0

先附上原作者的代码

/**
     * @author ius.
     * @date 2022/8/1
     * @introduction 获取QQ好友列表
     */
    function getCookie(aim) {
        const allText = document.cookie.replace(/\s*/g, ''); //document.cookie
        oneText = allText.split(";");
        for (var two of oneText) {
            const three = two.split("=");
            if (aim === three[0]) {
                return two;
            }
        }
    }

    const gtk = user.getToken();
    const uin = getCookie("uin").substring(5);
    const xhr = new XMLHttpRequest();
    const qzonetoken = window.shine0callback;
    var url = 'https://mobile.qzone.qq.com/friend/mfriend_list?qzonetoken=' + qzonetoken + '&g_tk=' + gtk + '&res_uin=' + uin + '&res_type=normal&format=json&count_per_page=10&page_index=0&page_type=0&mayknowuin=&qqmailstat=';
    xhr.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            const json = JSON.parse(xhr.responseText)
            const allGroup = json.data.gpnames;
            const allFriend = json.data.list;
            var consoleContext = "";
            for (var groupid of allGroup) {
                consoleContext += groupid["gpname"] + ":\n";
                for (const friendid of allFriend) {
                    if (groupid["gpid"] === friendid["groupid"]) {
                        consoleContext += "  " + friendid["remark"] + "(" + friendid["uin"] + ")" + "\n";
                    }
                }
            }
            console.log(consoleContext);
        }
    }
    xhr.open('GET', url)
    xhr.withCredentials = true;
    xhr.send()

获取的信息是好友名字+(账号)

下面是我改良版本

获取的信息是账号

// 获取指定名称的cookie值
function getCookie(aim) {
    // 去除cookie字符串中的空格
    const allText = document.cookie.replace(/\s*/g, '');
    // 将cookie字符串按分号分割成数组
    const oneText = allText.split(";");
    
    // 遍历每个cookie
    for (var two of oneText) {
        // 将cookie按等号分割成键值对
        const three = two.split("=");
        // 检查当前cookie的名称是否与目标名称匹配
        if (aim === three[0]) {
            return two; // 返回匹配的cookie
        }
    }
}

// 获取用户的GTK(用于验证的令牌)
const gtk = user.getToken();
// 从cookie中获取用户的uin,并去掉前缀
const uin = getCookie("uin").substring(5);

// 创建一个XMLHttpRequest对象以发送HTTP请求
const xhr = new XMLHttpRequest();
// 获取qzonetoken
const qzonetoken = window.shine0callback;

// 构建请求的URL
var url = 'https://mobile.qzone.qq.com/friend/mfriend_list?qzonetoken=' + qzonetoken + '&g_tk=' + gtk + '&res_uin=' + uin + '&res_type=normal&format=json&count_per_page=10&page_index=0&page_type=0&mayknowuin=&qqmailstat=';

// 设置请求状态变化的回调函数
xhr.onreadystatechange = function () {
    // 当请求完成且响应状态为200(成功)时
    if (this.readyState == 4 && this.status == 200) {
        // 解析JSON格式的响应文本
        const json = JSON.parse(xhr.responseText);
        // 获取所有分组
        const allGroup = json.data.gpnames;
        // 获取所有好友列表
        const allFriend = json.data.list;

        // 遍历每个分组
        for (var groupid of allGroup) {
            // 遍历每个好友
            for (const friendid of allFriend) {
                // 检查好友的分组ID是否与当前分组的ID匹配
                if (groupid["gpid"] === friendid["groupid"]) {
                    // 如果匹配,打印该好友的uin(账号),每个账号单独一行
                    console.log(friendid["uin"]);
                }
            }
        }
    }
}

// 初始化GET请求
xhr.open('GET', url);
// 允许携带凭证(如cookie)
xhr.withCredentials = true;
// 发送请求
xhr.send();

使用方式

电脑EDGE或者Chrome浏览器

打开QQ空间登录然后切换仿真模式

然后在把地址改为:https://h5.qzone.qq.com/mqzone/index

最后把代码放在控制台上回车就搞定了

下面以edge浏览器为例子

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 23小时前 0

暂无评论

推荐阅读
  ZTo294hNoDcA   3天前   23   0   0 Java
  mgo1fSDRePpT   2天前   16   0   0 Java
  ukiVIBTK2zBw   2天前   16   0   0 Java
an7r1i2Cj68o