哔哩哔哩动态页导航优化

1.哔哩哔哩动态页导航样式优化,有横竖两种,切换样式只需删除源码里“/*”和“*/”即可,同时请将另一种样式注释掉。2.默认显示“投稿视频”内容。

当前为 2018-04-06 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name               哔哩哔哩动态页导航优化
// @namespace    http://asifadeaway.com/
// @version            0.3
// @icon                  https://static.hdslb.com/images/favicon.ico
// @description     1.哔哩哔哩动态页导航样式优化,有横竖两种,切换样式只需删除源码里“/*”和“*/”即可,同时请将另一种样式注释掉。2.默认显示“投稿视频”内容。
// @author             QIUZAIYOU
// @match             http*://t.bilibili.com/*
// @grant               none
// @require            https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// ==/UserScript==
$(function() {
	//默认显示“投稿视频”内容
	$(".tab-bar .tab a").removeClass("selected");
	$(".tab-bar > div:nth-child(3) > a:nth-child(1)").addClass("selected");
	$(".tab-bar .line").css("transform", "translateX(172px)");
	var url = $(location).attr('href');

	function OpenDongTai() {

		if (url == 'https://t.bilibili.com/pages/nav/index') {
			return false; //不影响BiliBili首页导航栏动态悬浮窗内容显示
		} else if (url != 'https://t.bilibili.com/?tab=8') {
			window.location.href = "https://t.bilibili.com/?tab=8";
		} else {
			return false;
		}
	}
	OpenDongTai();
	//横排置顶样式且导航栏置顶显示
	var a = $('.tab-bar'),
		b = a.offset(),
		d = $('.tab-bar .tab'),
		e = $('.tab-bar .tab .tab-text'); //返回或设置导航栏相对于文档的偏移(位置)
	//加个屏幕滚动事件,c是滚动条相当于文档最顶端的距离
	$(document).on('scroll', function() {
		var c = $(document).scrollTop();
		//当滚动的屏幕距离大于等于导航栏本身离最顶端的距离时(判断条件)给它加样式(根据自己业务的条件加样式,一般如下)
		if (b.top <= c) {
			d.css({
				textAlign: 'center',
				margin: '0 auto',
			});
			e.css('lineHeight', '40px');
			a.css({
				position: 'fixed',
				width: '632px',
				top: '0',
				margin: '0 auto',
				zIndex: '915049',
				height: '40px',
				lineHeight: '40px'
			});
		} else {
			d.css({
				margin: '',
				textAlign: ''
			});
			e.css('lineHeight', '');
			a.css({
				position: '',
				width: '',
				top: '',
				margin: '',
				zIndex: '',
				height: '',
				lineHeight: ''
			});
		}
	});

});



/*
//竖排样式
$(function() {
    var a = $('.tab-bar'),
        b = a.offset(), //返回或设置导航栏相对于文档的偏移(位置)
        d = $('.tab-bar .tab'),
        e = $('.line');
    //加个屏幕滚动事件,c是滚动条相当于文档最顶端的距离
    $(document).on('scroll', function() {
        var c = $(document).scrollTop();
        //当滚动的屏幕距离大于等于导航栏本身离最顶端的距离时(判断条件)给它加样式(根据自己业务的条件加样式,一般如下)
        if(b.top <= c) {
            d.css({
                display:'block',
                padding:'0',
                textAlign:'center',
                margin: '0 auto',
            });
            e.css('display','none');
            a.css({
                position: 'fixed',
                width: '70px',
                left: '50%',
                margin: '0 0 0 313px',
                zIndex: '915049',
                height:'290px',
                lineHeight:'40px',
                boxShadow:'0 0 10px 0 rgba(154,197,242,.9)'

            });
        } else {
            d.css({
                display:'',
                padding:'',
                margin: '',
                textAlign:''
            });
            e.css('display','');
            a.css({
                position: '',
                width: '',
                left: '',
                margin: '',
                zIndex: '',
                height:'',
                lineHeight:'',
                boxShadow:''
            });
        }
    });
});
*/