ChatGPT会员版查看费用按钮及JS代码优化
<p><button id="btn_grants" onclick="viewGrants()" autocomplete="off" class="ui button">查看费用</button></p>
<script type="text/javascript">
async function viewGrants() {
var url = "https://svip1-api.cveoy.top/v3/grants";
var key = document.getElementById("edit_openaikey").value.trim()
localStorage.setItem('APIKEY', key);
var data = JSON.stringify({"keys": key});
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function() {
if (xhr.status === 200) {
var response = JSON.parse(xhr.response);
if(response.activateTime == null) response.useAmount = 0;
var strgrent = "今日使用次数:" + response.useAmount;
var expires_at = response.activateTime*1+(response.expire*60*1000)
var date = new Date(expires_at);
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = (date.getDate() < 10 ? '0'+(date.getDate()) : date.getDate()) + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
if(response.activateTime == null) {
strgrent += "<br/>到期时间:您还未使用"
}else {
strgrent += "<br/>到期时间:" + Y + M + D + h + m + s
}
var editgrent = document.getElementById("edit_grents")
editgrent.innerHTML = strgrent;
var menuDiv = document.querySelector(".ui.menu.mt-30");
var btnGrants = document.querySelector("#btn_grants");
menuDiv.insertBefore(btnGrants, menuDiv.firstChild);
} else {
editgrent.innerHTML = xhr.statusText;
}
};
await xhr.send(data);
};
</script>
<body>
<header class="ui sticky menu" id="sticky-header">
<div class="ui container">
<a href="vip.html" class="header item">AI会员版 Chat GpT</a>
</div>
</header>
<div class="ui basic segment pt-10">
<div class="ui call-to-action gray-bg ptb-60">
<div class="ui container">
<div id="edit_grents">
<span style="color:red">SVip每天300次问答,开通代理+V:<a href="weixin://">ziyuan2319</a></span>
</div>
<div class="ui form">
<div class="field">
<input id="edit_openaikey" placeholder="sk-这里填写key" autocomplete="off" type="password">
</div>
<div class="field">
<textarea id="chat-gpt-input" placeholder="输入你的问题"></textarea>
</div>
<div class="field">
<button id="answer" onclick="callCHATGPT()" class="ui primary button">点击回答</button>
<button onclick="location.reload()" class="ui button">清空内容</button>
<button onclick="copyCode()" class="ui button">复制结果</button>
<button id="saveBtn" class="ui button">保存Key</button>
<button onclick="save()" autocomplete="off" class="ui button">保存内容</button>
<button id="btn_grants" onclick="viewGrants()" autocomplete="off" class="ui button">查看费用</button>
<button class="ui button">开通会员</button>
</div>
<div class="field">
<textarea id="chatgpt-response" placeholder="由于是长涂访问,如果遇到卡顿不回答,点击“清空内容”按钮即可"></textarea>
</div>
</div>
</div>
<footer class="ui basic segment gray-bg text-center ptb-20">
<div class="ui container">
<div class="ui menu mt-30">
<a class="item">无涯工作室 ChatGpT会员开通</a>
<div class="item" id="result"></div>
</div>
</div>
</footer>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
</body>
原文地址: https://www.cveoy.top/t/topic/ksYB 著作权归作者所有。请勿转载和采集!