PH_Downloader

pornhub.com

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         PH_Downloader
// @namespace    ph
// @version      0.0.4
// @description  pornhub.com
// @author       Hmhm
// @match        *://*.pornhub.com/view_video.php?viewkey=*
// @match        *://*.pornhubpremium.com/view_video.php?viewkey=*
// @grant        unsafeWindow
// @license      WTFPL
// ==/UserScript==

(Win=>{
	for(let key in Win){
		if(key.startsWith("flashvars_")){
			for(let md of Win[key]?.mediaDefinitions){
				if(md?.format=="mp4"){
					fetch(md.videoUrl,{mode:"cors"}).then(r=>r.json()).then(json=>{
						let dom = document.createElement("div");
						dom.innerHTML = json.map(obj=>`<h1><a href="${obj?.videoUrl}">${obj?.quality}p</a></h1>`).join("");
						if(typeof(isPlatformMobile)!="undefined"&&isPlatformMobile==1)
							document.body.insertBefore(dom,document.querySelector("#mobileContainer"));
						else
							document.querySelector("#main-container").insertBefore(dom,document.querySelector("#vpContentContainer"));
					});break;
				}
			}
		}
	}
})(unsafeWindow??window);