更新通知部分

This commit is contained in:
李万一 2021-11-03 13:56:00 +00:00 committed by Gitee
parent c2faf00855
commit 5b57539732

View File

@ -84,7 +84,7 @@
$('p[class^="point-block"]').each((i, e) => {
e.firstChild.firstChild.nodeValue = sidebarDict[e.firstChild.firstChild.nodeValue];
});
// 4条
// 4条 状态条
$('p[class^="bar-name"]').each((i, e) => {
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
});
@ -93,8 +93,10 @@
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
});
// [use]按钮
$('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
$('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
if ($('#pointsMerits').length !== 0)
$('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
if ($('#pointsPoints').length !== 0)
$('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
clearInterval(sidebarInterval);
}, 1000);
@ -150,62 +152,165 @@
* 通知
*/
if (window.location.href.indexOf('events.php') >= 0) {
let events = $('span.mail-link');
let events;// = $('span.mail-link');
const eventMutation = new MutationObserver(() => {
events = $('span.mail-link');
eventsTrans();
});
//初始化中内容未加载
let eventInterval = setInterval(() => {
console.log('循环判断内容是否已加载')
events = $('span.mail-link');
if (events.length === 0) {
events = $('span.mail-link');
return;
}
clearInterval(eventInterval);
eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
eventsTrans();
}, 1000);
function eventsTrans() {
if (events.length === 0) return;
events.each((i, e) => {
if ($(e).text().indexOf('finished') >= 0) { // 赛车
const isBestLap = $(e).text().indexOf('best lap') >= 0;
/**
* 赛车
* You finished 5th in the Hammerhead race. Your best lap was 01:14.87.
* You finished 1st in the Docks race. Your best lap was 04:01.33.
* You finished 1st in the Hammerhead race and have received 3 racing points! Your best lap was 01:06.92.
* You finished 4th in the Docks race. Your best lap was 03:29.27 beating your previous best lap record of 03:35.77 by 00:06.50.
* You have crashed your Honda NSX on the Sewage race! The upgrades Paddle Shift Gearbox (Short Ratio) and Carbon Fiber Roof were lost.
* You have crashed your Ford Mustang on the Docks race! Your car has been recovered.
*/
if ($(e).text().indexOf('finished') >= 0) {
const isGainRacingPoint = $(e).text().indexOf('racing point') >= 0;
if ($(e).text().indexOf('crashed') >= 0) return; // todo 撞车
const pos = e.childNodes[1].firstChild.nodeValue
.split('')[0].match(/[0-9]+/)[0];
const isGainRacingPoint = $(e).text().indexOf('racing point');
let racingPoint = isGainRacingPoint >= 0 ? $(e).text()[isGainRacingPoint - 2] : null;
const isBeat = $(e).text().indexOf('beating') >= 0;
let record, bestBy;
if (isBeat) {
record = $(e).text().split('record of ')[1].split(' by ')[0];
bestBy = $(e).text().split('record of ')[1].split(' by ')[1].split('. ')[0];
}
const pos = e.childNodes[1].firstChild.nodeValue.match(/[0-9]+/)[0];
const splitList = e.childNodes[2].nodeValue.split(' ');
const bestLap = e.childNodes[2].nodeValue.split(' best lap was ')[1].split(' ')[0];
let map = splitList[3];
map = map === 'Two' ? 'Two Islands' : map;
map = map === 'Stone' ? 'Stone Park' : map;
e.firstChild.nodeValue = '你在 ' + map + ' 赛车比赛中获得了第 '//+pos+'名。';
e.childNodes[1].nodeValue = pos;
e.childNodes[2].nodeValue = '名。';
if (isGainRacingPoint) {
const racingPoint = splitList[-9];
e.firstChild.nodeValue = '你在赛车比赛 ' + map + ' 中获得了第 ';
e.childNodes[1].firstChild.nodeValue = pos;
e.childNodes[2].nodeValue = ' 名。';
if (isGainRacingPoint >= 0) {
e.childNodes[2].nodeValue += '你获得了' + racingPoint + '赛车点数。';
}
if (isBestLap) {
const bestLap = splitList[-2];
e.childNodes[2].nodeValue += '你的最好成绩是' + bestLap + '。';
}
e.childNodes[2].nodeValue += '你的最佳成绩是 ' + bestLap;
if (isBeat)
e.childNodes[2].nodeValue += ',比上次成绩 ' + record + ' 快 ' + bestBy;
e.childNodes[2].nodeValue += '。'
e.childNodes[2].nodeValue += ' [';
e.childNodes[3].firstChild.nodeValue = '查看';
return;
}
if ($(e).text().indexOf('Loan Shark') >= 0) { // 还贷
/**
* 还贷
*/
if ($(e).text().indexOf('Loan Shark') >= 0) {
const node1Value = e.firstChild.nodeValue; // You have been charged $29,000 for your loan. You can pay this by visiting the
//e.childNodes[1].firstChild.nodeValue; // <a href="loan.php">Loan Shark</a>
// const node3Value=e.childNodes[2].nodeValue; 内容是 ". "
let charge = node1Value.split(' ')[4];
let replace;
replace = '你需要支付 ';
replace += charge;
replace += ' 贷款利息,点此支付:';
e.firstChild.nodeValue = replace;
e.childNodes[1].firstChild.nodeValue = '鲨客借贷Loan Shark';
e.childNodes[2].nodeValue = '。';
return;
}
if ($(e).text().indexOf('sent') >= 0) { // 收到钱物
if ($(e).text().indexOf('message') >= 0) { // 附带信息
return;
} else {
return;
}
}
if ($(e).text().indexOf('bazaar') >= 0) { // bazaar
/**
* 收到钱物
* You were sent $21,000,000 from
* <a href="profiles.php?XID=2703642">JNZR</a>
* .
* 附带信息 with the message: Manuscript fee OCT
* e.firstChild.nodeValue
* e.childNodes[1].firstChild.nodeValue
* e.childNodes[2].nodeValue
*
* You were sent 4x Xanax from RaichuQ with the message: Manuscript fee OCT
* You were sent $21,000,000 from JNZR.
* You were sent some Xanax from runningowl
* You were sent 1x Present from Duke with the message: Is it your birthday?
* You were sent Duke's Safe from DUKE
* You were sent a Diamond Bladed Knife from charapower
*/
if ($(e).text().indexOf('sent') >= 0) {
const isWithMsg= $(e).text().indexOf('message') >= 0;
const msg=isWithMsg?$(e).text().split(' with the message: ')[1]:null;
const wordsList=e.firstChild.nodeValue.split(' ');
console.log(wordsList);
// 发送的数量
let number;
if(wordsList[3]==='some'||wordsList[3]==='a') // 收到一个可数的不可堆叠或不可数的东西
number='1x';
else if(wordsList[3][wordsList[3].length-1]==='x') // 收到可数的可堆叠东西
number=wordsList[3];
else
number=null;
const item=number===null?wordsList.slice(3,wordsList.length-2):wordsList.slice(4,wordsList.length-2);
console.log(item);
// 你收到了来自someone的【数量】物品附带信息xxx。
e.firstChild.nodeValue='你收到了来自 ';
e.childNodes[2].nodeValue=' 的 ';
if(number)
e.childNodes[2].nodeValue+=number
e.childNodes[2].nodeValue+=' '+item;
if(isWithMsg)
e.childNodes[2].nodeValue+=',附带信息:'+msg;
e.childNodes[2].nodeValue+='。';
return;
}
/**
* bazaar
* Dewei3 bought 2 x Toyota MR2 from your bazaar for $56,590.
* ['', 'bought', '2', 'x', 'Toyota', 'MR2', 'from', 'your', 'bazaar', 'for', '$56,590.\n']
* e.childNodes[1].nodeValue
*/
if ($(e).text().indexOf('bazaar') >= 0) {
const bazEN=e.childNodes[1].nodeValue;
// const itemStart=bazEN.indexOf(' x ')+3;
// const itemEnd=bazEN.indexOf(' from your bazaar for ');
const spl=bazEN.split(' ');
const num=spl[2].replace('.','');
// const item=bazEN.slice(itemStart,itemEnd);
const item=spl.slice(4,spl.indexOf('from')).join(' ');
console.log(item)
const money=spl[spl.length-1];
e.childNodes[1].nodeValue=' 花费 '+money+' 从你的 bazaar 买了 '+num+' 个 '+' '+item+'。';
return;
}
if ($(e).text().indexOf('trade') >= 0) { // 交易
if ($(e).text().indexOf('You must now accept') >= 0) { // 接受交易
return;
@ -239,25 +344,41 @@
return;
}
}
if ($(e).text().indexOf('lottery') >= 0) { // 每日彩票
/**
* 每日彩票
* 有人在Lucky Shot彩票中赢得11,832,100,000美元!
* zstorm won $5,574,200 in the Daily Dime lottery!
*/
if ($(e).text().indexOf('lottery') >= 0) {
console.log('彩票')
const split=e.childNodes[1].nodeValue.split(' ');
const type=split[split.length-3]+' '+split[split.length-2];
const money=split[2];
e.childNodes[1].nodeValue=' 在 '+type+' 彩票中赢得了 '+money+'';
return;
}
if ($(e).text().indexOf('organized crime') >= 0) { // oc开启
return;
}
if ($(e).text().indexOf('You and your team') >= 0) { // oc结束
return;
}
if ($(e).text().indexOf('successfully busted') >= 0) { // 劫狱成功
return;
}
if ($(e).text().indexOf('trying to bust') >= 0 ||
$(e).text().indexOf('failed to bust') >= 0) { // 劫狱失败
return;
}
if ($(e).text().indexOf('Loan Shark') >= 0) { // 还贷
/**
* bust 捞人
* <a href="profiles.php?XID=2208715">Spookyt</a>
* failed to bust you out of jail.
*/
if ($(e).text().indexOf('bust') >= 0) { // 劫狱成功
if ($(e).text().indexOf('to bust') >= 0) { // 劫狱失败
e.childNodes[1].nodeValue=' 想捞你出来但是把自己搭进去了。';
return;
}
e.childNodes[1].nodeValue=' 成功把你捞了出来。';
return;
}
if ($(e).text().indexOf('doorstep') >= 0) { // 蓝星奖励
return;
}
@ -265,7 +386,5 @@
}
}
})();