KAT Headers Unified

Unifies and improves the headers of both the community and torrent sections of the site. (and makes community pages full width)

נכון ליום 22-08-2018. ראה הגרסה האחרונה.

// ==UserScript==
// @name         KAT Headers Unified
// @namespace    NotNeo
// @version      0.3
// @description  Unifies and improves the headers of both the community and torrent sections of the site. (and makes community pages full width)
// @author       NotNeo
// @match        https://katcr.co/show/community/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @grant        none
// ==/UserScript==

var headerShrunkByDefault = "remember"; //yes,no,remember

addGlobalStyle(`
	#wrapper {
		max-width: 100% !important;
	}

	#header {
		padding-left: 5px;
		position: fixed;
		width: 100%;
		z-index: 100;
	}

	#content_section {
		padding-top: 65px;
	}

	#header div.frame {
		padding-right: 5px;
	}

	#top_section > .forumtitle {
		margin-right: -55px;
	}

	#top_section {
		min-height: 0px;
	}

	#header > .frame > div:last-of-type, #header > .frame > br.clear {
		display: none;
	}

	#menu_nav > li > ul {
		position: fixed;
		border: solid #333 2px;
		width: -moz-min-content;
		width: -webkit-min-content;
	}

	#search_form  .input_text {
		max-width: calc(100% - 1350px) !important;
		min-width: 200px;
	}

	.valueBubble {
		display: inline-block;
		height: 7px;
		width: 7px;
		margin-bottom: 7px;
		margin-left: -10px;
		margin-right: -2px;
		font-family: sans-serif;
		color: #fc7208;
		background: #fc7208;
		border: 2px solid #594c2d;
		border-radius: 50%;
		transition: .1s all;
	}

	.valueBubble span {
		position: absolute;
		margin-top: -22px;
		margin-left: 10px;
		font-size: 10px;
	}

`);

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}

function CalcContentPad() {
    if($("#upshrink").attr("src").split("images/")[1] == "upshrink.png") {
        $("#content_section").prop("style", "padding-top: 165px;");
    }
    else {
        $("#content_section").prop("style", "padding-top: 65px;");
    }
}

$("#siteslogan").detach().appendTo('#upper_section');
$("#main_menu").parent().detach().appendTo("#top_section");

if(headerShrunkByDefault != "remember") { //if header shrink is "remember", let the site handle it...
    var imgSrc = $("#upshrink").attr("src").split("images/")[1]; //...else get current state
    if((headerShrunkByDefault == "yes" && imgSrc == "upshrink.png") || (headerShrunkByDefault == "no" && imgSrc == "upshrink2.png")) { //...and if the state is wrong...
        $("#upshrink").click(); //...change it
    }
}

//GetUserName
var userName = $(".greeting > span").text();

//Adding/removing/moving header parts
var numOfPM = $("#button_pm span.firstlevel strong").text() || 0;//get number of messages
$("#button_pm").remove();
$("#menu_nav").append(`
	<li id="button_pm">
		<a class="firstlevel" href="https://katcr.co/show/community/index.php?action=pm">
			<i class="ka ka-message"></i> <span class="valueBubble"><span>`+numOfPM+`</span></span> Messages
		</a>
		<ul class="navigation__sub_items">
			<li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=pm;sa=send" class="navigation__link"><i class="kf__pencil button button--icon-button"></i> New message</a></li>
			<li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=pm" class="navigation__link"><i class="kf__envelope button button--icon-button"></i> Inbox</a></li>
		</ul>
	</li>
`);

$("#button_logout").remove();
$("#button_profile").remove();
$("#menu_nav").append(`
	<li id="button_profile">
		<a class="firstlevel" href="https://katcr.co/user/`+userName+`/profile/"><i class="ka ka-user"></i> `+userName+`</a>
		<ul class="navigation__sub_items" style="right: 45px;">
			<li class="navigation__item"><a href="https://katcr.co/user/`+userName+`/profile/" class="navigation__link">Profile (Torrent View)</a></li>
			<li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=profile" class="navigation__link">Profile (Forum View)</a></li>
			<li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=profile;area=forumprofile" class="navigation__link">Edit Profile</a></li>
			<li class="navigation__item"><a href="https://katcr.co/show/community/index.php?action=logout;f5a864270bbe=31cebf87c5228ae961571b9712fcd69b" class="navigation__link">Log out</a></li>
		</ul>
	</li>
`);


CalcContentPad();
$("#upshrink").click(CalcContentPad);