GBT gallery downloader (GBTGD)

Downloads all images from gallery in a .zip file.

Από την 29/11/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         GBT gallery downloader (GBTGD)
// @namespace    _pc
// @version      4.5
// @license      MIT
// @description  Downloads all images from gallery in a .zip file.
// @author       verydelight
// @match        *://*.gayboystube.com/galleries/*
// @icon         https://www.gayboystube.com/favicon.ico
// @run-at       document-end
// @grant        GM.xmlHttpRequest
// @grant        GM_download
// @grant        GM_xmlHttpRequest
// @grant        GM.download
// @require      https://update.greasyfork.org/scripts/473358/1237031/JSZip.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/FileSaver.min.js
// ==/UserScript==
'use strict';
window.onload = function(){
	var zip = new JSZip();
	let button = document.createElement("button");
	button.append("Download Gallery");
	button.setAttribute("type","button");
	button.addEventListener ("click", fullSize, false);
	document.getElementById('tab_video_info').append(button);
	async function downloadFile(url, filename,iCurr,iMax) {
		try {
			const response = await GM.xmlHttpRequest({
				method: 'GET',
				responseType: 'blob',
				url: url,
				headers: {
					"Content-Type": "image/jpeg", "Accept": "image/jpeg"
				},
			});
			const blob = new Blob([response.response],{type: 'image/jpeg'});
			zip.file(filename, blob, {binary: true})
		} catch (err) {
			console.error("GBTGD: Error in fetching and downloading file:", err);
		}
		if(iCurr==iMax){
			zip.generateAsync({ type: "blob" }).then(content => saveAs(content, "GBT_gallery"));
		}
	}
	async function fullSize(){
		var images = document.getElementById('album_view_album_view').getElementsByTagName('img');
		var iMax = images.length-1;
		for (var i=0, n=images.length;i<n;i++) {
			var currentSrc = images[i].getAttribute('data-src');
			var pattern1 = /\/thumbs/;
			var pattern2 = /\/main\/\d{1,4}x\d{1,4}/;
			if (currentSrc.match(pattern1)) {
				currentSrc = currentSrc.replace(pattern1, '');
			};
			if (currentSrc.match(pattern2)) {
				currentSrc = currentSrc.replace(pattern2, '/sources');
			};
			var fileName = currentSrc.split('/');
			fileName = fileName[fileName.length-1];
			downloadFile(currentSrc,fileName,i,iMax);
		};
	}
};