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.

目前為 2025-04-14 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
		}
	}
})();