본문으로 이동

사용자:Ort43v/common.js

위키백과, 우리 모두의 백과사전.

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다. 구글 크롬, 파이어폭스, 마이크로소프트 엣지, 사파리: ⇧ Shift 키를 누른 채 "새로 고침" 버튼을 클릭하십시오. 더 자세한 정보를 보려면 위키백과:캐시 무시하기 항목을 참고하십시오.

/* userTricks - a user script library
 * 2012 [[User:Ort43v]]
 */
var userTricks = {
t: null,
testTitle: "",
minHour: 6,
maxHour: 22,

blackout: function(){
document.body.style.backgroundImage = 'none';
document.body.style.backgroundColor = 'black';
},

clear: function(){
document.body.style.display = 'none';
rand = Math.floor(Math.random() * 3);
if (rand > 1) {
  userTricks.timer();
}
},

timer: function(){
userTricks.t = setTimeout('userTricks.quiz()',60000);
},

show: function(){
document.body.style.display = 'block';
},

id: function(id){
return document.getElementById(id);
},

quiz: function(){
rand1 = Math.floor(Math.random() * 1000000000);
rand2 = Math.floor(Math.random() * 1000000000);
sum = rand1 + rand2;
ans = prompt(rand1 + '+' + rand2 + ':');
if (isNaN(ans)) {
  ans = '1';
}
ans = eval(ans);
if (sum == ans) {
  userTricks.show();
}
},

main: function(){
d = new Date();
h = d.getHours();

if (h < userTricks.minHour) {
  userTricks.clear();
}


// for testing
if ( mw.config.get( 'wgPageName' ) == userTricks.testTitle ) {
  userTricks.clear();
  
}
}

};

userTricks.main();