MT论坛

为导航栏新添加一个最新发表标签

目前为 2020-04-19 提交的版本。查看 最新版本

// ==UserScript==
// @name         MT论坛
// @namespace    http://tampermonkey.net/
// @description  为导航栏新添加一个最新发表标签
// @version      0.3
// @author       MT-戒酒的李白染
// @icon         https://bbs.binmt.cc/favicon.ico
// @match        *://bbs.binmt.cc/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var ele = document.createElement('li');
    var url = window.location.href;
    ele.id = "latest_publication"
    ele.innerHTML = '<a href="https:\/\/bbs.binmt.cc\/forum.php?mod=guide&view=newthread" hidefocus="true" title="最新发表">最新发表<\/a>';
    document.getElementsByClassName("wp comiis_nvbox cl")[0].children[1].appendChild(ele);
    if(url=='https:\/\/bbs.binmt.cc\/forum.php?mod=guide&view=newthread')
    {
        ele.style.cssText='background: url("https:\/\/cdn2.bbs.binmt.cc\/template\/comiis_mi\/img\/nv_a.png") repeat-x 50% -50px;';

    }
    function ownurl(){
        if(window.location.href.match('bbs.binmt.cc/thread'))
        {
               try{
                var a = document.getElementsByClassName("showhide")[0].innerHTML;
                var b = a.replace(/\s/g,'');
                var d = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
                var e = b.match(d)[0];
                var c = '<a target="_blank" href="'+e+'" style="text-decoration:none;border: 1px solid #e74c3c;color: #c0392b;">'+e+'</a>';
                var f = '="'+e+'"'
                var g = b.match(f);
                if(g)
                {
                    return
                }else{
                    document.getElementsByClassName("showhide")[0].innerHTML = a.replace(e,c);
                }
            }catch(err){
                return
            }

        }else{
            return
        }
    }
    ownurl();

})();