편집 요약 없음 |
편집 요약 없음 |
||
30번째 줄: | 30번째 줄: | ||
var userinfos = doc.createElement('div'); | var userinfos = doc.createElement('div'); | ||
userinfos.id = "user-infos"; | |||
var userinfo = doc.createElement('span'); | var userinfo = doc.createElement('span'); | ||
var image = doc.createElement('img'); | var image = doc.createElement('img'); | ||
var period = doc.createElement('small'); | |||
var period = doc.createElement('small') | |||
var status = doc.createElement('span'); | var status = doc.createElement('span'); | ||
var lastEdit = doc.createElement(' | var lastEdit = doc.createElement('small'); | ||
var userinfoEditCount = doc.createElement('span'); | var userinfoEditCount = doc.createElement('span'); | ||
doc.querySelector('.title').appendChild(userinfos); | doc.querySelector('.title').appendChild(userinfos); | ||
if (mw.config.get('wgNamespaceNumber') == 2) { | if (mw.config.get('wgNamespaceNumber') == 2) { | ||
49번째 줄: | 47번째 줄: | ||
image.src = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Stop_x_nuvola.svg/40px-Stop_x_nuvola.svg.png"; | image.src = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Stop_x_nuvola.svg/40px-Stop_x_nuvola.svg.png"; | ||
image.width = "40"; | image.width = "40"; | ||
status.innerText = "차단된 사용자" | status.innerText = "차단된 사용자"; | ||
period.innerText = "차단기한 : " + bktstring; | period.innerText = "차단기한 : " + bktstring; | ||
56번째 줄: | 54번째 줄: | ||
image.src = "https://image.librewiki.net/f/f9/Ledibug2.png"; | image.src = "https://image.librewiki.net/f/f9/Ledibug2.png"; | ||
image.width = "40"; | image.width = "40"; | ||
status.innerText = "3개월간 활동하지 않는 사용자" | status.innerText = "3개월간 활동하지 않는 사용자"; | ||
} else { | } else { | ||
66번째 줄: | 64번째 줄: | ||
image.src = "https://image.librewiki.net/4/47/Ledibug-Louis-Fact.png"; | image.src = "https://image.librewiki.net/4/47/Ledibug-Louis-Fact.png"; | ||
image.width = "40"; | image.width = "40"; | ||
status.innerText = "편집중" | status.innerText = "편집중"; | ||
lastEdit.innerText = "마지막 편집 : " + at.getHours() + '시 ' + at.getMinutes() + '분'; | lastEdit.innerText = "마지막 편집 : " + at.getHours() + '시 ' + at.getMinutes() + '분'; | ||
73번째 줄: | 71번째 줄: | ||
image.src = "https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png"; | image.src = "https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png"; | ||
image.width = "40"; | image.width = "40"; | ||
status.innerText = "휴식중" | status.innerText = "휴식중 "; | ||
lastEdit.innerText = "마지막 편집 : " + at.getHours() + '시 ' + at.getMinutes() + '분'; | lastEdit.innerText = "마지막 편집 : " + at.getHours() + '시 ' + at.getMinutes() + '분'; | ||
79번째 줄: | 77번째 줄: | ||
image.src = "https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png"; | image.src = "https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png"; | ||
image.width = "40"; | image.width = "40"; | ||
status.innerText = "휴식중" | status.innerText = "휴식중 "; | ||
lastEdit.innerText = "마지막 편집 : " + (at.getMonth() + 1) + '월 ' + (at.getDate()) + '일'; | lastEdit.innerText = "마지막 편집 : " + (at.getMonth() + 1) + '월 ' + (at.getDate()) + '일'; | ||
} | } | ||
85번째 줄: | 83번째 줄: | ||
userinfoEditCount.className = 'user-info-edit-counter'; | userinfoEditCount.className = 'user-info-edit-counter'; | ||
userinfoEditCount.style.cssText = 'display: inline-block'; | userinfoEditCount.style.cssText = 'display: inline-block'; | ||
userinfoEditCount.innerHTML = '' + editcount + '회'; | userinfoEditCount.innerHTML = ' ' + editcount + '회'; | ||
userinfos.append(image); // 캐릭터 | userinfos.append(image); // 캐릭터 |
2021년 9월 19일 (일) 18:41 판
// 사용 방법 : 자산의 사용자 자바스크립트 문서에 주석기호 '//'를 빼고 아래 문구를 입력하시면 사용가능합니다.
// mw.loader.load('//librewiki.net/index.php?title=사용자:Cerulean/userinfo.js&action=raw&ctype=text/javascript');
// Userinfo.js by librewiki [[User:cerulean]]
//원저작자 : [[사용자:Utolee90]]
//BY-SA-3.0 unported
var doc = document;
var wiki_username = mw.config.get('wgTitle').split("/")[0];
var params = {
'action': 'query',
list: ['blocks', 'recentchanges', 'users'],
utf8: 1,
bklimit: '1',
rclimit: '1',
bkusers: wiki_username,
rcuser: wiki_username,
ususers: wiki_username,
format: 'json',
usprop: 'editcount',
},
api = new mw.Api(); // api action=query
api.get(params).done(function (data) {
var bk = data.query.blocks; // 차단 목록
var rc = data.query.recentchanges; //최근 바뀜 목록
var editcount = data.query.users[0].editcount; //편집 횟수
var userinfos = doc.createElement('div');
userinfos.id = "user-infos";
var userinfo = doc.createElement('span');
var image = doc.createElement('img');
var period = doc.createElement('small');
var status = doc.createElement('span');
var lastEdit = doc.createElement('small');
var userinfoEditCount = doc.createElement('span');
doc.querySelector('.title').appendChild(userinfos);
if (mw.config.get('wgNamespaceNumber') == 2) {
if (bk.length != 0) { // 차단 목록이 존재할 때...
var bkt = (bk[0].expiry === 'infinity') ? 'infinity' : new Date(bk[0].expiry);
var bktstring = (bkt === 'infinity') ? '무기한' : (bkt.getFullYear() + '년 ' + (bkt.getMonth() + 1) + '월 ' + (bkt.getDate()) + '일');
image.src = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Stop_x_nuvola.svg/40px-Stop_x_nuvola.svg.png";
image.width = "40";
status.innerText = "차단된 사용자";
period.innerText = "차단기한 : " + bktstring;
} else if (rc.length == 0) { // 최근 바뀜 목록이 없을 때
image.src = "https://image.librewiki.net/f/f9/Ledibug2.png";
image.width = "40";
status.innerText = "3개월간 활동하지 않는 사용자";
} else {
var x = rc[0].timestamp; // 마지막 편집 시간 확인
var at = new Date(x); //시간 데이터 추출
var now = new Date().getTime(); //현재시간 getTime
if (now - at.getTime() <= 3600 * 1000) { // 마지막 편집이 최근 1시간 이후.
image.src = "https://image.librewiki.net/4/47/Ledibug-Louis-Fact.png";
image.width = "40";
status.innerText = "편집중";
lastEdit.innerText = "마지막 편집 : " + at.getHours() + '시 ' + at.getMinutes() + '분';
} else if (now - at.getTime() <= 24 * 3600 * 1000) { // 마지막 편집이 최근 24시간 이전
image.src = "https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png";
image.width = "40";
status.innerText = "휴식중 ";
lastEdit.innerText = "마지막 편집 : " + at.getHours() + '시 ' + at.getMinutes() + '분';
} else {
image.src = "https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png";
image.width = "40";
status.innerText = "휴식중 ";
lastEdit.innerText = "마지막 편집 : " + (at.getMonth() + 1) + '월 ' + (at.getDate()) + '일';
}
}
userinfoEditCount.className = 'user-info-edit-counter';
userinfoEditCount.style.cssText = 'display: inline-block';
userinfoEditCount.innerHTML = ' ' + editcount + '회';
userinfos.append(image); // 캐릭터
userinfo.append(status); //상태
userinfo.append(period); //차단기한
userinfo.append(lastEdit); //마지막 편집
userinfo.append(userinfoEditCount); //편집 횟수
userinfos.append(userinfo); //유저 정보 문자열
}
});