사용자:하늘/userinfo.js: 두 판 사이의 차이

(수정하다보니 GPL 라이선스 부분이 지워짐)
잔글 (Chirho님이 사용자:Cerulean/userinfo.js 문서를 넘겨주기를 만들지 않고 사용자:하늘/userinfo.js 문서로 이동했습니다: "Cerulean" 사용자의 이름을 "하늘"(으)로 바꿀 때 문서를 자동으로 이동했습니다)
 
(다른 사용자 한 명의 중간 판 26개는 보이지 않습니다)
1번째 줄: 1번째 줄:
// 사용 방법 : 자산의 사용자 자바스크립트 문서에 주석기호 '//'를 빼고 아래 문구를 입력하시면 사용가능합니다.
// 사용 방법 : 자산의 사용자 자바스크립트 문서에 주석기호 '//'를 빼고 아래 문구를 입력하시면 사용가능합니다.
// mw.loader.load('//librewiki.net/index.php?title=사용자:Cerulean/userinfo.js&action=raw&ctype=text/javascript');
// mw.loader.load('/index.php?title=사용자:Cerulean/userinfo.js&action=raw&ctype=text/javascript');


// Userinfo.js by librewiki [[User:cerulean]]
// Userinfo.js by librewiki [[User:cerulean]]


//원저작자 : [[사용자:Utolee90]]
// Original : [[사용자:Utolee90]]


//BY-SA-3.0 unported
//BY-SA-3.0 unported


var doc = document;
$(document).ready(() => {
var wiki_username = mw.config.get('wgTitle').split("/")[0];
var wiki_username = mw.config.get('wgTitle').split("/")[0];
var params = {
var params = {
    action: 'query',
'action': 'query',
    list: ['blocks', 'recentchanges', 'users'],
list: ['blocks', 'recentchanges', 'users'],
    utf8: 1,
utf8: 1,
    bklimit: '1',
bklimit: '1',
    rclimit: '1',
rclimit: '1',
    bkusers: wiki_username,
bkusers: wiki_username,
    rcuser: wiki_username,
rcuser: wiki_username,
    ususers: wiki_username,
ususers: wiki_username,
    format: 'json',
format: 'json',
    usprop: 'editcount',
usprop: 'editcount',
},
},
    api = new mw.Api(); // api action=query
api = new mw.Api(); // api action=query


api.get(params).done(function (data) {
api.get(params).done(function (data) {
    var bk = data.query.blocks; // 차단 목록
var bk = data.query.blocks; // 차단 목록
    var rc = data.query.recentchanges; //최근 바뀜 목록
var rc = data.query.recentchanges; //최근 바뀜 목록
    var editcount = data.query.users[0].editcount; //editcount
var editcount = data.query.users[0].editcount; //편집 횟수
    var div = doc.createElement('div');
 
    div.id = "user-status-infos";
var userinfos = document.createElement('div');
    doc.querySelector('.title').appendChild(div);
userinfos.id = "user-infos";
    if (mw.config.get('wgNamespaceNumber') == 2) {
userinfos.style.cssText = "display: flex; align-items: center;";
        if (bk.length != 0) { // 차단 목록이 존재할 때...
//userinfos.style.opacity = "0";
            var bkt = (bk[0].expiry === 'infinity') ? 'infinity' : new Date(bk[0].expiry);
 
            var bktstring = (bkt === 'infinity') ? '무기한' : (bkt.getFullYear() + '년 ' + (bkt.getMonth() + 1) + '월 ' + (bkt.getDate()) + '일');
var image = document.createElement('img');
            div.innerHTML = '<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Stop_x_nuvola.svg/40px-Stop_x_nuvola.svg.png" width=40 /> <span class="status-text">차단된 사용자&nbsp;&nbsp;</span> <small>차단기한 : ' + bktstring + '</small>';
// image.style.float = "left";
        }
var userinfo = document.createElement('span');
        else if (rc.length == 0) { // 최근 바뀜 목록이 없을 때
userinfo.style.display = "inline-block";
            div.innerHTML = '<img src="https://image.librewiki.net/f/f9/Ledibug2.png" width=40 /> <span class="status-text">3개월간 활동하지 않는 사용자.</span>';
userinfo.style.padding = "0.4em";
        }
 
        else {
var period = document.createElement('small');
            var x = rc[0].timestamp; // 마지막 편집 시간 확인
var status = document.createElement('span');
            var at = new Date(x); //시간 데이터 추출
var lastEdit = document.createElement('small');
            var now = new Date().getTime(); //현재시간 getTime
var userinfoEditCount = document.createElement('span');
            if (now - at.getTime() <= 3600 * 1000) { // 마지막 편집이 최근 1시간 이후.
 
                div.innerHTML = '<img src="https://image.librewiki.net/4/47/Ledibug-Louis-Fact.png" width=40 /> <span class="status-text">편집중&nbsp;&nbsp;</span> <small>마지막 편집 시간 :' + ' ' + at.getHours() + '시 ' + at.getMinutes() + '분</small>';
document.querySelector('h1').after(userinfos);
            }
if (mw.config.get('wgNamespaceNumber') == 2) {
            else if (now - at.getTime() <= 24 * 3600 * 1000) { // 마지막 편집이 최근 24시간 이전  
if (bk.length != 0) { // 차단 내역이 존재할 때...
                div.innerHTML = '<img src="https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png" width=40 /> <span class="status-text">휴식중&nbsp;&nbsp;</span><small>마지막 편집 시간 :' + at.getHours() + '시 ' + at.getMinutes() + '분</small>';
var bkt = (bk[0].expiry === 'infinity') ? 'infinity' : new Date(bk[0].expiry);
            }
var bktstring = (bkt === 'infinity') ? '무기한' : (bkt.getFullYear() + '년 ' + (bkt.getMonth() + 1) + '월 ' + (bkt.getDate()) + '일' + '까지');
            else {
 
                div.innerHTML = '<img src="https://image.librewiki.net/8/8b/Ledibug-Lucy-False.png" width=40 /> <span class="status-text">휴식중&nbsp;&nbsp;</span> <small>마지막 편집 날짜 :&nbsp;' + (at.getMonth() + 1) + '월 ' + (at.getDate()) + '일</small>';
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 = bktstring + " 차단된 사용자";
        var editcount = '' + editcount + '회';
period.innerText = "";
        var span = doc.createElement('span');
 
        span.className = 'user-edit-counter';
} else if (rc.length == 0) { // 최근 바뀜 목록이 없을 때
        span.style.cssText = '';
 
        span.innerHTML = editcount;
image.src = "https://image.librewiki.net/f/f9/Ledibug2.png";
        doc.querySelector('#user-status-infos').appendChild(span);
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: block;';
if (editcount !== undefined) {
userinfoEditCount.innerHTML = '편집 횟수 : ' + '<span style="font-style: italic;">' + editcount + '</span> 회';
userinfo.append(userinfoEditCount); //편집 횟수
}
userinfo.append(status); //상태
userinfo.append(period); //차단기한
userinfo.append(lastEdit); //마지막 편집
 
image.onload = function () {
userinfos.append(image); // 캐릭터
userinfos.append(userinfo); //유저 정보 문자열
userinfos.animate([{ opacity: 0 }, { opacity: 1 }], 300);
};
}
});
})

2022년 5월 11일 (수) 10:30 기준 최신판

// 사용 방법 : 자산의 사용자 자바스크립트 문서에 주석기호 '//'를 빼고 아래 문구를 입력하시면 사용가능합니다.
// mw.loader.load('/index.php?title=사용자:Cerulean/userinfo.js&action=raw&ctype=text/javascript');

// Userinfo.js by librewiki [[User:cerulean]]

// Original : [[사용자:Utolee90]]

//BY-SA-3.0 unported

$(document).ready(() => {
	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 = document.createElement('div');
		userinfos.id = "user-infos";
		userinfos.style.cssText = "display: flex; align-items: center;";
		//userinfos.style.opacity = "0";

		var image = document.createElement('img');
		// image.style.float = "left";
		var userinfo = document.createElement('span');
		userinfo.style.display = "inline-block";
		userinfo.style.padding = "0.4em";

		var period = document.createElement('small');
		var status = document.createElement('span');
		var lastEdit = document.createElement('small');
		var userinfoEditCount = document.createElement('span');

		document.querySelector('h1').after(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 = bktstring + " 차단된 사용자";
				period.innerText = "";

			} 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: block;';
			if (editcount !== undefined) {
				userinfoEditCount.innerHTML = '편집 횟수 : ' + '<span style="font-style: italic;">' + editcount + '</span> 회';
				userinfo.append(userinfoEditCount); //편집 횟수
			}
			userinfo.append(status); //상태
			userinfo.append(period); //차단기한
			userinfo.append(lastEdit); //마지막 편집

			image.onload = function () {
				userinfos.append(image); // 캐릭터
				userinfos.append(userinfo); //유저 정보 문자열
				userinfos.animate([{ opacity: 0 }, { opacity: 1 }], 300);
			};
		}
	});
})