更新edu页面

This commit is contained in:
woohoo 2021-11-09 18:43:55 +08:00
parent a0c240aae0
commit f88e140655

View File

@ -25,6 +25,9 @@
'Classified Ads': '分类广告', 'Classified Ads': '分类广告',
'Properties': '房产', 'Properties': '房产',
'City': '城市', 'City': '城市',
'Education':'教育',
'Gym':'健身房',
'Biology Modules':'生物学课程',
}; };
const titleLinksDict = { const titleLinksDict = {
'Personal stats': '个人统计信息', 'Personal stats': '个人统计信息',
@ -35,6 +38,7 @@
'City': '城市', 'City': '城市',
'Back to Estate Agents': '返回地产中介', 'Back to Estate Agents': '返回地产中介',
'Tutorial': '教程', 'Tutorial': '教程',
'Back to Education':'返回',
}; };
const sidebarDict = { // todo 从json加载 const sidebarDict = { // todo 从json加载
'Money': '现金', 'Money': '现金',
@ -156,6 +160,15 @@
'Intelligence': '智力 INT', 'Intelligence': '智力 INT',
'Endurance': '耐心 END', 'Endurance': '耐心 END',
}; };
const attackDict = {
"mugged": "打劫了 ",
"attached": "攻击了 ",
"arrested": "逮捕了 ",
"hospitalized": "暴力殴打了 ",
"but": "但是",
"Someone": "有人",
"lost": "失败了"
};
const newspaperDict = { const newspaperDict = {
'front page': '头版', 'front page': '头版',
'archive': '归档', 'archive': '归档',
@ -277,6 +290,23 @@
'Are you sure you would like to buy this membership?': '确定购买这个健身房会员吗?', 'Are you sure you would like to buy this membership?': '确定购买这个健身房会员吗?',
'Not Available': '不可用', 'Not Available': '不可用',
}; };
const eduDict={
'Biology':'生物学',
'Biology Modules':'生物学课程',
'Introduction to Biochemistry':'生物化学概论',
'You do not meet the requirements for this course. Please complete the prerequisites first.':
'你不符合本课程的要求。请先学习前置课程。',
'Description:':'描述:',
'Learning outcomes:':'学习后可获得:',
'Prerequisites:':'前置课程:',
'Parameters:':'课程参数:',
'As the ultimate module - you will focus on maximum gym gain with the least amount of input.':'',
'Ability to withdraw and deliver blood':'抽取和输送血液的能力(使用血包)',
'Gain {$1} {$2} upon completion':'获得{$1}点{$2}',
'intelligence':'智力(INT)',
'endurance':'耐心(END)',
'manual labor':'体力(MAN)',
};
/** /**
@ -422,21 +452,11 @@
if (e.firstChild.nodeValue === 'Latest Events') { if (e.firstChild.nodeValue === 'Latest Events') {
homeEvents = $(e).parent().next().find('span'); homeEvents = $(e).parent().next().find('span');
} else if (e.firstChild.nodeValue === 'Latest Attacks') { } else if (e.firstChild.nodeValue === 'Latest Attacks') {
const attackDict = {
"mugged": "打劫了 ",
"attached": "攻击了 ",
"arrested": "逮捕了 ",
"hospitalized": "暴力殴打了 ",
"but": "但是",
"Someone": "有人",
"lost": "失败了"
}
$(e).parent().next().find('span').each(function () { $(e).parent().next().find('span').each(function () {
let nodes = $(this)[0].childNodes; let nodes = $(this)[0].childNodes;
nodes.forEach((v, i) => { nodes.forEach((v, i) => {
if (v.nodeValue !== null) { if (v.nodeValue !== null) {
let waitToTsf = v.nodeValue.toString().indexOf(" "); let waitToTsf = v.nodeValue.toString().indexOf(" ");
let words = v.nodeValue.replace("\n", "").toString().split(" "); let words = v.nodeValue.replace("\n", "").toString().split(" ");
words.forEach((word, j) => { words.forEach((word, j) => {
if (attackDict.hasOwnProperty(word)) { if (attackDict.hasOwnProperty(word)) {
@ -569,22 +589,29 @@
$(e).text(gymDict[$(e).text().trim()]); $(e).text(gymDict[$(e).text().trim()]);
}); });
// 每次锻炼的花销 // 每次锻炼的花销
$('div[class^="description"] p:nth-child(2)').each((i, e) => { // $('div[class^="description"] p:nth-child(2)').each((i,e)=>{
const energyPerTrain = $(e).text().split(' ').length === 4 ? $(e).text().split(' ')[0] : null; // const energyPerTrain=$(e).text().split(' ').length===4?$(e).text().split(' ')[0]:null;
if (gymDict[$(e).text().replace(energyPerTrain, `{$}`)]) // if(gymDict[$(e).text().replace(energyPerTrain,`{$}`)])
$(e).text(gymDict[$(e).text().replace(energyPerTrain, `{$}`)].replace(`{$}`, energyPerTrain)); // $(e).text(gymDict[$(e).text().replace(energyPerTrain,`{$}`)].replace(`{$}`,energyPerTrain));
}); // });
// 锻炼按钮 // 锻炼页面所有按钮
$('button[class^="button"]').each((i,e)=>{ $('button[class^="button"]').each((i,e)=>{
if (gymDict[$(e).text().trim()]) if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]); $(e).text(gymDict[$(e).text().trim()]);
});// cancel按钮 });
// cancel按钮
$('button[class^="cancel"]').each((i,e)=>{ $('button[class^="cancel"]').each((i,e)=>{
if (gymDict[$(e).text().trim()]) if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]); $(e).text(gymDict[$(e).text().trim()]);
}); });
// 锻炼的提示信息 // 锻炼的提示信息
$('div[class^="messageWrapper"] p').each((i,e)=>{ $('div[class^="messageWrapper"] p').each((i,e)=>{
/**
* todo
* <p>You dug deep and completed 15 minutes of incline sprints</p>
* <p role="alert" class="gained___3T_GZ">You gained 1,854.05 speed</p>
*/
//$(e).attr('class').match(/gained/)
if(gymDict[$(e).text()]) if(gymDict[$(e).text()])
$(e).text(gymDict[$(e).text()]); $(e).text(gymDict[$(e).text()]);
}); });
@ -620,6 +647,102 @@
return; return;
} }
/**
* 教育页面
*/
if (window.location.href.indexOf('education.php') >= 0) {
const eduOB = new MutationObserver(eduOBInit);
function eduOBInit() {
eduOB.disconnect();
eduTrans();
eduOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
}
function eduTrans() {
titleTrans();
contentTitleLinksTrans();
// 大科目、学院标题
$('div.content-wrapper div.title').each((i,e)=>{
if(eduDict[$(e).text().trim()])
e.firstChild.nodeValue=eduDict[$(e).text().trim()];
});
// 学院详情标题
$('div.content-wrapper div.title-black').each((i,e)=>{
if(e.childNodes.length===3)
if(eduDict[e.lastChild.nodeValue.trim()])
e.lastChild.nodeValue=' '+eduDict[e.lastChild.nodeValue.trim()];
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 学院详情 小课程标题
$('div.content-wrapper span.module-name').each((i,e)=>{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 课程详情 7 标题
$('div.module-desc p.title').each((i,e)=>{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 学院详情 小课程提示信息
$('div.content-wrapper div.msg-cont div').each((i,e)=>{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
});
// 课程介绍中的所有li元素
$('div.module-desc ul.info li').each((i,e)=>{
if(e.childNodes.length===1) {
const spl = $(e).text().trim().split(' ');
switch (spl[0]) {
case 'Length:': {//Length
const d = spl[1].slice(0, -1);
const h = spl[2].slice(0, -1);
const m = spl[3].slice(0, -1);
$(e).text('时长:' + d + '天' + h + '时' + m + '分');
return;
}
case 'Cost:': {//Cost
$(e).text('费用:' + spl[1]);
return;
}
case 'Tier:': {//Tier
$(e).text('级别:' + spl[1]);
return;
}
case 'Gain': {
if(isNumber(spl[1])) {//Gain 40 intelligence upon completion
const wsGained = spl.slice(2, -2).join(' ');
if(eduDict[$(e).text().trim().replace(spl[1],'{$1}')
.replace(wsGained,'{$2}')])
$(e).text(eduDict[$(e).text().trim().replace(spl[1],'{$1}').replace(wsGained,'{$2}')]
.replace('{$1}',spl[1]).replace('{$2}',eduDict[wsGained]?eduDict[wsGained]:wsGained));
}
else{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
}
return;
}
default:{
if(eduDict[$(e).text().trim()])
$(e).text(eduDict[$(e).text().trim()]);
}
}
}
else{ // 前置课程
if(eduDict[$(e).children().text().trim()])
$(e).children().text(eduDict[$(e).children().text().trim()]);
}
});
}
eduTrans();
eduOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
return;
}
/** /**
* 报纸菜单 * 报纸菜单
*/ */
@ -1103,10 +1226,10 @@
return; return;
} }
return; return;
;
} }
if (spl[0] === 'Someone') { // 被匿名 if ($(e).find('a').text().toLowerCase().indexOf('someone') < 0 && // 避免玩家名带有someone字样
$(e).text().split(' ')[0].toLowerCase()==='someone') { // 被匿名
if (spl.length === 6 && spl[3] === 'hospitalized') { // 匿名hos if (spl.length === 6 && spl[3] === 'hospitalized') { // 匿名hos
e.firstChild.nodeValue = '有人袭击你并安排你住院 ['; e.firstChild.nodeValue = '有人袭击你并安排你住院 [';
e.childNodes[1].firstChild.nodeValue = '查看'; e.childNodes[1].firstChild.nodeValue = '查看';