Update whapedia-image-redirect.user.js

This commit is contained in:
2025-07-16 09:59:29 +02:00
committed by GitHub
parent 96b45cf2b2
commit fc9b7aae98

View File

@@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Wahapedia Enhanced Search // @name Wahapedia Enhanced Search
// @namespace http://tampermonkey.net/ // @namespace http://tampermonkey.net/
// @version 2025-02-14 // @version 2025-07-16
// @description Enhances Wahapedia with Kagi image search and Warhammer.com search // @description Enhances Wahapedia with Kagi image search and Warhammer.com search
// @author luxick // @author luxick
// @updateURL https://github.com/luxick/scripts/raw/master/whapedia-image-redirect.user.js // @updateURL https://github.com/luxick/scripts/raw/master/whapedia-image-redirect.user.js
@@ -44,28 +44,28 @@
return warhammerButton; return warhammerButton;
} }
// Function to add Warhammer.com search buttons
function addWarhammerSearchButtons() { function addWarhammerSearchButtons() {
// Get the model name from the dsH2Header div // Get all model name containers
const headerContainer = document.querySelector('.dsH2Header'); const headerContainers = document.querySelectorAll('.dsH2Header');
if (!headerContainer) return; if (!headerContainers.length) return;
const modelName = headerContainer.firstElementChild.textContent.trim(); headerContainers.forEach(headerContainer => {
if (!modelName) return; const modelName = headerContainer.firstElementChild.textContent.trim();
if (!modelName) return;
// Add button to narrow container const narrowContainer = headerContainer.querySelector('.dsIconsNarrow');
const narrowContainer = document.querySelector('.dsIconsNarrow'); if (narrowContainer) {
if (narrowContainer) { narrowContainer.appendChild(createButton(modelName));
narrowContainer.appendChild(createButton(modelName)); }
}
// Add button to wide container const wideContainer = headerContainer.querySelector('.dsIconsWide');
const wideContainer = document.querySelector('.dsIconsWide'); if (wideContainer) {
if (wideContainer) { wideContainer.appendChild(createButton(modelName));
wideContainer.appendChild(createButton(modelName)); }
} });
} }
// Initial run of both functions // Initial run of both functions
replaceImageSearchUrls(); replaceImageSearchUrls();
addWarhammerSearchButtons(); addWarhammerSearchButtons();