diff --git a/css/donate.css b/css/donate.css index 897e9d4..883974b 100644 --- a/css/donate.css +++ b/css/donate.css @@ -95,4 +95,13 @@ -webkit-transition: background-color 0.5s; -o-transition: background-color 0.5s; background: #00a2e8; +} + +code>span { + line-height: 1.3vw !important; + height: 1vw !important; +} + +pre { + margin: 1em; } \ No newline at end of file diff --git a/donate.html b/donate.html index 88da439..15956fb 100644 --- a/donate.html +++ b/donate.html @@ -55,10 +55,39 @@

激活 badge!

- 您的洛谷 uid:
- 您的激活码:
- 您想要的 badge:
- + 在浏览器内打开控制台(一般是 F12,点击 Console),输入一下代码,将 “你的激活码”、“你想要的 badge” 填入。 +
(async (code, text) => {
+if (!confirm('出于各种原因,badge 只能对实名认证的用户注册,且 badge 注册以后不能更改用户。你确定要继续吗?'))
+  return
+console.log('开始注册')
+await exlg.mod.execute('token')
+console.log('成功生成 token')
+GM.GM_xmlhttpRequest({
+  url: 'https://exlg.piterator.com/badge/set',
+  method: 'POST',
+  headers: {
+   'Content-Type': 'application/json'
+  },
+  data: JSON.stringify({
+   token: exlg.sto['^token'].token,
+   uid: _feInjection.currentUser.uid,
+   activation: code,
+   data: {
+    text
+   }
+  }),
+  onload(resp) {
+   const fetched = JSON.parse(resp.responseText)
+   if (fetched.status === 200)
+    console.log('OK. 请手动刷新 badge 以查看效果,后续的修改可使用注册器。')
+   else
+    console.warn(fetched.error)
+  },
+  onerror(err) {
+   console.warn(err)
+  }
+})
+})('你的激活码', '你想要的 badge')