User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
Tag: Undo |
No edit summary |
||
| Line 166: | Line 166: | ||
if (categories.includes('VfD archive entries')) return; |
if (categories.includes('VfD archive entries')) return; |
||
// |
// Look for all h2 headings (works on both main page and subpages) |
||
$('#mw-content-text').find('h2').each(function () { |
$('#mw-content-text').find('h2').each(function () { |
||
const |
const heading = $(this); |
||
const link = heading.find('a').first(); |
|||
// Only add buttons if the heading contains a link |
|||
if (!link.length) return; |
|||
// On main page, detect the linked subpage if heading contains a link |
|||
if (currentPage === pagePrefix) { |
|||
const link = $(this).find('a').first().attr('title'); |
|||
if (link && link.startsWith(pagePrefix + '/')) { |
|||
targetPage = link.replace(pagePrefix + '/', ''); |
|||
} |
|||
} |
|||
const targetPage = link.attr('title'); // Use the linked page as target |
|||
createButtonsForHeading(this, targetPage); |
createButtonsForHeading(this, targetPage); |
||
}); |
}); |
||