GBT HTML5 native player, full preload, download (GBTPP)

Replaces fluid player with browsers HTML5 native player, initialises native preload and proceeds full preload in background.

14.04.2025 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         GBT HTML5 native player, full preload, download (GBTPP)
// @version      4.6
// @namespace    _pc
// @description  Replaces fluid player with browsers HTML5 native player, initialises native preload and proceeds full preload in background.
// @author       verydelight
// @license      MIT
// @icon         https://www.gayporntube.com/favicon.ico
// @connect      gayboystube.com
// @connect      gayporntube.com
// @compatible   Firefox Tampermonkey
// @grant        GM.xmlHttpRequest
// @grant        GM_download
// @grant        GM_xmlHttpRequest
// @grant        GM.download
// @match        *://*.gayboystube.com/video/*
// @match        *://*.gayporntube.com/video/*
// @webRequest   {"selector":"*fluidplayer*","action":"cancel"}
// ==/UserScript==
(async function() {
	const videoplayer = document.getElementById('play-video');
	const videoplayerSource = videoplayer.querySelector('source');
	const pattern = /\/\?br=\d*$/;
	if (videoplayerSource) {
		const src = videoplayerSource.src.replace(pattern, '');
		if (src !== videoplayerSource.src) {
			videoplayerSource.src = src;
		}
		videoplayer.removeAttribute("height");
		videoplayer.removeAttribute("width");
        videoplayer.setAttribute("preload","auto");
        videoplayer.focus();
		await downloadVideo(videoplayerSource.src);
	}
	async function downloadVideo(url) {
		try {
			const response = await GM.xmlHttpRequest({
				method: 'GET',
				responseType: 'blob',
				url: url,
				headers: {
					"Content-Type": "video/mp4",
					"Accept": "video/mp4"
				},
			});
			const blob = new Blob([response.response], { type: 'video/mp4' });
			const objectUrl = URL.createObjectURL(blob);
			const { currentTime, paused, ended } = videoplayer;
            videoplayerSource.src = objectUrl;
			videoplayer.load();
            videoplayer.currentTime = currentTime;
			if (!paused && !ended && currentTime > 0) {
				videoplayer.play();
			}
            const parts = url.split("/");
            const filename = parts[parts.length - 1];
            const dlinfo = document.createElement('div');
            dlinfo.textContent = "Video ready/fully preloaded - Click download button or use save as or save video as from context menue";
            dlinfo.classList.add("blue");
            dlinfo.style.fontWeight = "bold";
            const container = document.querySelector("#tab_video_info");
            const dlBttn = container.querySelector(".bttn");
            dlBttn.href = objectUrl;
            dlBttn.download = filename;
            videoplayer.parentNode.insertBefore(dlinfo, videoplayer.nextSibling);
		} catch (err) {
			console.error("GBTPP: Error in fetching and downloading file: ", err);
		}
	}
})();