MangaDex Cover Mass-Downloader: Fix für fehlenden Button
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name MangaDex Cover Mass-Downloader
|
// @name MangaDex Cover Mass-Downloader
|
||||||
// @namespace https://git.ponywave.de/Akamaru/Userscripts
|
// @namespace https://git.ponywave.de/Akamaru/Userscripts
|
||||||
// @version 1.2
|
// @version 1.3
|
||||||
// @description Lädt Cover von MangaDex im Bulk als ZIP-Datei herunter
|
// @description Lädt Cover von MangaDex im Bulk als ZIP-Datei herunter
|
||||||
// @author Akamaru
|
// @author Akamaru
|
||||||
// @match https://mangadex.org/title/*
|
// @match https://mangadex.org/title/*
|
||||||
@@ -50,20 +50,47 @@
|
|||||||
childList: true,
|
childList: true,
|
||||||
subtree: true
|
subtree: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Überwache URL-Änderungen für SPA-Navigation
|
||||||
|
// 1. History API überwachen (pushState/replaceState)
|
||||||
|
const originalPushState = history.pushState;
|
||||||
|
const originalReplaceState = history.replaceState;
|
||||||
|
|
||||||
|
history.pushState = function() {
|
||||||
|
originalPushState.apply(this, arguments);
|
||||||
|
// Prüfe ob wir auf einer /title/* Seite sind
|
||||||
|
if (window.location.pathname.startsWith('/title/')) {
|
||||||
|
setTimeout(checkAndAddButton, 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
history.replaceState = function() {
|
||||||
|
originalReplaceState.apply(this, arguments);
|
||||||
|
if (window.location.pathname.startsWith('/title/')) {
|
||||||
|
setTimeout(checkAndAddButton, 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 2. popstate Event für Browser-Navigation (Zurück/Vorwärts)
|
||||||
|
window.addEventListener('popstate', () => {
|
||||||
|
if (window.location.pathname.startsWith('/title/')) {
|
||||||
|
setTimeout(checkAndAddButton, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDownloadButton() {
|
function addDownloadButton() {
|
||||||
// Prüfe ob Button bereits existiert
|
|
||||||
if (document.getElementById('cover-download-btn')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finde den Button-Container
|
// Finde den Button-Container
|
||||||
const buttonContainer = document.querySelector('.flex.gap-2.sm\\:mb-0.mb-2.flex-wrap');
|
const buttonContainer = document.querySelector('.flex.gap-2.sm\\:mb-0.mb-2.flex-wrap');
|
||||||
if (!buttonContainer) {
|
if (!buttonContainer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prüfe ob Button bereits im Container existiert (nicht nur global)
|
||||||
|
if (buttonContainer.querySelector('#cover-download-btn')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Erstelle Download-Button im Stil von "Start Reading"
|
// Erstelle Download-Button im Stil von "Start Reading"
|
||||||
const downloadBtn = document.createElement('button');
|
const downloadBtn = document.createElement('button');
|
||||||
downloadBtn.id = 'cover-download-btn';
|
downloadBtn.id = 'cover-download-btn';
|
||||||
|
|||||||
Reference in New Issue
Block a user