User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
fix Tag: Reverted |
||
Line 4:
const currentPage = mw.config.get('wgPageName').replace(/_/g, ' ');
// Allow main VfD page AND subpages, block everything else
if (!currentPage.startsWith(pagePrefix + '/') || mw.config.get('wgAction') !== 'view') return;▼
if (!(currentPage === pagePrefix || currentPage.startsWith(pagePrefix + '/'))
const api = new mw.Api();
Line 89 ⟶ 91:
// Create UI buttons for each heading
function createButtonsForHeading(heading,
let targetPage = null;
// If we're on the main VfD page, always close the subpage link
if (currentPage === pagePrefix) {
const link = $(heading).find('a').first().attr('title');
if (link && link.startsWith(pagePrefix + '/')) {
targetPage = link; // close the subpage, not main page
}
} else {
targetPage = defaultTargetPage; // on subpage, close itself
}
if (!targetPage) return;
const container = document.createElement('span');
container.style.marginLeft = '6px';
| |||