Skip to content

Instantly share code, notes, and snippets.

@Verssae
Last active June 22, 2023 06:54
Show Gist options
  • Save Verssae/f54fc10a714369eeceeb329cdd2039bd to your computer and use it in GitHub Desktop.
Save Verssae/f54fc10a714369eeceeb329cdd2039bd to your computer and use it in GitHub Desktop.
Get student names and ids from lms student list pages
let names = Array.from(document.getElementsByClassName("roster_user_name student_context_card_trigger")).map(e => e.text.split('(', 1)[0].split('/')[0].trim())
let ids = Array.from(document.getElementsByClassName("rosterUser al-hover-container")).map(e => e.getElementsByTagName('td')[2].textContent.trim())
var arrays = [
names,
ids
]; // 출력할 문자열 배열들
var container = document.createElement("div"); // 새로운 <div> 요소 생성
container.style.position = "fixed";
container.style.top = "50%";
container.style.left = "50%";
container.style.transform = "translate(-50%, -50%)";
container.style.backgroundColor = "#fff";
container.style.color = "#000";
container.style.padding = "10px";
container.style.zIndex = "9999";
for (var i = 0; i < arrays.length; i++) {
var array = arrays[i];
for (var j = 0; j < array.length; j++) {
var line = document.createElement("div"); // 새로운 <div> 요소 생성
line.textContent = array[j]; // 문자열 설정
container.appendChild(line); // <div> 요소를 컨테이너에 추가
}
if (i < arrays.length - 1) {
var lineSeparator = document.createElement("hr"); // 구분선 추가
lineSeparator.style.margin = "10px 0";
container.appendChild(lineSeparator);
}
}
document.body.appendChild(container); // 컨테이너를 <body> 요소에 추가
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment