위키백과:위키홀릭 치료/알리미

아래 스킨에서 현재 자신이 사용중인 스킨에 맞는 자바스크립트를 클릭 및 생성하여 소스코드 문단의 내용을 추가하시면 알리미가 작동합니다. 위키백과 이용 중 1시간이 지나면 위키백과:위키백과 중독증 치료 페이지로 이동됩니다.

  • 익스플로러 8에서 정상 작동하는 것이 확인되었습니다. (최초 설정시 캐시로 인해 정상 작동하지 않을 수 있습니다.)

스킨 편집

소스코드 편집

// 1시간 경과 알리미
function annoyMe() {
  var time = +(new Date());
  var remainder = time % annoy.freq;
  if ( remainder < annoy.duration ) return rileMeUp( annoy.duration - remainder );
  annoy_runOnce( function() { rileMeUp( annoy.duration ); }, annoy.freq - remainder );
}

function rileMeUp( length ) {
  for (var i=0; i<document.links.length; ++i) {
	document.links[i].oldhref=document.links[i].href;
	document.links[i].href=annoy.target;
  }
  annoy_runOnce( deRile, length );
}

function deRile() {
  for (var i=0; i<document.links.length; ++i) {
	document.links[i].href=document.links[i].oldhref;
  }
  annoy_runOnce( function() { rileMeUp( annoy.duration ) }, annoy.freq - annoy.duration );
}

window.annoy={ 
  freq: 1000*60*60, //60분이 지나면 이동
  duration: 1000*60*1, //1분마다 시간 지났는지 확인
  target: 'https://ko.wikipedia.org/wiki/%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC:%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC_%EC%A4%91%EB%8F%85%EC%A6%9D_%EC%B9%98%EB%A3%8C'  //"위키백과:위키홀릭 치료" 페이지로 이동
}
addOnloadHook( annoyMe );

window.annoy_runOnce=function(f, time) {
  var i=annoy_runOnce.timers.length;
  var ff = function () { clearInterval(annoy_runOnce.timers[i]); f() };
  var timer=setInterval(ff, time);
  annoy_runOnce.timers.push(timer);
}
annoy_runOnce.timers=[];