LiveLeak Enhancements

Hides annoying page sections (e.g. social media, advertising) and other enhancements.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        LiveLeak Enhancements
// @description Hides annoying page sections (e.g. social media, advertising) and other enhancements.
// @version     1.0
// @namespace   Dimethyl
// @include     *://www.liveleak.com/*
// @grant       none
// ==/UserScript==

function onFirstDocumentReady() {
    var $topUserMenuLink = $(".top_user_menu_link");
    if ($topUserMenuLink.length) {
        var linkOffset = $topUserMenuLink.offset();
        $('#top_user_menu').offset({
            top: linkOffset.top + $topUserMenuLink.height(),
            left: linkOffset.left
        });
    }
    
    $('#top_user_menu > a[href^="comment?"]')
       .each(function() { this.href += '&sort_by=newest'; });
    
    var $likeTable = $('a[href="http://www.facebook.com/liveleak.official"]').first().closest('table');
    if ($likeTable.length) {
        $likeTable.hide();
        $likeTable.next().hide();
    }
    
    var $shareDiv = $('div[class~="pw-counter-vertical"]');
    if ($shareDiv.length) {
        $shareDiv.hide();
        $shareDiv.next().hide();
    }
    
    var $itemShareDiv = $('div[class~="pw-counter-horizontal"]');
    if ($itemShareDiv.length) {
        $itemShareDiv.parent().hide();
    }
    
    var $adSpan = $('#rightcol > span').filter(function() { return $(this).text() == 'Advertisement below'; });
    if ($adSpan.length) {
        $adSpan.hide();
        $adSpan.next().hide();
    }
    
    var $adverDiv = $('div[class~="section_title"]').filter(function() { return $(this).text() == 'Advertisers'; });
    if ($adverDiv.length) {
        $adverDiv.hide();
        $adverDiv.next().hide();
    }
    
    var $itemAd = $('div.tab_nav_large').prevAll('div.clear').first().next('center');
    if ($itemAd.length) {
        $itemAd.hide();
        $itemAd.next().hide();
    }
}

function onEveryDocumentReady() {
    var animationDuration = 250;
    
    $(".top_user_menu_link")
        .unbind('click')
        .wrap('<a href="' + $(".top_user_menu a").first().attr('href') + '" style="text-decoration: none;"></a>')
        .click(function(e) {
            if (e.which == 2) return;
            var $menu = $("#top_user_menu");
            if (!$menu.is(':visible')) e.stopPropagation();
            $menu.fadeIn(animationDuration);
            e.preventDefault();
        });
    
    $(".user_popup_menu_link")
        .unbind('click')
        .click(function(e) {
            if (e.which == 2) return;
            $menu = $(this).parent().find(".user_popup_menu");
            if (!$menu.is(':visible')) e.stopPropagation();
            $menu.fadeIn(animationDuration);
            e.preventDefault();
        });
    
    $('#top_user_menu').prop('onclick', null);
    
    $(document)
        .unbind('click')
        .click(function(e) {
            $('#top_user_menu').fadeOut(animationDuration);
            $(".user_popup_menu").fadeOut(animationDuration);
        });
    
    $('.user_popup_menu_shell')
        .each(function() {
            var $menuLink = $(this).find('.user_popup_menu_link');
            var $channelLink = $(this).find('.user_popup_menu a').first();
            if ($menuLink.length && $channelLink.length) {
                $menuLink[0].href = $channelLink[0].href;
            }
        });
}

setTimeout(function() { onFirstDocumentReady(); onEveryDocumentReady(); }, 0);

$(document).ajaxSuccess(function() { setTimeout(onEveryDocumentReady, 0); });