# 如何在Galaxy平台上查看自己当前参与活动数(银河牛仔活动) **Published by:** [Martin Zhan](https://paragraph.com/@martin-zhan/) **Published on:** 2022-02-06 **URL:** https://paragraph.com/@martin-zhan/galaxy ## Content 先点击红框查看是否满足要求的标准,是这个网页 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/ 2.键盘按快捷键F12打开开发者工具 3.点击Sources5.点击Snippets6.点击New snippets,自己随意命名为xxx.js(我命名为了project_galaxy.js),然后把上面提供的代码粘贴到右边代码区。7.将自己的地址拷贝到箭头位置8.右键选择文件名,点击Run即可运行。9.运行成功后即弹出提示当前自己的参加活动数。以后任何时候想查看自己的参与活动数,就按F12打开开发者工具,然后Sources→Snippets→Run即可查看。 ## Publication Information - [Martin Zhan](https://paragraph.com/@martin-zhan/): Publication homepage - [All Posts](https://paragraph.com/@martin-zhan/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@martin-zhan): Subscribe to updates