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.

Stan na 15-04-2025. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         GBT HTML5 native player, full preload, download (GBTPP)
// @version      4.61
// @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");
            const href = dlBttn.getAttribute('href');
            const urlObj = new URL(href);
            const filename = urlObj.searchParams.get('download_filename');
            dlBttn.href = objectUrl;
            dlBttn.download = filename;
            videoplayer.parentNode.insertBefore(dlinfo, videoplayer.nextSibling);
		} catch (err) {
			console.error("GBTPP: Error in fetching and downloading file: ", err);
		}
	}
})();