Sleazy Fork is available in English.

ExtendPornHub

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

נכון ליום 15-04-2015. ראה הגרסה האחרונה.

// ==UserScript==
// @author			Jack_mustang
// @version			1.4
// @name			ExtendPornHub
// @description		Remove ads, enlarges video, stops autoplay keeping buffering & block pop-ups
// @date			2015 April 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'))
			}
			videoStuff()
		}
	},false)

	function videoStuff() {
		if (!(document.querySelector("#player object") || document.querySelector("#player video")))
			return setTimeout(videoStuff, 50)

		// Change player, remove in-video ads and remove autoplay and enable autobuffer, no need for HTML
		if (document.querySelector('#player object')) {
			var player = document.querySelector('#player object'),
				modPlayer = player.innerHTML
			modPlayer = modPlayer.replace(/autoplay=true/g,"autoplay=false&autoload=true")
			modPlayer = modPlayer.replace(/htmlPauseroll=true/g,"htmlPauseroll=false&disable_sharebar=true")
			modPlayer = modPlayer.replace(/htmlPostRoll=true/g,"htmlPostRoll=false")
			modPlayer = modPlayer.replace(/&pauseroll_url=http:\/\/.*\.php/g,"")
			modPlayer = modPlayer.replace(/&postroll_url=http:\/\/.*\.php/g,"")
			player.innerHTML = modPlayer
		}

		// 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.getElementById("#PornhubNetworkBar") ? 0 : 25),
				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() + "scrollthere();"
		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)
	}

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