본문으로 이동
  • 이 서버는 리버티게임의 개발용 베타 서버로, 게임 플레이 용도로 제작된 사이트가 아닙니다.
  • 리버티게임의 자동 인증된 사용자라면 개발에 필요한 관리자 권한을 신청할 수 있습니다.
  • 틀 및 기능별 소도구를 필요한 문서에만 선택적으로 로딩하는 테스트를 진행하고 있습니다. 작동하지 않는 문서가 있다면 담당자에게 알려주세요.

사용자:Senouis/프론트엔드 스크립트: 두 판 사이의 차이

리버티게임(개발), 모두가 만들어가는 자유로운 게임
Senouis (토론 | 기여)
편집 요약 없음
Senouis (토론 | 기여)
편집 요약 없음
46번째 줄: 46번째 줄:
}
}
}
}
ratingslist.push(elem);
});
});
}
}
});
});
}
}

2024년 8월 15일 (목) 17:26 판

let targetlist = [];

let ratingslist = [];

function crawlingSectionRatings() {
	let api = new mw.Api();
	api.get({
		action: "query",
		list: "categorymembers",
		cmtitle: "분류:리버티게임",
		cmtype: "page",
		cmnamespace: 0,
		cmlimit: 500
	}).then((result) => {
		for (const value of result.query.categorymembers){
			fetch('https://dev.libertygame.work/index.php?action=raw&title=' + value.title).then((result)=>{
				console.log(result);
				return result.text();
			}).then((result)=>{
				result = result.split("\n");
				let elem = {"1":0, "2":0, "3":0, "4":0, "5":0};
				let point = 6;
				if (!result.includes("== 이 게임 평가하기 ==") && !result.includes("== 평가 ==")){
					console.log("토론 문서에 평가가 없는 게임이 존재합니다.");
					return;
				}
				for (let i = 0 ; i < result.length; i++){
					console.log(result[i]);
					if (result[i] === "=== 죽여준다 (Awesome!) ==="){
						point=5;
					} else if (result[i] === "=== 기대이상 (Cool~) ==="){
						point=4;
					} else if (result[i] === "=== 보통 (Normal) ==="){
						point=3;
					} else if (result[i] === "=== 후지다 (Bad) ==="){
						point=2;
					} else if (result[i] === "=== 국회의원 같다 (Disgusting) ==="){
						point=1;
					} else if (result[i][1] === "=" && result[i][2] !== "=" && point === 1){
						break; // 평가 문단을 벗어남
					} else if (point <= 5) {
						splitedline = result[i].split("#");
						if (splitedline.length > 2 && result[i][1] === "#") continue; // 2단계 이상의 문자열로 간주
						else if (splitedline[1] === "" || splitedline[1] === " ") continue; // 빈 평가
						elem[point.toString()] += 1;
					}
				}
				ratingslist.push(elem);
			});
		}
	});
}