博客显示当前Cloudflare CDN节点,让界面更炫酷

本文基于huai.pub于2020-03-13 17:55:26发表的文章而成,遵循署名-非商业性使用 4.0 国标 (CC BY-NC 4.0)

前言

本博客自建立以来,先后托管于Cloudflare Pages和Vercel。几个月前,Vercel的A记录ip被GFW部分污染,经过拨测的全国测速,全国15%的地区污染[1]居然有那么多人看不到我精心完成的博客,这怎么能忍!

于是我上周把博客又切换回了Cloudflare Pages,虽然延迟比不上Vercel,全国ping出来平均都有150ms[2],但好在Cloudflare拥有很强的可定制性和全球可用性,也就不在意那一点延迟了。

这时,我又看到了这篇博客:在开启了CloudFlare的页面中显示当前节点信息

既然已经切换到了Cloudflare,何不整个炫酷的?放在页脚,页面整体渲染后再呈现信息,不影响性能的同时还能告诉各位连接的节点顺便装个逼

js脚本

代码

我修改了一下原文章中获取脚本的返回,缩减了一点点代码,然后增加了n多代码

原脚本用indexOf()匹配节点,修改版用正则替换了一下,改成了数组内套json的方法绝对不是看原版的括号不爽,这样更直接,难出错。

格式化后的JavaScript脚本,太长了,这里把它先折叠起来
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
$(document).ready(
$.ajax({
url: "/cdn-cgi/trace",
success: function (data, status) {
let areas = [
'{"s":"TNR","l":"Antananarivo, Madagascar"}',
'{"s":"CPT","l":"Cape Town, South Africa"}',
'{"s":"CMN","l":"Casablanca, Morocco"}',
'{"s":"DAR","l":"Dar Es Salaam, Tanzania"}',
'{"s":"JIB","l":"Djibouti City, Djibouti"}',
'{"s":"DUR","l":"Durban, South Africa"}',
'{"s":"JNB","l":"Johannesburg, South Africa"}',
'{"s":"KGL","l":"Kigali, Rwanda"}',
'{"s":"LOS","l":"Lagos, Nigeria"}',
'{"s":"LAD","l":"Luanda, Angola"}',
'{"s":"MPM","l":"Maputo, MZ"}',
'{"s":"MBA","l":"Mombasa, Kenya"}',
'{"s":"MRU","l":"Port Louis, Mauritius"}',
'{"s":"RUN","l":"Réunion, France"}',
'{"s":"BLR","l":"Bangalore, India"}',
'{"s":"BKK","l":"Bangkok, Thailand"}',
'{"s":"BWN","l":"Bandar Seri Begawan, Brunei"}',
'{"s":"CEB","l":"Cebu, Philippines"}',
'{"s":"CTU","l":"成都, 🇨🇳 中国大陆"}',
'{"s":"MAA","l":"Chennai, India"}',
'{"s":"CGP","l":"Chittagong, Bangladesh"}',
'{"s":"CKG","l":"重庆, 🇨🇳 中国大陆"}',
'{"s":"CMB","l":"Colombo, Sri Lanka"}',
'{"s":"DAC","l":"Dhaka, Bangladesh"}',
'{"s":"SZX","l":"东莞, 🇨🇳 中国大陆"}',
'{"s":"FUO","l":"佛山, 🇨🇳 中国大陆"}',
'{"s":"FOC","l":"福州, 🇨🇳 中国大陆"}',
'{"s":"CAN","l":"广州, 🇨🇳 中国大陆"}',
'{"s":"HGH","l":"杭州, 🇨🇳 中国大陆"}',
'{"s":"HAN","l":"Hanoi, Vietnam"}',
'{"s":"HNY","l":"衡阳, 🇨🇳 中国大陆"}',
'{"s":"SGN","l":"Ho Chi Minh City, Vietnam"}',
'{"s":"HKG","l":"🇭🇰 香港"}',
'{"s":"HYD","l":"Hyderabad, India"}',
'{"s":"ISB","l":"Islamabad, Pakistan"}',
'{"s":"CGK","l":"Jakarta, Indonesia"}',
'{"s":"TNA","l":"济南, 🇨🇳 中国大陆"}',
'{"s":"KHI","l":"Karachi, Pakistan"}',
'{"s":"KTM","l":"Kathmandu, Nepal"}',
'{"s":"CCU","l":"Kolkata, India"}',
'{"s":"KUL","l":"Kuala Lumpur, Malaysia"}',
'{"s":"LHE","l":"Lahore, Pakistan"}',
'{"s":"NAY","l":"廊坊, 🇨🇳 中国大陆"}',
'{"s":"LYA","l":"洛阳, 🇨🇳 中国大陆"}',
'{"s":"MFM","l":"🇲🇴 澳门"}',
'{"s":"MLE","l":"Malé, Maldives"}',
'{"s":"MNL","l":"Manila, Philippines"}',
'{"s":"BOM","l":"Mumbai, India"}',
'{"s":"NAG","l":"Nagpur, India"}',
'{"s":"NNG","l":"南宁, 🇨🇳 中国大陆"}',
'{"s":"DEL","l":"New Delhi, India"}',
'{"s":"KIX","l":"Osaka, Japan"}',
'{"s":"PNH","l":"Phnom Penh, Cambodia"}',
'{"s":"TAO","l":"青岛, 🇨🇳 中国大陆"}',
'{"s":"ICN","l":"Seoul, South Korea"}',
'{"s":"SHA","l":"上海, 🇨🇳 中国大陆"}',
'{"s":"SHE","l":"沈阳, 🇨🇳 中国大陆"}',
'{"s":"SJW","l":"石家庄, 🇨🇳 中国大陆"}',
'{"s":"SIN","l":"Singapore, Singapore"}',
'{"s":"SZV","l":"苏州, 🇨🇳 中国大陆"}',
'{"s":"TPE","l":"台北, 🇨🇳 台湾"}',
'{"s":"PBH","l":"Thimphu, Bhutan"}',
'{"s":"TSN","l":"天津, 🇨🇳 中国大陆"}',
'{"s":"NRT","l":"Tokyo, Japan"}',
'{"s":"ULN","l":"Ulaanbaatar, Mongolia"}',
'{"s":"VTE","l":"Vientiane, Laos"}',
'{"s":"WUH","l":"武汉, 🇨🇳 中国大陆"}',
'{"s":"WUX","l":"无锡, 🇨🇳 中国大陆"}',
'{"s":"XIY","l":"西安, 🇨🇳 中国大陆"}',
'{"s":"EVN","l":"Yerevan, Armenia"}',
'{"s":"CGO","l":"郑州, 🇨🇳 中国大陆"}',
'{"s":"CSX","l":"株洲, 🇨🇳 中国大陆"}',
'{"s":"AMS","l":"Amsterdam, Netherlands"}',
'{"s":"ATH","l":"Athens, Greece"}',
'{"s":"BCN","l":"Barcelona, Spain"}',
'{"s":"BEG","l":"Belgrade, Serbia"}',
'{"s":"TXL","l":"Berlin, Germany"}',
'{"s":"BRU","l":"Brussels, Belgium"}',
'{"s":"OTP","l":"Bucharest, Romania"}',
'{"s":"BUD","l":"Budapest, Hungary"}',
'{"s":"KIV","l":"Chișinău, Moldova"}',
'{"s":"CPH","l":"Copenhagen, Denmark"}',
'{"s":"ORK","l":"Cork, Ireland"}',
'{"s":"DUB","l":"Dublin, Ireland"}',
'{"s":"DUS","l":"Düsseldorf, Germany"}',
'{"s":"EDI","l":"Edinburgh, United Kingdom"}',
'{"s":"FRA","l":"Frankfurt, Germany"}',
'{"s":"GVA","l":"Geneva, Switzerland"}',
'{"s":"GOT","l":"Gothenburg, Sweden"}',
'{"s":"HAM","l":"Hamburg, Germany"}',
'{"s":"HEL","l":"Helsinki, Finland"}',
'{"s":"IST","l":"Istanbul, Turkey"}',
'{"s":"KBP","l":"Kyiv, Ukraine"}',
'{"s":"LIS","l":"Lisbon, Portugal"}',
'{"s":"LHR","l":"London, United Kingdom"}',
'{"s":"LUX","l":"Luxembourg City, Luxembourg"}',
'{"s":"MAD","l":"Madrid, Spain"}',
'{"s":"MAN","l":"Manchester, United Kingdom"}',
'{"s":"MRS","l":"Marseille, France"}',
'{"s":"MXP","l":"Milan, Italy"}',
'{"s":"DME","l":"Moscow, Russia"}',
'{"s":"MUC","l":"Munich, Germany"}',
'{"s":"LCA","l":"Nicosia, Cyprus"}',
'{"s":"OSL","l":"Oslo, Norway"}',
'{"s":"CDG","l":"Paris, France"}',
'{"s":"PRG","l":"Prague, Czech Republic"}',
'{"s":"KEF","l":"Reykjavík, Iceland"}',
'{"s":"RIX","l":"Riga, Latvia"}',
'{"s":"FCO","l":"Rome, Italy"}',
'{"s":"LED","l":"Saint Petersburg, Russia"}',
'{"s":"SOF","l":"Sofia, Bulgaria"}',
'{"s":"ARN","l":"Stockholm, Sweden"}',
'{"s":"TLL","l":"Tallinn, Estonia"}',
'{"s":"SKG","l":"Thessaloniki, Greece"}',
'{"s":"VIE","l":"Vienna, Austria"}',
'{"s":"VNO","l":"Vilnius, Lithuania"}',
'{"s":"WAW","l":"Warsaw, Poland"}',
'{"s":"ZAG","l":"Zagreb, Croatia"}',
'{"s":"ZRH","l":"Zürich, Switzerland"}',
'{"s":"ARI","l":"Arica, Chile"}',
'{"s":"ASU","l":"Asunción, Paraguay"}',
'{"s":"BOG","l":"Bogotá, Colombia"}',
'{"s":"EZE","l":"Buenos Aires, Argentina"}',
'{"s":"CWB","l":"Curitiba, Brazil"}',
'{"s":"FOR","l":"Fortaleza, Brazil"}',
'{"s":"GUA","l":"Guatemala City, Guatemala"}',
'{"s":"LIM","l":"Lima, Peru"}',
'{"s":"MDE","l":"Medellín, Colombia"}',
'{"s":"PTY","l":"Panama City, Panama"}',
'{"s":"POA","l":"Porto Alegre, Brazil"}',
'{"s":"UIO","l":"Quito, Ecuador"}',
'{"s":"GIG","l":"Rio de Janeiro, Brazil"}',
'{"s":"GRU","l":"São Paulo, Brazil"}',
'{"s":"SCL","l":"Santiago, Chile"}',
'{"s":"CUR","l":"Willemstad, Curaçao"}',
'{"s":"GND","l":"St. George‘s, Grenada"}',
'{"s":"AMM","l":"Amman, Jordan"}',
'{"s":"BGW","l":"Baghdad, Iraq"}',
'{"s":"GYD","l":"Baku, Azerbaijan"}',
'{"s":"BEY","l":"Beirut, Lebanon"}',
'{"s":"DOH","l":"Doha, Qatar"}',
'{"s":"DXB","l":"Dubai, United Arab Emirates"}',
'{"s":"KWI","l":"Kuwait City, Kuwait"}',
'{"s":"BAH","l":"Manama, Bahrain"}',
'{"s":"MCT","l":"Muscat, Oman"}',
'{"s":"ZDM","l":"Ramallah"}',
'{"s":"RUH","l":"Riyadh, Saudi Arabia"}',
'{"s":"TLV","l":"Tel Aviv, Israel"}',
'{"s":"IAD","l":"Ashburn, VA, United States"}',
'{"s":"ATL","l":"Atlanta, GA, United States"}',
'{"s":"BOS","l":"Boston, MA, United States"}',
'{"s":"BUF","l":"Buffalo, NY, United States"}',
'{"s":"YYC","l":"Calgary, AB, Canada"}',
'{"s":"CLT","l":"Charlotte, NC, United States"}',
'{"s":"ORD","l":"Chicago, IL, United States"}',
'{"s":"CMH","l":"Columbus, OH, United States"}',
'{"s":"DFW","l":"Dallas, TX, United States"}',
'{"s":"DEN","l":"Denver, CO, United States"}',
'{"s":"DTW","l":"Detroit, MI, United States"}',
'{"s":"HNL","l":"Honolulu, HI, United States"}',
'{"s":"IAH","l":"Houston, TX, United States"}',
'{"s":"IND","l":"Indianapolis, IN, United States"}',
'{"s":"JAX","l":"Jacksonville, FL, United States"}',
'{"s":"MCI","l":"Kansas City, MO, United States"}',
'{"s":"LAS","l":"Las Vegas, NV, United States"}',
'{"s":"LAX","l":"Los Angeles, CA, United States"}',
'{"s":"MFE","l":"McAllen, TX, United States"}',
'{"s":"MEM","l":"Memphis, TN, United States"}',
'{"s":"MEX","l":"Mexico City, Mexico"}',
'{"s":"MIA","l":"Miami, FL, United States"}',
'{"s":"MSP","l":"Minneapolis, MN, United States"}',
'{"s":"MGM","l":"Montgomery, AL, United States"}',
'{"s":"YUL","l":"Montréal, QC, Canada"}',
'{"s":"BNA","l":"Nashville, TN, United States"}',
'{"s":"EWR","l":"Newark, NJ, United States"}',
'{"s":"ORF","l":"Norfolk, VA, United States"}',
'{"s":"OMA","l":"Omaha, NE, United States"}',
'{"s":"PHL","l":"Philadelphia, United States"}',
'{"s":"PHX","l":"Phoenix, AZ, United States"}',
'{"s":"PIT","l":"Pittsburgh, PA, United States"}',
'{"s":"PAP","l":"Port-Au-Prince, Haiti"}',
'{"s":"PDX","l":"Portland, OR, United States"}',
'{"s":"QRO","l":"Queretaro, MX, Mexico"}',
'{"s":"RIC","l":"Richmond, Virginia"}',
'{"s":"SMF","l":"Sacramento, CA, United States"}',
'{"s":"SLC","l":"Salt Lake City, UT, United States"}',
'{"s":"SAN","l":"San Diego, CA, United States"}',
'{"s":"SJC","l":"San Jose, CA, United States"}',
'{"s":"YXE","l":"Saskatoon, SK, Canada"}',
'{"s":"SEA","l":"Seattle, WA, United States"}',
'{"s":"STL","l":"St. Louis, MO, United States"}',
'{"s":"TPA","l":"Tampa, FL, United States"}',
'{"s":"YYZ","l":"Toronto, ON, Canada"}',
'{"s":"YVR","l":"Vancouver, BC, Canada"}',
'{"s":"TLH","l":"Tallahassee, FL, United States"}',
'{"s":"YWG","l":"Winnipeg, MB, Canada"}',
'{"s":"ADL","l":"Adelaide, SA, Australia"}',
'{"s":"AKL","l":"Auckland, New Zealand"}',
'{"s":"BNE","l":"Brisbane, QLD, Australia"}',
'{"s":"MEL","l":"Melbourne, VIC, Australia"}',
'{"s":"NOU","l":"Noumea, New caledonia"}',
'{"s":"PER","l":"Perth, WA, Australia"}',
'{"s":"SYD","l":"Sydney, NSW, Australia"}'
];
let area = data.split("colo=")[1].split("\n")[0];
for (var i = 0; i < areas.length; i++) {
const as = JSON.parse(areas[i]);
if (as.s == area) {
document.getElementById("cdn").innerHTML = as.l;
break;
};
}
}
}
)
);

修改版将所有的中国节点加上了国旗emoji,替换为了中文,有兴趣的同学也可以自行替换其他节点

不过Cloudflare 大陆节点只有Enterprise Plan用户且已备案才能使用,我不认为能看到大陆节点出现的那一天😢

原理

Cloudflare为所有客户加上了/cdn-cgi/端点,任何一个套了Cloudflare的网站访问example.com/cdn-cgi/trace后都会返回用户现在的信息,如ip地址、CDN节点、是否开启WARP、tls协议版本等。

那么就可以在前端访问这个端点,再进行解析,将内容写入前段对应id的标签内,就可以呈现出目前的用户与Cloudflare CDN间的关系了。

使用

前提

由于使用了jQuery来访问cdn-cgi,所以使用这个脚本需要先引入这个库。已经引用了此库的博客无需再次引用。

目前大部分博客都用了jQuery库,所以大概率无需改代码。实在没有的可以简单改写下该脚本再使用

min缩减版:

1
$(document).ready($.ajax({url: "/cdn-cgi/trace",success: function(data, status) {let areas=['{"s":"TNR","l":"Antananarivo, Madagascar"}','{"s":"CPT","l":"Cape Town, South Africa"}','{"s":"CMN","l":"Casablanca, Morocco"}','{"s":"DAR","l":"Dar Es Salaam, Tanzania"}','{"s":"JIB","l":"Djibouti City, Djibouti"}','{"s":"DUR","l":"Durban, South Africa"}','{"s":"JNB","l":"Johannesburg, South Africa"}','{"s":"KGL","l":"Kigali, Rwanda"}','{"s":"LOS","l":"Lagos, Nigeria"}','{"s":"LAD","l":"Luanda, Angola"}','{"s":"MPM","l":"Maputo, MZ"}','{"s":"MBA","l":"Mombasa, Kenya"}','{"s":"MRU","l":"Port Louis, Mauritius"}','{"s":"RUN","l":"Réunion, France"}','{"s":"BLR","l":"Bangalore, India"}','{"s":"BKK","l":"Bangkok, Thailand"}','{"s":"BWN","l":"Bandar Seri Begawan, Brunei"}','{"s":"CEB","l":"Cebu, Philippines"}','{"s":"CTU","l":"成都, 🇨🇳 中国大陆"}','{"s":"MAA","l":"Chennai, India"}','{"s":"CGP","l":"Chittagong, Bangladesh"}','{"s":"CKG","l":"重庆, 🇨🇳 中国大陆"}','{"s":"CMB","l":"Colombo, Sri Lanka"}','{"s":"DAC","l":"Dhaka, Bangladesh"}','{"s":"SZX","l":"东莞, 🇨🇳 中国大陆"}','{"s":"FUO","l":"佛山, 🇨🇳 中国大陆"}','{"s":"FOC","l":"福州, 🇨🇳 中国大陆"}','{"s":"CAN","l":"广州, 🇨🇳 中国大陆"}','{"s":"HGH","l":"杭州, 🇨🇳 中国大陆"}','{"s":"HAN","l":"Hanoi, Vietnam"}','{"s":"HNY","l":"衡阳, 🇨🇳 中国大陆"}','{"s":"SGN","l":"Ho Chi Minh City, Vietnam"}','{"s":"HKG","l":"🇭🇰 香港"}','{"s":"HYD","l":"Hyderabad, India"}','{"s":"ISB","l":"Islamabad, Pakistan"}','{"s":"CGK","l":"Jakarta, Indonesia"}','{"s":"TNA","l":"济南, 🇨🇳 中国大陆"}','{"s":"KHI","l":"Karachi, Pakistan"}','{"s":"KTM","l":"Kathmandu, Nepal"}','{"s":"CCU","l":"Kolkata, India"}','{"s":"KUL","l":"Kuala Lumpur, Malaysia"}','{"s":"LHE","l":"Lahore, Pakistan"}','{"s":"NAY","l":"廊坊, 🇨🇳 中国大陆"}','{"s":"LYA","l":"洛阳, 🇨🇳 中国大陆"}','{"s":"MFM","l":"🇲🇴 澳门"}','{"s":"MLE","l":"Malé, Maldives"}','{"s":"MNL","l":"Manila, Philippines"}','{"s":"BOM","l":"Mumbai, India"}','{"s":"NAG","l":"Nagpur, India"}','{"s":"NNG","l":"南宁, 🇨🇳 中国大陆"}','{"s":"DEL","l":"New Delhi, India"}','{"s":"KIX","l":"Osaka, Japan"}','{"s":"PNH","l":"Phnom Penh, Cambodia"}','{"s":"TAO","l":"青岛, 🇨🇳 中国大陆"}','{"s":"ICN","l":"Seoul, South Korea"}','{"s":"SHA","l":"上海, 🇨🇳 中国大陆"}','{"s":"SHE","l":"沈阳, 🇨🇳 中国大陆"}','{"s":"SJW","l":"石家庄, 🇨🇳 中国大陆"}','{"s":"SIN","l":"Singapore, Singapore"}','{"s":"SZV","l":"苏州, 🇨🇳 中国大陆"}','{"s":"TPE","l":"台北, 🇨🇳 台湾"}','{"s":"PBH","l":"Thimphu, Bhutan"}','{"s":"TSN","l":"天津, 🇨🇳 中国大陆"}','{"s":"NRT","l":"Tokyo, Japan"}','{"s":"ULN","l":"Ulaanbaatar, Mongolia"}','{"s":"VTE","l":"Vientiane, Laos"}','{"s":"WUH","l":"武汉, 🇨🇳 中国大陆"}','{"s":"WUX","l":"无锡, 🇨🇳 中国大陆"}','{"s":"XIY","l":"西安, 🇨🇳 中国大陆"}','{"s":"EVN","l":"Yerevan, Armenia"}','{"s":"CGO","l":"郑州, 🇨🇳 中国大陆"}','{"s":"CSX","l":"株洲, 🇨🇳 中国大陆"}','{"s":"AMS","l":"Amsterdam, Netherlands"}','{"s":"ATH","l":"Athens, Greece"}','{"s":"BCN","l":"Barcelona, Spain"}','{"s":"BEG","l":"Belgrade, Serbia"}','{"s":"TXL","l":"Berlin, Germany"}','{"s":"BRU","l":"Brussels, Belgium"}','{"s":"OTP","l":"Bucharest, Romania"}','{"s":"BUD","l":"Budapest, Hungary"}','{"s":"KIV","l":"Chișinău, Moldova"}','{"s":"CPH","l":"Copenhagen, Denmark"}','{"s":"ORK","l":"Cork, Ireland"}','{"s":"DUB","l":"Dublin, Ireland"}','{"s":"DUS","l":"Düsseldorf, Germany"}','{"s":"EDI","l":"Edinburgh, United Kingdom"}','{"s":"FRA","l":"Frankfurt, Germany"}','{"s":"GVA","l":"Geneva, Switzerland"}','{"s":"GOT","l":"Gothenburg, Sweden"}','{"s":"HAM","l":"Hamburg, Germany"}','{"s":"HEL","l":"Helsinki, Finland"}','{"s":"IST","l":"Istanbul, Turkey"}','{"s":"KBP","l":"Kyiv, Ukraine"}','{"s":"LIS","l":"Lisbon, Portugal"}','{"s":"LHR","l":"London, United Kingdom"}','{"s":"LUX","l":"Luxembourg City, Luxembourg"}','{"s":"MAD","l":"Madrid, Spain"}','{"s":"MAN","l":"Manchester, United Kingdom"}','{"s":"MRS","l":"Marseille, France"}','{"s":"MXP","l":"Milan, Italy"}','{"s":"DME","l":"Moscow, Russia"}','{"s":"MUC","l":"Munich, Germany"}','{"s":"LCA","l":"Nicosia, Cyprus"}','{"s":"OSL","l":"Oslo, Norway"}','{"s":"CDG","l":"Paris, France"}','{"s":"PRG","l":"Prague, Czech Republic"}','{"s":"KEF","l":"Reykjavík, Iceland"}','{"s":"RIX","l":"Riga, Latvia"}','{"s":"FCO","l":"Rome, Italy"}','{"s":"LED","l":"Saint Petersburg, Russia"}','{"s":"SOF","l":"Sofia, Bulgaria"}','{"s":"ARN","l":"Stockholm, Sweden"}','{"s":"TLL","l":"Tallinn, Estonia"}','{"s":"SKG","l":"Thessaloniki, Greece"}','{"s":"VIE","l":"Vienna, Austria"}','{"s":"VNO","l":"Vilnius, Lithuania"}','{"s":"WAW","l":"Warsaw, Poland"}','{"s":"ZAG","l":"Zagreb, Croatia"}','{"s":"ZRH","l":"Zürich, Switzerland"}','{"s":"ARI","l":"Arica, Chile"}','{"s":"ASU","l":"Asunción, Paraguay"}','{"s":"BOG","l":"Bogotá, Colombia"}','{"s":"EZE","l":"Buenos Aires, Argentina"}','{"s":"CWB","l":"Curitiba, Brazil"}','{"s":"FOR","l":"Fortaleza, Brazil"}','{"s":"GUA","l":"Guatemala City, Guatemala"}','{"s":"LIM","l":"Lima, Peru"}','{"s":"MDE","l":"Medellín, Colombia"}','{"s":"PTY","l":"Panama City, Panama"}','{"s":"POA","l":"Porto Alegre, Brazil"}','{"s":"UIO","l":"Quito, Ecuador"}','{"s":"GIG","l":"Rio de Janeiro, Brazil"}','{"s":"GRU","l":"São Paulo, Brazil"}','{"s":"SCL","l":"Santiago, Chile"}','{"s":"CUR","l":"Willemstad, Curaçao"}','{"s":"GND","l":"St. George‘s, Grenada"}','{"s":"AMM","l":"Amman, Jordan"}','{"s":"BGW","l":"Baghdad, Iraq"}','{"s":"GYD","l":"Baku, Azerbaijan"}','{"s":"BEY","l":"Beirut, Lebanon"}','{"s":"DOH","l":"Doha, Qatar"}','{"s":"DXB","l":"Dubai, United Arab Emirates"}','{"s":"KWI","l":"Kuwait City, Kuwait"}','{"s":"BAH","l":"Manama, Bahrain"}','{"s":"MCT","l":"Muscat, Oman"}','{"s":"ZDM","l":"Ramallah"}','{"s":"RUH","l":"Riyadh, Saudi Arabia"}','{"s":"TLV","l":"Tel Aviv, Israel"}','{"s":"IAD","l":"Ashburn, VA, United States"}','{"s":"ATL","l":"Atlanta, GA, United States"}','{"s":"BOS","l":"Boston, MA, United States"}','{"s":"BUF","l":"Buffalo, NY, United States"}','{"s":"YYC","l":"Calgary, AB, Canada"}','{"s":"CLT","l":"Charlotte, NC, United States"}','{"s":"ORD","l":"Chicago, IL, United States"}','{"s":"CMH","l":"Columbus, OH, United States"}','{"s":"DFW","l":"Dallas, TX, United States"}','{"s":"DEN","l":"Denver, CO, United States"}','{"s":"DTW","l":"Detroit, MI, United States"}','{"s":"HNL","l":"Honolulu, HI, United States"}','{"s":"IAH","l":"Houston, TX, United States"}','{"s":"IND","l":"Indianapolis, IN, United States"}','{"s":"JAX","l":"Jacksonville, FL, United States"}','{"s":"MCI","l":"Kansas City, MO, United States"}','{"s":"LAS","l":"Las Vegas, NV, United States"}','{"s":"LAX","l":"Los Angeles, CA, United States"}','{"s":"MFE","l":"McAllen, TX, United States"}','{"s":"MEM","l":"Memphis, TN, United States"}','{"s":"MEX","l":"Mexico City, Mexico"}','{"s":"MIA","l":"Miami, FL, United States"}','{"s":"MSP","l":"Minneapolis, MN, United States"}','{"s":"MGM","l":"Montgomery, AL, United States"}','{"s":"YUL","l":"Montréal, QC, Canada"}','{"s":"BNA","l":"Nashville, TN, United States"}','{"s":"EWR","l":"Newark, NJ, United States"}','{"s":"ORF","l":"Norfolk, VA, United States"}','{"s":"OMA","l":"Omaha, NE, United States"}','{"s":"PHL","l":"Philadelphia, United States"}','{"s":"PHX","l":"Phoenix, AZ, United States"}','{"s":"PIT","l":"Pittsburgh, PA, United States"}','{"s":"PAP","l":"Port-Au-Prince, Haiti"}','{"s":"PDX","l":"Portland, OR, United States"}','{"s":"QRO","l":"Queretaro, MX, Mexico"}','{"s":"RIC","l":"Richmond, Virginia"}','{"s":"SMF","l":"Sacramento, CA, United States"}','{"s":"SLC","l":"Salt Lake City, UT, United States"}','{"s":"SAN","l":"San Diego, CA, United States"}','{"s":"SJC","l":"San Jose, CA, United States"}','{"s":"YXE","l":"Saskatoon, SK, Canada"}','{"s":"SEA","l":"Seattle, WA, United States"}','{"s":"STL","l":"St. Louis, MO, United States"}','{"s":"TPA","l":"Tampa, FL, United States"}','{"s":"YYZ","l":"Toronto, ON, Canada"}','{"s":"YVR","l":"Vancouver, BC, Canada"}','{"s":"TLH","l":"Tallahassee, FL, United States"}','{"s":"YWG","l":"Winnipeg, MB, Canada"}','{"s":"ADL","l":"Adelaide, SA, Australia"}','{"s":"AKL","l":"Auckland, New Zealand"}','{"s":"BNE","l":"Brisbane, QLD, Australia"}','{"s":"MEL","l":"Melbourne, VIC, Australia"}','{"s":"NOU","l":"Noumea, New caledonia"}','{"s":"PER","l":"Perth, WA, Australia"}','{"s":"SYD","l":"Sydney, NSW, Australia"}'];let area = data.split("colo=")[1].split("\n")[0];for (var i = 0; i < areas.length; i++) {const as = JSON.parse(areas[i]);if (as.s == area) {document.getElementById("cdn").innerHTML = as.l;break;}}}}));

放入<script></script>内或者作为文件引用皆可。

显示节点信息

在想要呈现节点信息的地方添加<span id="cdn"></span>即可

效果可见本博客下方⬇️

注释
  1. 数据来自于boce,本博客不保证正确性
  2. 来自ping.pe

博客显示当前Cloudflare CDN节点,让界面更炫酷
https://www.morax-xyc.com/post/ad876c0e/
作者
Morax-xyc
发布于
2022年9月18日
许可协议