미디어위키:Common.js

Admin (토론 | 기여)님의 2026년 5월 12일 (화) 08:45 판 (포럼 버튼: vector-header-end 첫 자식으로 흐름 배치 (절대 위치 제거))

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
  • 오페라: Ctrl-F5를 입력.
/* 아카디아 위키 - 사용자 정의 JS */

/* 로고 워드마크 텍스트 변경 */
(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>');
    $portal.append('<a href="https://forum.akadia.kr/" class="akadia-portal-link" title="아카디아 포럼">아카디아 포럼</a>');
    /* .vector-header-end 첫 자식으로 삽입 -> [포럼][검색][사용자] 순으로 flex 배치 */
    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');
        }
    });
});