メニューを切り替える
個人設定メニューを切り替える
個人メニューを切り替える
ログインしていません
編集を行うと、IPアドレスが公開されます。

「MediaWiki:Common.js」の版間の差分

MediaWikiインターフェイスページ
a
t
93行目: 93行目:


/* スマホめにゅー */
/* スマホめにゅー */
/* Main function */
(function() {
var timer = setInterval(function() {
    var checkCount = 0;
    if ($('.menu ul:first').length) {
    var timer = setInterval(function() {
        console.log("mobile menu exists");
        checkCount++;
        clearInterval(timer);
        var $targetUl = $('.menu ul:first, .navigation-drawer ul:first');


         $('.menu ul:first').after(
         if ($targetUl.length) {
             '<ul class="level1"> \
            clearInterval(timer);
                <li> \
              
                    <a href="#" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-mf-expand mw-ui-icon-small"> \
            if ($('#p-custom-accordion').length) return;
                        <span>Wikiリンク</span> \
                    </a> \
                </li> \
                <ul class="level2"> \
                    <li> \
                        <a href="/wiki/Wiki:方針" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-notice"> \
                            <span>方針</span> \
                        </a> \
                    </li> \
                    <li> \
                        <a href="/wiki/特別:特別ページ一覧" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-star"> \
                            <span>特別ページ一覧</span> \
                        </a> \
                    </li> \
                    <li> \
                        <a href="/wiki/特別:ページ一覧" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-listBullet"> \
                            <span>全てのページ</span> \
                        </a> \
                    </li> \
                    <li> \
                        <a href="/wiki/特別:最近の更新" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-recentChanges"> \
                            <span>最近の更新</span> \
                        </a> \
                    </li> \
                </ul> \
            </ul>'
        );


        $(".level2").hide();
            $targetUl.after(
                '<ul class="level1" id="p-custom-accordion" style="list-style:none; margin:0; padding:0;">' +
                    '<li style="padding: 10px;">' +
                        '<a href="#" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-mf-expand mw-ui-icon-small" style="font-weight:bold;">' +
                            '<span>カスタムメニュー</span>' +
                        '</a>' +
                    '</li>' +
                    '<ul class="level2" style="list-style:none; margin:0; padding-left: 20px;">' +
                        '<li><a href="/wiki/Wiki:方針" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-notice"><span>方針</span></a></li>' +
                        '<li><a href="/wiki/特別:特別ページ一覧" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-star"><span>特別ページ一覧</span></a></li>' +
                        '<li><a href="/wiki/特別:ページ一覧" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-listBullet"><span>全てのページ</span></a></li>' +
                        '<li><a href="/wiki/特別:最近の更新" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-recentChanges"><span>最近の更新</span></a></li>' +
                    '</ul>' +
                '</ul>'
            );


        $(".level1").on('click', function(event) {
            $(".level2").hide();
            event.preventDefault();
            $(".level1 > li").on('click', function(e) {
            $(this).find(".level2").slideToggle(500);
                e.preventDefault();
         });
                $(".level2").slideToggle(300);
     }
            });
}, 100);
         }
 
       
        if (checkCount > 50) clearInterval(timer);
     }, 100);
})();


console.log("OK Common.js")
console.log("OK Common.js")

2026年1月25日 (日) 02:21時点における版

/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */

/* PCスキンでサブタイトルを消す処理 */
const targetNode = document.getElementById('contentSub');
const config = { childList: true, subtree: true };

const callback = function(mutationsList, observer) {
  for (const mutation of mutationsList) {
    if (mutation.type === 'childList') {
      const subtitleElement = document.getElementById('mw-content-subtitle');
      if (subtitleElement) {
        const childNodes = subtitleElement.childNodes;
        const lastChildNode = childNodes[childNodes.length - 1];
        if (lastChildNode && lastChildNode.nodeType === Node.TEXT_NODE) {
          lastChildNode.remove();
          observer.disconnect();
          return;
        }
      }
    }
  }
};

const observer = new MutationObserver(callback);
if (targetNode) {
  observer.observe(targetNode, config);
}

/* PCスキンでサブタイトルを消す処理 ここまで */

/* beta2 */
    const pageTitle = mw.config.get('wgPageName')
    const pageNo = mw.config.get('wgRevisionId')
    const url = `https://wiki.tmyt105.com/w/api.php?action=query&format=json&prop=revisions&formatversion=2&revids=${pageNo}&rvprop=user`;
    const updaterElement = document.getElementById('last-updater-name');

    fetch(url)
        .then(response => {
            if (!response.ok) {
                throw new Error(`HTTP${response.status}`);
            }
            return response.json();
        })
        .then(data => {
            if (!updaterElement) return;
            const pages = data.query.pages;
            const pageId = Object.keys(pages)[0];
            const pageData = pages[pageId];

            if (pageData.missing) {
                updaterElement.textContent = 'null';
                return;
            }

            const revisions = pageData.revisions;
            if (revisions && revisions.length > 0) {
                const lastUpdater = revisions[0].user;
                updaterElement.textContent = lastUpdater.charAt(0).toLowerCase() + lastUpdater.slice(1);
            } else {
                updaterElement.textContent = 'null';
            }
        })
        .catch(error => {
            console.error('エラー:', error);
            if (updaterElement) {
                updaterElement.textContent = '[取得エラー]';
            }
        });

/* beta2 ここまで */

/* お知らせよう */
$(function() {
    var $notice = $('#wiki-origin-notice');
    if (!$notice.length) return;

    var contentId = $notice.data('content-id');
    var cookieName = 'originnotice-' + contentId;

    // Cookieがあるか確認
    if (document.cookie.indexOf(cookieName + '=true') > -1) {
        $notice.hide();
    }

    $('#close-notice-btn').on('click', function() {
        $notice.fadeOut();
        var date = new Date();
        date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toUTCString();
        document.cookie = cookieName + "=true" + expires + "; path=/";
    });
});

/* スマホめにゅー */
(function() {
    var checkCount = 0;
    var timer = setInterval(function() {
        checkCount++;
        var $targetUl = $('.menu ul:first, .navigation-drawer ul:first');

        if ($targetUl.length) {
            clearInterval(timer);
            
            if ($('#p-custom-accordion').length) return;

            $targetUl.after(
                '<ul class="level1" id="p-custom-accordion" style="list-style:none; margin:0; padding:0;">' +
                    '<li style="padding: 10px;">' +
                        '<a href="#" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-mf-expand mw-ui-icon-small" style="font-weight:bold;">' +
                            '<span>カスタムメニュー</span>' +
                        '</a>' +
                    '</li>' +
                    '<ul class="level2" style="list-style:none; margin:0; padding-left: 20px;">' +
                        '<li><a href="/wiki/Wiki:方針" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-notice"><span>方針</span></a></li>' +
                        '<li><a href="/wiki/特別:特別ページ一覧" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-star"><span>特別ページ一覧</span></a></li>' +
                        '<li><a href="/wiki/特別:ページ一覧" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-listBullet"><span>全てのページ</span></a></li>' +
                        '<li><a href="/wiki/特別:最近の更新" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-recentChanges"><span>最近の更新</span></a></li>' +
                    '</ul>' +
                '</ul>'
            );

            $(".level2").hide();
            $(".level1 > li").on('click', function(e) {
                e.preventDefault();
                $(".level2").slideToggle(300);
            });
        }

        
        if (checkCount > 50) clearInterval(timer);
    }, 100);
})();

console.log("OK Common.js")