미디어위키:Gadget-watchlistSince.js

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

/*
[[:en:Wikipedia:WikiProject User scripts/Scripts/Watchlist since]]
주시 문서 목록에서 페이지가 로드된 이후의 변경 사항을 표시하는 링크를 삽입.
IRTC1015 2010년 7월 19일 (월) 23:02 (KST)
*/

$(function () {
    if (!mw.config.get('wgCanonicalSpecialPageName') || mw.config.get('wgCanonicalSpecialPageName') != "Watchlist") return;
    if (!document.forms[0] || !document.forms[0].namespace) return;

    var link = document.createElement('a');
    link.id = 'listSince';
    link.href = '#';

    var then = +(new Date());
    var fixLinkHref = function () {
        var url = window.location.href.split('#')[0];
        var days = (( +(new Date()) - then ) + (60 * 1000)) / (1000 * 3600 * 24);
        if (url.match(/[?&]days=/))
            this.href = url.replace(/([?&]days=)[^&]*/, '$1'+days);
        else
            this.href = url + (url.indexOf('?') < 0 ? '?':'&') + 'days=' + days;
        return true;
    };
    link.onclick = fixLinkHref;
    link.onmousedown = fixLinkHref;  // react to middle clicks too

    var frag = document.createDocumentFragment();
    frag.appendChild(document.createTextNode(' | '));
    frag.appendChild(link);
    link.appendChild(document.createTextNode('페이지 로드 이후 바뀐 문서'));

    // just one little ID attribute would be _so_ nice...
    var nsSelectForm = document.getElementsByTagName('form')[0];
    nsSelectForm.parentNode.insertBefore(frag, nsSelectForm);
});