注意: 保存後、変更を確認するにはブラウザーのキャッシュを消去する必要がある場合があります。
- Firefox / Safari: Shift を押しながら 再読み込み をクリックするか、Ctrl-F5 または Ctrl-R を押してください (Mac では ⌘-R)
- Google Chrome: Ctrl-Shift-R を押してください (Mac では ⌘-Shift-R)
- Internet Explorer / Microsoft Edge: Ctrl を押しながら 最新の情報に更新 をクリックするか、Ctrl-F5 を押してください
- Opera: Ctrl-F5を押してください
/* All JavaScript here will be loaded for users of the Citizen skin */ mw.hook('wikipage.content').add(function ($content) { const relatedBox = $('<div id="related-articles-box"><em>関連記事を読み込み中…</em></div>'); $('#mw-content-text').append(relatedBox); new mw.Api().get({ action: 'query', prop: 'relatedarticles', titles: mw.config.get('wgPageName'), format: 'json' }).then(function (data) { const pages = data?.query?.pages; if (!pages) return; const pageId = Object.keys(pages)[0]; const articles = pages[pageId].relatedarticles; if (!articles || articles.length === 0) { relatedBox.text('関連記事は見つかりませんでした。'); return; } let html = '<ul>'; for (const a of articles) { html += `<li><a href="/wiki/${encodeURIComponent(a.title)}">${a.title}</a></li>`; } html += '</ul>'; relatedBox.html(html); }); });