Kemono.party Image Full Size Autoloader

Auto load full size image in kemono.party

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name Kemono.party Image Full Size Autoloader
// @name:zh-TW Kemono.party自動載入完整圖片
// @description Auto load full size image in kemono.party
// @description:zh-tw 在kemono.su的Post自動載入完整大小的圖片
// @match https://kemono.su/*/user/*/post/*
// @match https://kemono.su/*/user/*/post/*
// @version 2.0.0
// @namespace andyching168.scripts
// @author andyching168
// @license MIT License
// @run-at document-idle
// @grant none
// ==/UserScript==

let loadingCount = 0;
const MAX_CONCURRENT_LOADS = 3;

function loadImage(thumbImg, progressText) {
if (loadingCount >= MAX_CONCURRENT_LOADS) {
setTimeout(() => loadImage(thumbImg, progressText), 1000);
return;
}

loadingCount++;

const fullSizeImg = new Image();
fullSizeImg.style.display = "none";
thumbImg.parentNode.insertBefore(fullSizeImg, thumbImg.nextSibling);

const xhr = new XMLHttpRequest();
xhr.open('GET', thumbImg.parentNode.href, true);
xhr.responseType = 'arraybuffer';

xhr.onprogress = function(event) {
if (event.lengthComputable) {
const percentComplete = (event.loaded / event.total) * 100;
console.log(`Image loading: ${percentComplete}% complete`);
progressText.textContent = `Loading: ${percentComplete.toFixed(2)}% complete`;
}
};

xhr.onload = function() {
if (this.status === 200) {
const blob = new Blob([this.response], { type: 'image/jpeg' });
fullSizeImg.src = URL.createObjectURL(blob);
}
loadingCount--;
};

xhr.send();

fullSizeImg.onload = function() {
console.log("Image loaded");
this.loaded = true;
};

fullSizeImg.onerror = function() {
thumbImg.style.opacity = "1";
this.remove();
loadingCount--;
};

thumbImg.style.opacity = "1";

function checkImageLoaded() {
if (fullSizeImg.loaded) {
thumbImg.src = fullSizeImg.src;
thumbImg.style.transition = "opacity 1s";
thumbImg.style.opacity = "1";
fullSizeImg.remove();
progressText.remove();
} else {
setTimeout(checkImageLoaded, 500);
}
}

checkImageLoaded();
}

function createLoadButton(img) {
const container = document.createElement("div");
container.style.textAlign = "center";

const progressText = document.createElement("p");
progressText.textContent = "載入中...";
progressText.style.display = "block";
progressText.style.margin = "5px auto";

container.appendChild(progressText);

loadImage(img, progressText);

return container;
}

function addLoadButtons() {
const images = document.querySelectorAll("#page > div > div.post__files > div > figure > a > img");
images.forEach((img) => {
img.parentNode.parentNode.insertBefore(createLoadButton(img), img.parentNode);
});
}

addLoadButtons();