# 如何在Galaxy平台上查看自己当前参与活动数(银河牛仔活动)


By [Martin Zhan](https://paragraph.com/@martin-zhan) · 2022-02-06

---

![](https://storage.googleapis.com/papyrus_images/182f820f33811e0678f53c2d960fada221defc3b15e9ebc407c97c51b84b8e33.png)

先点击红框查看是否满足要求的标准，是这个网页

[https://galaxy.eco/credential/666](https://galaxy.eco/credential/666)

从上述官方提供的代码可以看出，原理就是：先获取用户参与的所有活动（每个活动有一个属性numberID，numberID可以唯一标志一个活动），然后筛选出不同的numberID有几个，用户真实参与的活动数就是几。

那么我们怎么自己查看当前自己参与的活动数？把代码稍作修改即可，我写了如下：

    var httpRequest = new XMLHttpRequest();//第一步：创建需要的对象
    var query = {
        "query": "query addressInfo($address: String!) {\r\n  addressInfo(address: $address) {\r\n    recentParticipation(input: { first: 10000 }) {\r\n      list {\r\n        campaign {\r\n          numberID\r\n      }\r\n      }\r\n    }\r\n  }\r\n}",
        "variables": {
            "address": "0x__________________"
        }
    }
    httpRequest.open('POST', 'https://graphigo.prd.galaxy.eco/query', true); //第二步：打开连接
    httpRequest.setRequestHeader("Content-type","application/json");//设置请求头
    httpRequest.send(JSON.stringify(query));//发送请求
    
    httpRequest.onreadystatechange = function () {//请求后的回调接口，可将请求成功后要执行的程序写在其中
        if (httpRequest.readyState == 4 && httpRequest.status == 200) {//验证请求是否发送成功
            var res = httpRequest.responseText;//获取到服务端返回的数据
            var data = JSON.parse(res).data
            var ans
            if(data == null || data.addressInfo == null || data.addressInfo.recentParticipation == null || data.addressInfo.recentParticipation.list == null || data.addressInfo.recentParticipation.list.length == 0) {
                ans = 0
            } else {
                let parts = data.addressInfo.recentParticipation.list
                let s = new Set()
                for (const part of parts) {
                    s.add(part.campaign.numberID)
                }
                ans = s.size
            }
            alert("参加活动数: " + ans.toString());
        }
    };
    

如何使用？步骤如下：

1.打开银河官网

[https://galaxy.eco/](https://galaxy.eco/)

2.键盘按快捷键F12打开开发者工具

3.点击Sources

![](https://storage.googleapis.com/papyrus_images/e5832472d8645efb3a84cca7acc53d9c76146b17b7bbb56eefacc9ac784232e9.png)

5.点击Snippets

![](https://storage.googleapis.com/papyrus_images/a3a92588b9807fc7da8f8124b307c1b17e26c50261c1e462fb6a2764d5d9e45c.png)

6.点击New snippets，自己随意命名为xxx.js（我命名为了project\_galaxy.js），然后把上面提供的代码粘贴到右边代码区。

![](https://storage.googleapis.com/papyrus_images/97dbe71d3f6f17e093a99b550ad35196b8deca3f52ed5d21c010f38d2bd8b7d4.png)

7.将自己的地址拷贝到箭头位置

![](https://storage.googleapis.com/papyrus_images/a4c37ef913c6bc14e3b8a3a07ab9177296ed432d84334afcbde366e00be24925.png)

8.右键选择文件名，点击Run即可运行。

![](https://storage.googleapis.com/papyrus_images/ad72460011773f398b781d4e7ef734803768b78f3692d44b3e941c84fce01619.png)

9.运行成功后即弹出提示当前自己的参加活动数。

![](https://storage.googleapis.com/papyrus_images/ede3ef9f3031ea6462fffc5a61703253aa424d9f173ffd9940d2e0a0a63823a0.png)

以后任何时候想查看自己的参与活动数，就按F12打开开发者工具，然后Sources→Snippets→Run即可查看。

---

*Originally published on [Martin Zhan](https://paragraph.com/@martin-zhan/galaxy)*
