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