Localhost de essay

Personal tweaks for localhost

Verze ze dne 31. 10. 2016. Zobrazit nejnovější verzi.

// ==UserScript==
// @name			Localhost de essay
// @namespace		COMDSPDSA
// @version			1
// @description		Personal tweaks for localhost
// @author			Dan Overlander
// @include			*http://localhost:36865*
// @include			*http://localhost:36158*
// @require			https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require         https://greasyfork.org/scripts/23115-tampermonkey-support-library/code/Tampermonkey%20Support%20Library.js?version=146830
// @require		    https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js
// ==/UserScript==

/*
 * tm is an object included via @require from DorkForce's Tampermonkey Assist script
 */

(function() {
    'use strict';

    var TIMEOUT = 750,
		thisScript = 'Localhost de essay',
		toggle = {
            isResetting: undefined,
            hpCompressed: false
		},
		page = {
			initialize: function () {
				setTimeout(function () {
					page.addClasses();
                    page.setTamperIcon();
					page.addHighlights();
                    page.compressHomepage();
				}, TIMEOUT);
			},
			addClasses: function () {
				if (!toggle.areClassesAdded) {
					toggle.areClassesAdded = true;

                    tm.addGlobalStyle('.cust-list-blk:hover {background-color: cornsilk}');
                    tm.addGlobalStyle('.home-sections .dotted {margin-top:3px; margin-bottom:3px;');
                    tm.addGlobalStyle('.home-sections .actv-block {padding-bottom:0;');
                    tm.addGlobalStyle('.singleActivity:hover {background-color: cornsilk;}');

                    tm.addGlobalStyle('.usertag {background-color: greenyellow;}');
                }
			},
			setTamperIcon: function () {
				// Add Tampermonkey Icon with label to identify this script
				if (!toggle.isResetting) {
					$('.tamperlabel').remove();
					toggle.isResetting = setTimeout(function() {
						if($('.tamperlabel').length > 0) {
							$('.tamperlabel').prop('title', $('.tamperlabel').prop('title') + ' | ' + thisScript);
						} else {
							$('.brand-title').append('<span class="icon-ui-dell tamperlabel" title="Tampermonkey scripts: ' + thisScript + '"></span>');
						}
						toggle.isResetting = undefined;
					}, TIMEOUT);
				}
			},
            addHighlights: function () {
                $('.cust-list-blk a:contains("IVANA")').css('color', 'red');
                $('.cust-list-blk a:contains("UMBRELLA")').css('color', 'red');
                $('.cust-list-blk a:contains("TYRELL")').css('color', 'red');
                $('.cust-list-blk a:contains("BOB")').css('color', 'red');
                if ($('.cust-list-blk a:contains("BOB")').text().indexOf('DOMS') <= 0) {
                    $('.cust-list-blk a:contains("BOB")').append(' <span class="usertag">DOMS</span>');
                }
            },
            compressHomepage: function () {
                if (!toggle.hpCompressed) {

                    //toggle.hpCompressed = true;
                    $('.cust-list-blk').css({'height': '22px', 'font-size': '.8em', 'overflow': 'hidden'});
                    $('.icon-c360-sm').css({'height': '8px', 'width': '9px'});
                    $('.icon-small-favorite-100').css({'height': '9px', 'width': '9px', 'background-position': '-287px -46px'});
                    $('.icon-small-favorite-0').css({'height': '9px', 'width': '9px', 'background-position': '-286px -137px'});
                    $('.remove-record').css({'top': '-3px', 'position': 'relative', 'height': '20px'});
                    $('.cust-list-blk a:nth-child(3)').parent().next().css({'position': 'relative', 'float': 'right', 'top': '-13px'}).html('<span class="remove-record leQuote" style="background-position:-46px -144px;">&nbsp;</span>');

                    // recent activity
                    $('.actv-type span:first-child').css('display', 'none');
                    $('.actv-type span:nth-child(2)').css('float', 'right');

                    // hide last col
                    if ($('#main .col-md-4:nth-child(4)').length > 0) {
                        $('#main .col-md-4:nth-child(4)').remove();
                        $('#main .col-md-4').toggleClass("col-md-4").toggleClass("col-md-6");
                    }

                    // hide title
                    $('#home_recentActivity').parent().parent().hide();

                    // compress title bar
                    $('.top-nav').css({'padding': '3px 0 0 0'});
                    $('.icon-ui-dell').css({'font-size': '35px', 'height': '35px'});
                    $('.main-nav').css({'min-height': '40px', 'margin-bottom': '10px', 'height': '40px'});
                    $('.view-nav-withoutribbon').css({'margin-top': '30px'});
                    $('.brand-title').css({'line-height': '35px'});
                    $('.content-shell .view-nav').css({'top': '40px'});
                    $('.brand').next().next().css({'position': 'relative', 'top': '-8px'});
                    if($('.remove-record').length === 0) {
                        if($('.view-nav-withoutribbon').length > 0) {
                            $('.content-area').css({'margin-top': '10px'});
                        } else {
                            $('.content-area').css({'margin-top': '100px'});
                        }
                    }
                }
            }
		};

    /*
     * Global functions
     */

	function loopMain () {
		if ($('.remove-record').length > 0 || $('#main').length > 0) {
			page.initialize();
		} else {
			setTimeout(loopMain, TIMEOUT);
		}
	}

	setTimeout(loopMain, TIMEOUT);

	$(document).mouseup(function(e) {
		loopMain();
	});

})();