博客美化合集(未完待续~)

申明

申明
请注意,本文最后更新时间:2022-01-26,以后内容可能已经不具有时效性,请谨慎参考


添加复制提醒

没找到好看的复制提醒代码只能凑合用这个了,有好看的记得分享一下

  1. 在头部引用
  2. 在后台底部自定义添加

头部引用

     <script src="https://www.xiaobai666.top/usr/themes/Cuteen/static/layer/layer.js"></script>

在后台底部自定义添加

    <script>
       document.addEventListener("copy",function(e){new Vue({data:function(){this.$notify({title:"复制成功",message:"若要转载请务必保留原文链接!",type:"success"});return{visible:false}}})})


</script>

添加天气

<a href="https://blog.lemonct.xyz/index.php/archives/110/" class="LinkCard">天气教程</a>

字体

<a href="https://blog.lemonct.xyz/index.php/archives/101/" class="LinkCard">字体教程</a>

进站提示

在主题后台底部自定义中添加
如果你网站开启了pjax,可能还会有点小bug,问题不大

    <!-- 客户端信息 -->
        <div id="fps" style="z-index:5;position:fixed;bottom:3px;left:3px;color:#2196F3;font-size:10px;"></div>
        <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/kaliisra/myblogstatic/kehuduan-js/fetch.min.js"></script>
        <script src="https://cdn.gmit.vip/layer/3.1.1/layer.js" type="text/javascript" charset="utf-8"></script>
        <script>
        /*网站打开提醒代码开始*/
        $(function(){
            if(/*getCookie('msg') !=*/ 1){
                var t = document.createElement("a");
                t.href = document.referrer;
                var msgTitle = t.hostname;
                var name = t.hostname.split(".")[1];
                if("" !== document.referrer){
                    switch (name) {
                        case 'bing':
                            msgTitle = '必应搜索';
                            break;
                        case 'baidu':
                            msgTitle = '百度搜索';
                            break;
                        case 'so':
                            msgTitle = '360搜索';
                            break;
                        case 'google':
                            msgTitle = '谷歌搜索';
                            break;
                        case 'sm':
                            msgTitle = '神马搜索';
                            break;
                        case 'sogou':
                            msgTitle = '搜狗搜索';
                            break;
                        default:
                            msgTitle =  t.hostname;
                    };
                };
                var time = (new Date).getHours();
                var msg = '';
                23 < time || time <= 5 ? msg = "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛?":
                5< time && time <= 7 ? msg = "早上好!一日之计在于晨,美好的一天就要开始了!":
                7< time && time <= 11 ? msg = "上午好!工作顺利嘛,不要久坐,多起来走动走动哦!":
                11< time && time <= 14 ? msg = "中午了,工作了一个上午,现在是午餐时间!":
                14< time && time <= 17 ? msg = "午后很容易犯困呢,今天的运动目标完成了吗?":
                17< time && time <= 19 ? msg = "傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~":
                19< time && time <= 21 ? msg = "晚上好,今天过得怎么样?":
                21< time && time <= 23 && (msg = "已经这么晚了呀,早点休息吧,晚安~");
                $.ajax({
                    type:"get",
                    url:"https://open.gmit.vip/web/api/UserInfo/",
                    async:true,
                    success:function(data){
                        window.info = data;
                        layer.msg("Hi~ 来自"+ data.data.location + '~<br/>通过 '+msgTitle+' 进来的朋友!<br/>使用 '+ data.data.os +"<br/>"+ data.data.browser +' 访问本站!' + '<br/>' + msg);
                        var showFPS = (function(){
                            var requestAnimationFrame =
                                window.requestAnimationFrame ||
                                window.webkitRequestAnimationFrame ||
                                window.mozRequestAnimationFrame ||
                                window.oRequestAnimationFrame ||
                                window.msRequestAnimationFrame ||
                                function(callback) {
                                    window.setTimeout(callback, 1000/60);
                                };
                            var e,pe,pid,fps,last,offset,step,appendFps;
     
                            fps = 0;
                            last = Date.now();
                            step = function(){
                                offset = Date.now() - last;
                                fps += 1;
                                if( offset >= 1000 ){
                                last += offset;
                                appendFps(fps);
                                fps = 0;
                                };
                                requestAnimationFrame( step );
                            };
                            appendFps = function(fps){
                                var settings = {
                                    timeout: 5000,
                                    logError: true
                                };
                                $('#fps').html('<span style="float:left;">'+fps+'FPS</span><br/><span style="float:left">'+window.info.data.os+'</span><br/><span style="float:left;margin-top:1px;">'+window.info.data.browser+'</span><br/><span style="float:left;margin-top:1px;">'+window.info.data.location+'</span><br/><span style="float:left;margin-top:1px;"></span>');
                            };
                            step();
                        })();
                    }
                });
            };
        });
        </script>

如果不显示,在头部或者脚部添加以下代码

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

添加访问量统计

我这里用的是插件,当然你们也可以用代码
插件:https://wws.lanzous.com/iVAPflj0zfa 密码:8x7v
之后在后台启用,并在你想要显示的地方添加以下代码
这个是访问统计

    <p class="small"> <?php PageViews_Plugin::showPageViews(); ?>

这个是点击量

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

添加在线人数统计

在functios.php最后添加

    //在线人数
    function online_users() {
        $filename='online.txt'; //数据文件
        $cookiename='Nanlon_OnLineCount'; //Cookie名称
        $onlinetime=30; //在线有效时间
        $online=file($filename); 
        $nowtime=$_SERVER['REQUEST_TIME']; 
        $nowonline=array(); 
        foreach($online as $line){ 
            $row=explode('|',$line); 
            $sesstime=trim($row[1]); 
            if(($nowtime - $sesstime)<=$onlinetime){
                $nowonline[$row[0]]=$sesstime;
            } 
        } 
        if(isset($_COOKIE[$cookiename])){
            $uid=$_COOKIE[$cookiename]; 
        }else{
            $vid=0;
            do{
                $vid++; 
                $uid='U'.$vid; 
            }while(array_key_exists($uid,$nowonline)); 
            setcookie($cookiename,$uid); 
        } 
        $nowonline[$uid]=$nowtime;
        $total_online=count($nowonline); 
        if($fp=@fopen($filename,'w')){ 
            if(flock($fp,LOCK_EX)){ 
                rewind($fp); 
                foreach($nowonline as $fuid=>$ftime){ 
                    $fline=$fuid.'|'.$ftime."\n"; 
                    @fputs($fp,$fline); 
                } 
                flock($fp,LOCK_UN); 
                fclose($fp); 
            } 
        } 
        echo "$total_online"; 
    } 

在你想显示的地方添加

在线人数: <?php echo online_users() ?>人

仿知乎链接.

预览图

在头部插入

    <script src="https://cdn.jsdelivr.net/gh/Sanarous/files@1.13/js/linkcard.js"></script>

格式

 <a href="链接" class="LinkCard">名称</a>

头像旋转呼吸光环

在自定义css中添加

    /**头像旋转呼吸光环**/
    .friends-img.mr-2.lazy.loaded:hover{
    transform:rotate(360deg);
    }
    .comment-avatar:hover{
    transform:rotate(360deg);
    }
    .sidebar-comment-avatar.mr-1:hover{
    transform:rotate(360deg);
    }
    .friends-img.mr-2.lazy.loaded,.comment-avatar,.sidebar-comment-avatar.mr-1 {
        border-radius: 50%;
        animation: light 4s ease-in-out infinite;
        transition: all 0.5s;
    }
    @keyframes light {
        0% {
            box-shadow: 0 0 4px
    #ff1354;
        }
        25% {
        box-shadow: 0 0 16px #1ebbff;
        }
        50% {
        box-shadow: 0 0 4px #0ed39f;
        }
        75% {
        box-shadow: 0 0 16px #4fe7f4;
        }
        100% {
        box-shadow: 0 0 4px #f35444;
        }
    }

图标跳动

在自定义css中添加

    /*图标跳动*/
    #like.btn.btn-outline-primary.rounded-pill.align-items-center.d-inline-flex,#headingMoney.btn.btn-outline-primary.rounded-pill.align-items-center.d-inline-flex {
        animation: star 0.5s ease-in-out infinite alternate;
    }
     
    @keyframes star {
        from {
            transform: scale(1);
        }
     
        to {
            transform: scale(1.1);
        }
        }

评论添加@

在functions.php中添加

    //获取评论的锚点链接
    function get_comment_at($coid)
    {
        $db   = Typecho_Db::get();
        $prow = $db->fetchRow($db->select('parent,status')->from('table.comments')
            ->where('coid = ?', $coid));//当前评论
        $mail = "";
        $parent = @$prow['parent'];
        if ($parent != "0") {//子评论
            $arow = $db->fetchRow($db->select('author,status,mail')->from('table.comments')
                ->where('coid = ?', $parent));//查询该条评论的父评论的信息
            @$author = @$arow['author'];//作者名称
            $mail = @$arow['mail'];
            if(@$author && $arow['status'] == "approved"){//父评论作者存在且父评论已经审核通过
                if (@$prow['status'] == "waiting"){
                    echo '<p class="commentReview">(评论审核中))</p>';
                }
                echo '<a href="#comment-' . $parent . '">@' . $author . '</a>';
            }else{//父评论作者不存在或者父评论没有审核通过
                if (@$prow['status'] == "waiting"){
                    echo '<p class="commentReview">(评论审核中))</p>';
                }else{
                    echo '';
                }
            }
        } else {//母评论,无需输出锚点链接
            if (@$prow['status'] == "waiting"){
                echo '<p class="commentReview">(评论审核中))</p>';
            }else{
                echo '';
            }
        }
    }

修改comment.php文件
原内容

<div class="comment-content" data-expand="查看更多..."><p style="display: inline;"><?= Ctx::Comment($comments->content) ?></p>
</div>

修改成

    <div class="comment-content" data-expand="查看更多..."><?php $parentMail = get_comment_at($comments->coid)?><?php echo $parentMail;?><p style="display: inline;"><?= Ctx::Comment($comments->content) ?></p>
    </div>

右键美化

在footer.php中前面添加

    <style type="text/css">
        a {text-decoration: none;}
        div.usercm{background-repeat:no-repeat;background-position:center center;background-size:cover;background-color:#fff;font
    -size:13px!important;width:130px;-moz-box-shadow:1px 1px 3px rgba
    (0,0,0,.3);box-shadow:0px 0px 15px #333;position:absolute;display:none;z-index:10000;opacity:0.9; border-radius: 8px;}
        div.usercm ul{list-style-type:none;list-style-position:outside;margin:0px;padding:0px;display:block}
        div.usercm ul li{margin:0px;padding:0px;line-height:35px;}
        div.usercm ul li a{color:#666;padding:0 15px;display:block}
        div.usercm ul li a:hover{color:#fff;background:rgba(170,222,18,0.88)}
        div.usercm ul li a i{margin-right:10px}
        a.disabled{color:#c8c8c8!important;cursor:not-allowed}
        a.disabled:hover{background-color:rgba(255,11,11,0)!important}
        div.usercm{background:#fff !important;}
        </style>
    <div class="usercm" style="left: 199px; top: 5px; display: none;">
        <ul>
            <li><a href="链接"><i class="fa fa-home fa-fw"></i><span>首页</span></a></li>
            <li><a href="javascript:void(0);" onclick="getSelect();"><i class="fa fa-copy fa-fw"></i><span>复制</span></a></li>
            <li><a href="javascript:history.go(1);"><i class="fa fa-arrow-right fa-fw"></i><span>前进</span></a></li>
            <li><a href="javascript:history.go(-1);"><i class="fa fa-arrow-left fa-fw"></i><span>后退</span></a></li>
            <li style="border-bottom:1px solid gray"><a href="javascript:window.location.reload();"><i class="fa fa-refresh fa-fw
    "></i><span>重载网页</span></a></li>
            <li><a href="链接"><i class="fa fa-meh-o fa-fw"></i><span>友链</span></a></li>  
               <li><a href="链接"><i class="fa fa-pencil-square-o fa-fw"></i><span>给我留言吧</span
    ></a></li>
        </ul>
    </div>
    <script type="text/javascript">
        (function(a) {
            a.extend({
                mouseMoveShow: function(b) {
                    var d = 0,
                        c = 0,
                        h = 0,
                        k = 0,
                        e = 0,
                        f = 0;
                    a(window).mousemove(function(g) {
                        d = a(window).width();
                        c = a(window).height();
                        h = g.clientX;
                        k = g.clientY;
                        e = g.pageX;
                        f = g.pageY;
                        h + a(b).width() >= d && (e = e - a(b).width() - 5);
                        k + a(b).height() >= c && (f = f - a(b).height() - 5);
                        a("html").on({
                            contextmenu: function(c) {
                                3 == c.which && a(b).css({
                                    left: e,
                                    top: f
                                }).show()
                            },
                            click: function() {
                                a(b).hide()
                            }
                        })
                    })
                },
                disabledContextMenu: function() {
                    window.oncontextmenu = function() {
                        return !1
                    }
                }
            })
        })(jQuery);
     
        function getSelect() {
            "" == (window.getSelection ? window.getSelection() : document.selection.createRange().text) ? layer.msg("啊噢...你没>
    还没选择文字呢!") : document.execCommand("Copy")
        }
        function baiduSearch() {
            var a = window.getSelection ? window.getSelection() : document.selection.createRange().text;
            "" == a ? layer.msg("啊噢...你没还没选择文字呢!") : window.open("https://www.baidu.com/s?wd=" + a)
        }
        $(function() {
            for (var a = navigator.userAgent, b = "Android;iPhone;SymbianOS;Windows Phone;iPad;iPod".split(";"), d = !0, c = 0; c
     < b.length; c++) if (0 < a.indexOf(b[c])) {
                d = !1;
                break
            }
            d && ($.mouseMoveShow(".usercm"), $.disabledContextMenu())
        });
    </script>

动态标题

在后台底部自定义添加

    <!--动态标题-->
    <script>
    //崩溃欺骗
    var OriginTitle = document.title;
    var titleTime;
    document.addEventListener("visibilitychange", function () {
    if (document.hidden) {
    document.title = "╭(°A°)╮ 页面崩溃啦 ~";
    clearTimeout(titleTime);
    } else {
    document.title = "(ฅ>ω<*ฅ) 噫又好了~" + OriginTitle;
    titleTime = setTimeout(function () {
    document.title = OriginTitle;
    }, 2000);
    }
    });
    </script>

添加打字机效果

    <script>
        var chakhsu = function(r) {
            function t() {
                return b[Math.floor(Math.random() * b.length)]
            }
     
            function e() {
                return String.fromCharCode(94 * Math.random() + 33)
            }
     
            function n(r) {
                for (var n = document.createDocumentFragment(), i = 0; r > i; i++) {
                    var l = document.createElement("span");
                    l.textContent = e(),
                    l.style.color = t(),
                    n.appendChild(l)
                }
                return n
            }
     
            function i() {
                var t = o[c.skillI];
                c.step ? c.step--:(c.step = g, c.prefixP < l.length ? (c.prefixP >= 0 && (c.text += l[c.prefixP]), c.prefixP++) : "forward" === c.direction ? c.skillP < t.length ? (c.text += t[c.skillP], c.skillP++) : c.delay ? c.delay--:(c.direction = "backward", c.delay = a) : c.skillP > 0 ? (c.text = c.text.slice(0, -1), c.skillP--) : (c.skillI = (c.skillI + 1) % o.length, c.direction = "forward")),
                r.textContent = c.text,
                r.appendChild(n(c.prefixP < l.length ? Math.min(s, s + c.prefixP) : Math.min(s, t.length - c.skillP))),
                setTimeout(i, d)
            }
            var l = "",
            o = ["Walk between the black and white.", ].map(function(r) {
                return r + ""
            }),
            a = 2,
            g = 1,
            s = 5,
            d = 75,
            b = ["rgb(110,64,170)", "rgb(150,61,179)", "rgb(191,60,175)", "rgb(228,65,157)", "rgb(254,75,131)", "rgb(255,94,99)", "rgb(255,120,71)", "rgb(251,150,51)", "rgb(226,183,47)", "rgb(198,214,60)", "rgb(175,240,91)", "rgb(127,246,88)", "rgb(82,246,103)", "rgb(48,239,130)", "rgb(29,223,163)", "rgb(26,199,194)", "rgb(35,171,216)", "rgb(54,140,225)", "rgb(76,110,219)", "rgb(96,84,200)"],
            c = {
                text: "",
                prefixP: -s,
                skillI: 0,
                skillP: 0,
                direction: "forward",
                delay: a,
                step: g
            };
            i()
        };
        chakhsu(document.getElementById('chakhsu'));
    </script>

在后台小标题添加(可能会报错)

<p id="chakhsu" class="mt-3 h5 text-white d-flex"></p>

或者修改hero.php中的代码
源代码:

<p id="subheading" class="mt-3 h5 text-white d-flex">
<?= Ctx::HeroTitle($this)[1] ?>

修改为

<p id="chakhsu" class="mt-3 h5 text-white d-flex"></p>


添加转载说明

在post.php最下面添加

    <!--版权声明-->
    <script> 
    document.body.addEventListener('copy', function (e) { 
    if (window.getSelection().toString() && window.getSelection().toString().length > 10) { 
    setClipboardText(e); 
    } 
    }); 
    function setClipboardText(event) { 
    var clipboardData = event.clipboardData || window.clipboardData; 
    if (clipboardData) { 
    event.preventDefault(); 
    var htmlData = '' 
    + '著作权归作者所有。<br>' 
    + '商业转载请联系作者获得授权,非商业转载请注明出处。<br>' 
    + '作者:<?php $this->author() ?><br>' 
    + '链接:' + window.location.href + '<br>' 
    + '来源:<?php $this->options->siteUrl(); ?><br><br>' 
    + window.getSelection().toString(); 
    var textData = '' 
    + '著作权归作者所有。\n' 
    + '商业转载请联系作者获得授权,非商业转载请注明出处。\n' 
    + '作者:<?php $this->author() ?>\n' 
    + '链接:' + window.location.href + '\n' 
    + '来源:<?php $this->options->siteUrl(); ?>\n\n' 
    + window.getSelection().toString(); 
    clipboardData.setData('text/html', htmlData); 
    clipboardData.setData('text/plain',textData); 
    } 
    } 
    </script>

网站底部文字跳动

在后台css自定义添加

    /*跳动文字css*/
    .Pshake{ 
        display: inline-block; 
        will-change: transform; -webkit-transform-origin: center center; -ms-transform-origin: center center; 
        transform-origin: center center; -webkit-animation: Pshake_Crazy 1s ease-in-out infinite; 
        animation: Pshake_Crazy 1s ease-in-out infinite;
     } 
    @keyframes Pshake_Crazy{ 
        10%{transform:translate(-0.5px,-0.5px) rotate(0.5deg);}
        20%{transform:translate(-0.5px,1.5px) rotate(0.5deg);}
        30%{transform:translate(1.5px,0.5px) rotate(0.5deg);} 
        40%{transform:translate(1.5px,-0.5px) rotate(-0.5deg);} 
        50%{transform:translate(2.5px,1.5px) rotate(1.5deg);} 
        60%{transform:translate(-0.5px,-0.5px) rotate(-0.5deg);} 
        70%{transform:translate(-0.5px,2.5px) rotate(1.5deg);} 
        80%{transform:translate(2.5px,-1.5px) rotate(-0.5deg);} 
        90%{transform:translate(1.5px,-0.5px) rotate(1.5deg);} 
        0%,100%{transform:translate(0,0) rotate(0);} 
    }

在你想跳动的地方添加class="Pshake"


Typecho添加评论邮件通知

Typecho评论邮件通知插件 LoveKKComment


网站分享成卡片

    <!-- QQCard BEGIN -->
    <meta itemprop="name" content="XXX博客名"/>
    <meta itemprop="image" content="头图" />
    <meta name="description" itemprop="description" content="博客介绍" />
    <!-- QQCard END -->

在后台头部自定义或者在head.php内添加以上内容


更新区

....后续会出

  1. Typecho文章页添加百度收录检测
  2. Typecho添加评论邮件通知
    ....等美化

请我喝杯奶茶吧!~博主已经半年没喝了...

无标签
打赏
评论区
头像