미디어위키:Common.js: 두 판 사이의 차이

아카디아(AKADIA)
(인라인 color !important 추가 - 방문 링크 보라색 확실히 무효화)
(favicon 교체 - 포럼과 동일 아카디아 로고 사용)
1번째 줄: 1번째 줄:
/* 아카디아 위키 - 사용자 정의 JS */
/* 아카디아 위키 - 사용자 정의 JS */
/* favicon 교체 (포럼과 동일 아이콘 사용) */
(function() {
    var FAVICON_URL = 'https://forum.akadia.kr/uploads/default/original/1X/6ad9d0b6ce6bad381a590198ba04c777261e38bf.png';
    function applyFavicon() {
        var links = document.querySelectorAll('link[rel~="icon"], link[rel~="shortcut"]');
        for (var i = 0; i < links.length; i++) { links[i].parentNode.removeChild(links[i]); }
        var link = document.createElement('link');
        link.rel = 'icon';
        link.type = 'image/png';
        link.href = FAVICON_URL;
        document.head.appendChild(link);
        var apple = document.createElement('link');
        apple.rel = 'apple-touch-icon';
        apple.href = FAVICON_URL;
        document.head.appendChild(apple);
    }
    if (document.readyState !== 'loading') { applyFavicon(); }
    else { document.addEventListener('DOMContentLoaded', applyFavicon); }
})();


/* 로고 워드마크 텍스트 변경 */
/* 로고 워드마크 텍스트 변경 */
9번째 줄: 29번째 줄:
         }
         }
     }
     }
     if (document.readyState !== 'loading') {
     if (document.readyState !== 'loading') { applyLogo(); }
        applyLogo();
     else { document.addEventListener('DOMContentLoaded', applyLogo); }
     } else {
        document.addEventListener('DOMContentLoaded', applyLogo);
    }
     if (window.jQuery) { jQuery(applyLogo); }
     if (window.jQuery) { jQuery(applyLogo); }
})();
})();
22번째 줄: 39번째 줄:
     var $portal = $('<div class="akadia-portal-links"></div>');
     var $portal = $('<div class="akadia-portal-links"></div>');
     var $link = $('<a href="https://forum.akadia.kr/" class="akadia-portal-link" title="아카디아 포럼">아카디아 포럼</a>');
     var $link = $('<a href="https://forum.akadia.kr/" class="akadia-portal-link" title="아카디아 포럼">아카디아 포럼</a>');
    /* :visited 보라색을 인라인 스타일로 강제 무효화 (CSS 캐시 회피) */
     $link[0].style.setProperty('color', '#ffffff', 'important');
     $link[0].style.setProperty('color', '#ffffff', 'important');
     $portal.append($link);
     $portal.append($link);
     var $end = $('.vector-header-end').first();
     var $end = $('.vector-header-end').first();
     if ($end.length) {
     if ($end.length) { $end.prepend($portal); }
        $end.prepend($portal);
     else { var $userLinks = $('.vector-user-links').first(); if ($userLinks.length) { $userLinks.before($portal); } else { $('#p-personal').before($portal); } }
     } else {
        var $userLinks = $('.vector-user-links').first();
        if ($userLinks.length) { $userLinks.before($portal); }
        else { $('#p-personal').before($portal); }
    }
});
});


41번째 줄: 52번째 줄:
         var meta = document.querySelector('meta[name="viewport"]');
         var meta = document.querySelector('meta[name="viewport"]');
         var content = 'width=device-width, initial-scale=1, shrink-to-fit=no';
         var content = 'width=device-width, initial-scale=1, shrink-to-fit=no';
         if (meta) {
         if (meta) { meta.setAttribute('content', content); }
            meta.setAttribute('content', content);
         else { meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', content); document.head.appendChild(meta); }
         } else {
            meta = document.createElement('meta');
            meta.setAttribute('name', 'viewport');
            meta.setAttribute('content', content);
            document.head.appendChild(meta);
        }
     }
     }
})();
})();
56번째 줄: 61번째 줄:
     $content.find('a.external').not('[href^="#"]').not('.mw-editsection a').each(function() {
     $content.find('a.external').not('[href^="#"]').not('.mw-editsection a').each(function() {
         var $a = $(this);
         var $a = $(this);
         if (!$a.attr('target')) {
         if (!$a.attr('target')) { $a.attr('target', '_blank').attr('rel', 'noopener noreferrer'); }
            $a.attr('target', '_blank').attr('rel', 'noopener noreferrer');
        }
     });
     });
});
});

2026년 5월 12일 (화) 09:44 판

/* 아카디아 위키 - 사용자 정의 JS */

/* favicon 교체 (포럼과 동일 아이콘 사용) */
(function() {
    var FAVICON_URL = 'https://forum.akadia.kr/uploads/default/original/1X/6ad9d0b6ce6bad381a590198ba04c777261e38bf.png';
    function applyFavicon() {
        var links = document.querySelectorAll('link[rel~="icon"], link[rel~="shortcut"]');
        for (var i = 0; i < links.length; i++) { links[i].parentNode.removeChild(links[i]); }
        var link = document.createElement('link');
        link.rel = 'icon';
        link.type = 'image/png';
        link.href = FAVICON_URL;
        document.head.appendChild(link);
        var apple = document.createElement('link');
        apple.rel = 'apple-touch-icon';
        apple.href = FAVICON_URL;
        document.head.appendChild(apple);
    }
    if (document.readyState !== 'loading') { applyFavicon(); }
    else { document.addEventListener('DOMContentLoaded', applyFavicon); }
})();

/* 로고 워드마크 텍스트 변경 */
(function() {
    function applyLogo() {
        var wm = document.querySelector('.mw-logo-wordmark');
        if (wm && wm.textContent.indexOf('위키') === -1) {
            wm.textContent = '아카디아 위키';
        }
    }
    if (document.readyState !== 'loading') { applyLogo(); }
    else { document.addEventListener('DOMContentLoaded', applyLogo); }
    if (window.jQuery) { jQuery(applyLogo); }
})();

/* 아카디아 포럼 - 헤더 알약 탭 삽입 */
$(function() {
    if ($('.akadia-portal-links').length) return;
    var $portal = $('<div class="akadia-portal-links"></div>');
    var $link = $('<a href="https://forum.akadia.kr/" class="akadia-portal-link" title="아카디아 포럼">아카디아 포럼</a>');
    $link[0].style.setProperty('color', '#ffffff', 'important');
    $portal.append($link);
    var $end = $('.vector-header-end').first();
    if ($end.length) { $end.prepend($portal); }
    else { var $userLinks = $('.vector-user-links').first(); if ($userLinks.length) { $userLinks.before($portal); } else { $('#p-personal').before($portal); } }
});

/* 모바일 viewport 대응 */
(function() {
    var screenW = window.screen && window.screen.width;
    if (screenW && screenW <= 720) {
        var meta = document.querySelector('meta[name="viewport"]');
        var content = 'width=device-width, initial-scale=1, shrink-to-fit=no';
        if (meta) { meta.setAttribute('content', content); }
        else { meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', content); document.head.appendChild(meta); }
    }
})();

/* 외부 링크 새 탭 열기 */
mw.hook('wikipage.content').add(function($content) {
    $content.find('a.external').not('[href^="#"]').not('.mw-editsection a').each(function() {
        var $a = $(this);
        if (!$a.attr('target')) { $a.attr('target', '_blank').attr('rel', 'noopener noreferrer'); }
    });
});