ladroop / Cam4 Clean

// ==UserScript==
// @name		   Cam4 Clean
// @description    removes all add's
// @namespace	   cam4_goes_droopy
// @version		   3.1
// @match          https://*.cam4.com/*
// @match          https://cam4.com/*
// @match          http://*.sex.co.uk/*
// @match          http://sex.co.uk/*
// @license        MIT
// @copyright      2015, ladroop (https://sleazyfork.org/nl/users/7390-ladroop)
// @grant          none
// @run-at         document-end
// ==/UserScript==

(function() {
    'use strict';

createCookie("bannerPops","under-exit",1);
createCookie("dirPageCount",11,1);

var thumbpage=false;
var campage=false;
var biopage=false;
var fullscreen=false;
var newelem="";
// for greasemonkey
var win = window.wrappedJSObject ? window.wrappedJSObject : window;

//first check where we are
    if (document.getElementById("directoryHtml")){
        thumbpage=true;
    }
    if (document.getElementById("profileHeaderTop")){
        biopage=true;
    }
    if (document.getElementById("camPaneBig")){
        campage=true;
    }

// do some actions
    if (thumbpage){
        setversion();
        remads();
        stopload();
    }
    if (biopage){
        setversion();
        showvotes();
    }
    if (campage){
        remads2();
        stopgold();
        fsbutton();
    }

// functions

//show script version on all pages
    function setversion(){
        var infostuff=document.getElementsByClassName('leftStuff');
        infostuff[0].innerHTML=infostuff[0].innerHTML+" | Made add Free by Ladroop.&nbsp V"+GM_info.script.version;
    }

// full screen button
    function fsbutton(){
        newelem=document.createElement('li');
		newelem.className="btn btn-orange";
		newelem.innerHTML="Theater modus";
		newelem.addEventListener('click',fullchat);
		document.getElementById("NSBar").appendChild(newelem);
    }

// go or exit fullscreen
    function fullchat(){
        if (!fullscreen){
            win.FullScreenApi.playerGoFullScreen();
            if (document.getElementById("Cam4HLSPlayer")){
                document.getElementById("video").style.height=parseInt(document.getElementById("video").style.height)-32+"px";
            }
            fullscreen=true;
        }else{
            win.FullScreenApi.playerExitFullScreen();
            fullscreen=false;
        }
    }

// block the go gold pop-up
    function stopgold(){
        win.Registration.showGoldUpgradeOverlay=function(){return false};
    }

// adverts on campage
    function remads2(){
        document.getElementById("besideBroadcastingContainer").style.display="none";
        document.getElementById("camPaneBig").style.width="100%";
        document.getElementById("profile-ad").style.display="none";
        if(document.getElementById("videoBannerMidrollAdWrapper")){
           document.getElementById("videoBannerMidrollAdWrapper").style.zIndex=-3;
        }
    }

// stop the loading overlay on thumbpage
    function stopload(){
        setInterval(function(){
            document.getElementById("directoryHtml").className="newThumbs";
        }, 3000);
    }

// adverts on thumbpage
    function remads(){
        document.getElementsByClassName("skyscraper-ad-1")[0].style.display="none";
        document.getElementsByClassName("skyscraper-ad-2")[0].style.display="none";
        document.getElementsByClassName("promo-center")[0].style.display="none";
        document.getElementsByClassName("sponsorAd")[0].style.display="none";
        document.getElementsByClassName("sponsorAd")[1].style.display="none";
        setTimeout(function(){
            document.getElementById("homeRandomAd-1").style.visibility="hidden";
            document.getElementById("homeRandomAd-1").style.height="0px";
        }, 2000);
        setTimeout(function(){
            document.getElementById("homeRandomAd-2").style.visibility="hidden";
            document.getElementById("homeRandomAd-2").style.height="0px";
        }, 2000);
        document.getElementById("subfoot").style.display="none";
        document.getElementById("main-content").className="";
    }

// show number of votes in the ranking on bio page
    function showvotes(){
        document.getElementById("rating_status").innerHTML=document.getElementById("hiddenvotes").innerHTML+" people voted";
    }

// cookie functions
	function createCookie(name,value,days,domain){
        var expires="";
        if (domain){
            domain=";domain=."+domain;
        }else{
            domain = "";
        }
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            expires = "; expires="+date.toGMTString();
        }
        document.cookie = name+"="+value+expires+"; path=/"+domain;
	}

})();