聊天室小尾巴 之 借鉴 @taozhiyu
(! function () {
// 定义
let t = 0,
today = "",
currCont = "",
e = 0;
// 这是要拼凑么?
const o = ($(".avatar-small").css("background-image").match(/https?:\/\/[^?]+/g) || [
"https://file.fishpi.cn/2021/10/blob-29bbd528.png"])[0],
n = function (cont) {
// 输入框的内容
const n = ChatRoom.editor.getValue();
// 重新设置内容, 添加后缀
ChatRoom.editor.setValue(n.trim().startsWith("小冰") || n.trim().startsWith("点歌") || n.trim().startsWith("朗读") ||
n.trim().toUpperCase().startsWith("TTS") || n.trim().startsWith("tts") ?
n :
n + `\n` + (100 !== t ?
`\n\n\n> ${($('.person-info').data('percent') + '').trim()+"%"} ${"[" + ">".repeat(Math.floor(t / 10)) + "=".repeat(10 - Math.floor(t / 10)) + "]"}
\n> ${15 - Math.floor((new Date().getTime() - e) / 1e3)} 秒后充能完毕 ` :
`\n\n\n> ${cont}`
))
setTimeout(() => ChatRoom._send(), 0);
};
// 看不懂这是要干啥
ChatRoom._send = ChatRoom._send || ChatRoom.send
// send 函数
ChatRoom.send = function () {
arguments.callee && !["ctrlEnter", "onclick"].includes(arguments.callee.caller.name) ? ChatRoom._send() :
100 !== t && new Date().getTime() - e > 15e3 ? (fetch("https://fishpi.cn/user/liveness?_=" + Math.random())
.then(t => t.json()).then(e => {
t = e.liveness
getDaily(new Date().format("yyyy-MM-dd"));
}), e = new Date().getTime()) : getDaily(new Date().format("yyyy-MM-dd"));
};
// 获取每日一句
function getDaily (daily){
// 赋值
if(typeof (today) == "undefined" || today == ""){
today = daily;
}
// 当前日期和储存日期一样
if(today == daily){
// 没有内容的时候
if(typeof (currCont) == "undefined" || currCont == ""){
// 获取每日一句
$.ajax({
url: "https://sentence.iciba.com/index.php?c=dailysentence&m=getdetail&title=" + daily,
type: "GET",
async: false,
dataType: "jsonp",
success: function (data) {
// 赋值 并调用
currCont = data.content;
n(data.content);
}
});
}else{
// 有值的时候直接返回
n(currCont);
}
}else{
// 把当前日期续上
today = daily;
// 获取每日一句
$.ajax({
url: "https://sentence.iciba.com/index.php?c=dailysentence&m=getdetail&title=" + daily,
type: "GET",
async: false,
dataType: "jsonp",
success: function (data) {
// 赋值 并调用
currCont = data.content;
n(data.content);
}
});
}
}
// 日期格式化
Date.prototype.format = function (format) {
var args = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds()
};
if (/(y+)/.test(format))
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var i in args) {
var n = args[i];
if (new RegExp("(" + i + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
}
return format;
};
}())();
我就是想加句骚话, 但是没有找到合适的 API. 那就只能每日一句了...
百花齐放
恭喜恭喜 科研成功 小尾巴真不错
确实烧