Sleazy Fork is available in English.

ExtendPornHub

Remove ads, enlarges video, stops autoplay keeping buffering & block pop-ups

اعتبارا من 15-07-2015. شاهد أحدث إصدار.

// ==UserScript==
// @author			Jack_mustang
// @version			1.7
// @name			ExtendPornHub
// @description		Remove ads, enlarges video, stops autoplay keeping buffering & block pop-ups
// @date			2015 July 15
// @include			*pornhub.com/*
// @run-at			document-start
// @grant			none
// @license			Public Domain
// @icon			https://gmgmla.dm2301.livefilestore.com/y2pAKJYeZAp4tG23hG68x1mRuEUQXqb1MxdLbuqVnyyuHFxC7ra5Fc-tfq6hD-r9cNnVufT3egUHaimL547xDlESrOVmQsqNSJ5gzaiSccLYzo/ExtendPornHub-logo.png
// @namespace		649b97180995e878e7e91b2957ef3bbee0f840a0
// ==/UserScript==
var ExtendPH = function ExtendPornHub(){
	// Pop-up killer, we trick PH to think we are old Presto Opera, this kills the pop-ups
	if (!window.opera)
		window.opera = true

	addStyle()

	window.addEventListener('DOMContentLoaded', function(){
		// Remove ads functions
		function removeQuery(query) {
			var ifr = document.querySelectorAll(query)
			if(ifr.length > 0)
				for(var i=0; i < ifr.length; i++)
					ifr[i].parentNode.removeChild(ifr[i])
		}
		// Remove iframes because they are ads
		removeQuery("iframe")
		// Front Page ads
		removeQuery(".replacementDiv")
		// Pornstars list ads
		removeQuery(".home-ad-container")
		// gifs, but may be on other places
		removeQuery(".browse-ad-container")

		/* Video page */
		if(document.getElementById('player')) {
			// move right column if it exists
			if(document.getElementById("hd-rightColVideoPage")) {
				var rightColumn = document.getElementById("hd-rightColVideoPage"),
					rightColumnNode = rightColumn.cloneNode(true),
					contentHolder = document.getElementById('main-container')
				contentHolder.removeChild(rightColumn)
				contentHolder.insertBefore(rightColumnNode, document.querySelector('.video-wrapper+.video-wrapper'))
			}

			// Change player
			var player = document.getElementById('player'),
				vidId = parseInt(player.getAttribute("data-video-id")),
			newflashvars = document.createElement("script")
			newflashvars.setAttribute("type", "text/javascript")
			newflashvars.id = "EPH-newflashvars"
			newflashvars.innerHTML =
			'flashvars_'+vidId+'.autoplay = false;'+
			'flashvars_'+vidId+'.autoload = true;'+
			'flashvars_'+vidId+'.htmlPauseRoll = false;'+
			'flashvars_'+vidId+'.htmlPostRoll = false;'+
			'flashvars_'+vidId+'.video_unavailable_country = false;'
			player.insertBefore(newflashvars, player.childNodes[0])

			// HTML5 player
			function html5player() {
				var flash = document.querySelector("#player object"),
					html5 = document.querySelector("#player video")
				if (flash == null && html5 == null)
					return setTimeout(html5player, 50)

				scrollthere()

				if (flash == null) {
					var video = document.querySelector("#player video")
					// Because those idiots call play()
					video.onplay = function() {
						video.load()
						video.onplay = null
					}
					video.setAttribute("onclick", "var vid = event.target;if(vid.paused)vid.play();else vid.pause()")
					video.setAttribute("onmouseover", "event.target.controls = true")
					video.setAttribute("onmouseout", "event.target.controls = false")
				}
			}

			// Scroll video to middle of page
			function scrollthere() {
				var player = document.getElementById('player'),
					vh = player.offsetHeight,
					vd = document.querySelector(".container").offsetTop + document.querySelector(".container").parentNode.offsetTop + document.querySelector(".video-wrapper").offsetTop + ((document.querySelector("#PornhubNetworkBar>.bar_body")==null) ? 25 : 0),
					fh = window.innerHeight;
					sc = vd-((fh-vh)/2)
				scrollTo(0, sc)
				console.info("** ExtendPornHub **\ntop: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
			}
			// Inject this function to page
			var script = document.createElement("script")
			script.setAttribute("type", "text/javascript")
			script.innerHTML = scrollthere.toString() + html5player.toString() + "html5player();"
			script.id = "EPH-scrollVid"
			document.body.appendChild(script)

			// Include button in right corner to center video on screen
			var node = document.createElement("div")
			node.setAttribute("style","position: fixed; bottom: 0; right: 0; cursor: pointer; border: 1px solid #313131; border-top-left-radius: 5px; color: #676767; font-weight: 700; background: #101010; text-align: center; font-size: 12px; padding: 7px 15px;z-index: 999999;")
			node.setAttribute("onclick", "scrollthere();")
			node.innerHTML = "Center video"
			node.id = "EPH-scroll"
			document.body.appendChild(node)
		}
	},false)

	function addStyle() {
		// While <head> is not loaded we keep trying
		if (!document.querySelector("head"))
			return setTimeout(addStyle, 50)

		// We create an object and start including its content to include in DOM at the end
		var ephcss =
		// Hide ads while we can't remove them
		"iframe, .replacementDiv, .container+div, .home-ad-container, hd-rightColVideoPage > div, .ad-link {\n\
			display: none !important;\n\
		}\n" +
		// Videos Being Watched Right Now in one line
		"ul.row-5-thumbs.videos-being-watched li.omega {\n\
			display: none;\n\
		}\n" +
		/* Video page */
		// Enlarge video
		"#main-container .video-wrapper:first-child, #main-container div:first-child:not(.video-wrapper)+.video-wrapper, #main-container div:first-child:not(.video-wrapper)+div:not(.video-wrapper)+.video-wrapper, #main-container div:first-child:not(.video-wrapper)+div:not(.video-wrapper)+div:not(.video-wrapper)+.video-wrapper {\n\
			width: 100% !important;\n\
		}\n\
		#main-container .video-wrapper #player {\n\
			height: 633px !important;\n\
		}\n" +
		// trick for moving right column in a more subtle way
		"#hd-rightColVideoPage:first-child, #hd-rightColVideoPage:not(.video-wrapper+#hd-rightColVideoPage) {\n\
			display: none;\n\
		}\n" +
		// correct right column
		"#main-container .reset {\n\
			display: none;\n\
		}\n" +
		/* Gifs pages */
		".gifsWrapper ul.gifs li.first, .gifsWrapper ul.gifs li.first img.thumb {\n\
			height: 354px !important;\n\
			width: 468px !important;\n\
		}\n"

		// Inject created CSS
		var ephnode = document.createElement("style")
			ephnode.type = "text/css"
			ephnode.id = "EPH-style"
			ephnode.appendChild(document.createTextNode(ephcss))
		document.head.appendChild(ephnode)
	}
}();