给typecho加上友情链接,无需插件

忘了之前在哪里看到了,回头找到原文地址,再加上

思路是这样的,page页面,按格式填入代码:

  1. 友情链接的代码如下:
  2. <ul id="flinks">
  3. <li>域名名称</li>
  4. <li>域名地址</li>
  5. <li>域名图标</li>
  6. <li>描述</li>
  7. <li>域名名称</li>
  8. <li>域名地址</li>
  9. <li>域名图标</li>
  10. <li>描述</li>

然后页面js会把这些内容隐藏掉,然后通过js去分配每一个支点,然后重新打造新的友情链接的列表

演示看这里:https://www.veimoz.com/links.html

js代码如下:

  1. <script>
  2. (function(){
  3. let a =document.getElementById("flinks");
  4. if(a){
  5. let ns = a.querySelectorAll("li");
  6. let nsl = ns.length;
  7. let str ='<div class="post-lists"><div class="post-lists-body" id ="flinksH">';
  8. let bgid = 0;
  9. const bgs =["bg-blue","bg-purple","bg-green","bg-yellow","bg-red","bg-orange"];
  10. for(let i = 0;i<=nsl-4;i+=4){
  11. bgid = Math.floor(Math.random() * 6);
  12. str += (`<div class="post-list-item"><div class="post-list-item-container "><div class="item-label ${bgs[bgid]}"><div class="item-title"><a target="_blank" href="${ns[i+1].innerText}">${ns[i].innerText}</a></div><div class="item-meta clearfix"><div class="item-meta-ico bg-ico-book"style="background: url(${ns[i+2].innerText}) no-repeat;background-size: 40px auto;"></div><div class="item-meta-date">${ns[i+3].innerText}</div></div></div></div></div>`);
  13. }
  14. str+='</div></div><style></style>';
  15. let n1 = document.createElement("div");
  16. n1.innerHTML = str;
  17. a.parentNode.insertBefore(n1,a);
  18. a.style="display: none;";
  19. }else{
  20. console.log('No such id "flinksH"');
  21. }
  22. }())
  23. </script>

css样式代码,放到主题的样式表就可以了

  1. .post-lists { position: relative; display: block; overflow: hidden;}
  2. .post-list-item { float: left; width: 33.3333%; height: auto; padding: 15px; align-items: center;}
  3. .post-list-item .item-title{font-size: 18px;}
  4. .post-list-item a{ color: #fff; border-bottom: 0px solid #00000070;}
  5. .post-list-item-container { position: relative; overflow: hidden; width: 100%; padding: 0; border-radius: 3px; background-color: #fff; -webkit-box-shadow: 0 1px 4px rgba(0,0,0,.04); box-shadow: 0 1px 4px rgba(0,0,0,.04);}
  6. .post-list-item-container .item-label { position: relative; height: 130px; padding: 25px 20px 40px; background-color: #fff;}
  7. .post-list-item-container .item-label.bg-purple .item-title a { color: #fff;}
  8. .post-list-item-container .item-label .item-meta { position: absolute; right: 0; bottom: 0; width: 100%; padding: 0 15px 15px; text-align: right;}
  9. .post-list-item-container .item-label .item-meta .item-meta-ico { display: inline-block; float: right; width: 42px; height: 42px; border: 1px solid #eaeaea; border-radius: 50%;}
  10. .post-list-item-container .item-label.bg-purple .item-meta .item-meta-date { color: #fff;}
  11. .post-list-item-container .item-label .item-meta .item-meta-date { font-size: 12px; position: relative; float: left; padding-left: 5px; text-align:left; text-transform: none; color: #f1f1f1; max-width: 75%; }
  12. .bg-purple { background-color: #bc99c4!important;}
  13. .bg-yellow { background-color: #f9bb3c!important;}
  14. .bg-orange { background-color: #f68e5f!important;}
  15. .bg-red { background-color: #e8583d!important;}
  16. .bg-green { background-color: #46c47c!important;}
  17. .bg-blue { background-color: #6fa3ef!important;}
  18. .bg-grey { background-color: #f7f7f7!important;}
  19. .bg-deepgrey { background-color: rgba(0,0,0,.5)!important;}
  20. .bg-white { background-color: #fff!important;}

具体来说也很简单,可能会有人认为,这样页面就相当于有了2个重复的外链链接,比如14个友情链接,就相当于28个导出链接了(14个是隐藏着),其实js生成的外链对百度来说是无效的,真正意义上页面还是只存在14个友情导出链接,所以就不用担心了

文章由官网发布,如若转载,请注明出处:https://www.veimoz.com/484
6 条评论
1.1w

发表评论

已有 6 条评论

  1. 草根叔     Win 10 /    Chrome
    2020-10-17 17:11

    具体怎么操作,能不能写个具体的教程给小白

    1. 【管理员】Vv     Win 7 /    Chrome
      2020-10-17 17:19

      @草根叔

      js和css写到相关文件里面,然后新建一个页面,内容里面按上面的格式输入,就可以了

      1. ying.     Win 10 /    Chrome
        2021-01-16 19:16

        @Vv

        咋弄阿??笑眼:

      2. 草根叔     Win 10 /    Chrome
        2020-11-06 14:22

        @Vv

        小白求教,CSS和JS的相关文件是那几个?

        1. 【管理员】Vv     Win 7 /    Chrome
          2020-11-06 14:24

          @草根叔

          一般主题都有主js和css,各个主题的设置命名不一定一样

  2. 季常     Win 10 /    Chrome
    2020-08-09 15:39

    找到了!

!