博客园自动添加版权说明,自动添加文章链接
生活随笔
收集整理的這篇文章主要介紹了
博客园自动添加版权说明,自动添加文章链接
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
功能:
1.給每一篇文章開頭加上版權(quán)說明;
2.自動(dòng)獲取當(dāng)前文章地址;
3.做了裝飾。
將以下代碼放在頁首Html代碼內(nèi)即可:
<script type="text/javascript"> var setMyBlog = { setCopyright: function() { //設(shè)置版權(quán)信息,轉(zhuǎn)載出處自動(dòng)根據(jù)頁面url生成var info_str = ' <p style="font-family:KaiTi ">作者:<a target="_blank" style="color:#4189C8">多弗朗強(qiáng)哥</a><br>'+'本文為作者原創(chuàng),轉(zhuǎn)載請注明出處:<a style="color:#4189C8" class="uri"></a></p><hr size="1" color="#0000"> ', info = $(info_str), info_a = info.find("a"), url = window.location.href; $(info_a[0]).attr("href","https://www.cnblogs.com/chendeqiang/"); $(info_a[1]).attr("href",url).text(url); $("#cnblogs_post_body").prepend(info); }, setCodeRow: function(){// 代碼行號(hào)顯示var pre = $("pre.sourceCode"); //選中需要更改的部分if(pre && pre.length){ pre.each(function() { var item = $(this); var lang = item.attr("class").split(" ")[1]; //判斷高亮的語言item.html(item.html().replace(/<[^>]+>/g,"")); //將<pre>標(biāo)簽中的html標(biāo)簽去掉item.removeClass().addClass("brush: " + lang +";"); //根據(jù)語言添加筆刷 SyntaxHighlighter.all(); }) } }, setAtarget: function() { // 博客內(nèi)的鏈接在新窗口打開$("#cnblogs_post_body a").each(function(){ this.target = "_blank"; }) }, runAll: function() { /* 運(yùn)行所有方法* setAtarget() 博客園內(nèi)標(biāo)簽新窗口打開* setCopyright() 設(shè)置版權(quán)信息* setCodeRow() 代碼行號(hào)顯示*/ this.setAtarget(); this.setCopyright(); this.setCodeRow(); } } setMyBlog.runAll(); </script>
效果如下:
參考自:https://www.cnblogs.com/gzdaijie/p/5187171.html
-END-
轉(zhuǎn)載于:https://www.cnblogs.com/chendeqiang/p/10193144.html
總結(jié)
以上是生活随笔為你收集整理的博客园自动添加版权说明,自动添加文章链接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: window上mysql的配置文件_wi
- 下一篇: webflux 对url参数的接收处理