老司机传说开发版

准备撸一个新的老司机传说,功能慢慢加,欢迎提供建议。尽量不弃坑。

As of 2020-07-24. See the latest version.

// ==UserScript==
// @name        老司机传说开发版
// @namespace   http://www.ocrosoft.com/
// @version     0.105
// @description 准备撸一个新的老司机传说,功能慢慢加,欢迎提供建议。尽量不弃坑。
// @author      ocrosoft
// @match       *://www.liuli.se/*
// @match       *://www.liuli.pl/*
// @match       *://blog.reimu.net/archives/*
// @match       *://pan.baidu.com/s/*
// @match       *://pan.baidu.com/disk/home*
// @icon        https://www.liuli.pl/favicon.ico
// @grant       unsafeWindow
// ==/UserScript==

let prefix = '[老司机传说] ';
function INFO(msg) {
    console.info(prefix + msg);
}
function WARN(msg) {
    console.warn(prefix + msg);
}
function ERROR(msg) {
    console.error(prefix + msg);
}
function ELEM(element) {
    console.log(element);
}

// jQuery
let jquery_cdns = [
    'http://code.jquery.com/jquery-2.1.4.min.js',
    'http://libs.baidu.com/jquery/2.1.4/jquery.min.js',
    'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.min.js'
];
function CheckJQuery() {
    function InsertJQuery(url) {
        let script = document.createElement('script');
        script.src = url;
        document.head.appendChild(script);
        return script;
    }
    function ConverProtocolIfNeeded(url) {
        let is_https = location.href.indexOf('https://') != -1;
        let url_is_https = url.indexOf('https://') != -1;

        if (is_https && !url_is_https) {
            return url.replace('http://', 'https://');
        } else if (!is_https && url_is_https) {
            return url.replace('https://', 'http://');
        }
    }
    function WaitAndCheckJQuery(cdn_index, resolve) {
        if (cdn_index >= jquery_cdns.length) {
            ERROR('无法加载 JQuery,正在退出。');
            resolve(false);
            return;
        }
        let url = ConverProtocolIfNeeded(jquery_cdns[cdn_index]);
        INFO('尝试第 ' + (cdn_index + 1) + ' 个 JQuery CDN:' + url + '。');
        let script = InsertJQuery(url);
        setTimeout(function() {
            try {
                $();
                INFO('已加载 JQuery。');
                resolve(true);
            } catch (exception) {
                WARN('无法访问。');
                script.remove();
                WaitAndCheckJQuery(cdn_index + 1, resolve);
            }
        }, 100);
    }
    return new Promise(function(resolve) {
        try {
            $();
            INFO('已加载 jQuery。');
            resolve(true);
        } catch (exception) {
            INFO('未发现 JQuery,尝试加载。');
            WaitAndCheckJQuery(0, resolve);
        }
    });
}

// 窗口大小发生改变的调用方法
let resize_functions = {};

let sites = [{
    name: '琉璃神社',
    pattern: 'https:\/\/www\.liuli\.(se|pl)\/wp\/\\d+\.html',
    process: function() {
        // 处理磁力链(仅正文)
        function ProcessMagnetInContent() {
            // 提取 HASH
            function GetHashFromMagnet(magnet) {
                return magnet.toLowerCase().replace('magnet:?xt=urn:btih:', '').toUpperCase();
            }
            // 增加一个跳转下载链接的气泡
            function AddBubble(hash_match) {
                // 元素
                let comment_bubble_wrapper = $('#wpd-bubble-wrapper');
                let link_bubble_wrapper = comment_bubble_wrapper.clone();
                link_bubble_wrapper.find('#wpd-bubble-all-comments-count').text(hash_match.length).addClass('od_link_count');
                let link_bubble = link_bubble_wrapper.find('#wpd-bubble-count');
                let svg = $('<svg height="512pt" viewBox="0 -61 512 512" width="512pt" xmlns="http://www.w3.org/2000/svg"><path d="m377 0h-121l-30 37.5 30 37.5h121c33.085938 0 60 26.914062 60 60s-26.914062 60-60 60h-121l-30 37.5 30 37.5h121c74.4375 0 135-60.5625 135-135s-60.5625-135-135-135zm0 0" fill="#18e0ff"></path><path d="m256 120-30 37.5 30 37.5c33.085938 0 60 26.914062 60 60s-26.914062 60-60 60l-30 37.5 30 37.5c74.4375 0 135-60.5625 135-135s-60.5625-135-135-135zm0 0" fill="#13bdf7"></path><path d="m135 195h121v-75h-121c-74.4375 0-135 60.5625-135 135s60.5625 135 135 135h121v-75h-121c-33.085938 0-60-26.914062-60-60s26.914062-60 60-60zm0 0" fill="#18e0ff"></path><path d="m256 75v-75c-74.4375 0-135 60.5625-135 135s60.5625 135 135 135v-75c-33.085938 0-60-26.914062-60-60s26.914062-60 60-60zm0 0" fill="#13bdf7"></path></svg>');
                link_bubble.children('svg').remove();
                link_bubble.append(svg);
                link_bubble_wrapper.css({
                    'left': comment_bubble_wrapper.css('left'),
                    'bottom': parseInt(comment_bubble_wrapper.css('bottom')) + 100 + 'px',
                });
                resize_functions.liuli_resize_bubble_position = function() {
                    link_bubble_wrapper.css('left', comment_bubble_wrapper.css('left'));
                };
                // 链接
                let bubble_message = link_bubble_wrapper.find('#wpd-bubble-add-message').addClass('od_link_message');
                bubble_message.empty().css({'display': 'block', 'text-align': 'left', 'width': 'max-content', 'height': 'auto'});
                $.each(hash_match, function(index, hash) {
                    if (index > 0) {
                        bubble_message.append('<br>');
                    }
                    let link_jump = $('<a style="color:#fff;">定位到链接</a>');
                    let hash_only = GetHashFromMagnet(hash);
                    let link_download = $('<a href="magnet:?xt=urn:btih:' + hash_only + '" style="color:#fff; margin-left: 10px;">' + hash_only + '</a>');
                    link_jump.click(function() {
                        let selector = '#od_link_' + hash_only;
                        // 目标在 toggle 里面
                        if ($('.toggle-box').find(selector).length > 0) {
                            let parent = $(selector).parent();
                            while (parent.length > 0) {
                                if (parent.hasClass('toggle-box')) {
                                    if (parent.css('display') == 'none') {
                                        parent.prev().click();
                                    }
                                    break;
                                }
                                parent = parent.parent();
                            }
                        }
                        $('body, html').animate({scrollTop: $(selector).offset().top}, 500);
                    });
                    let span = $('<span></span>');
                    span.append(link_jump).append(link_download);
                    bubble_message.append(span);
                });
                // 事件
                link_bubble_wrapper.find('#wpd-bubble-count').click(function(event) {
                    let wrapper = $(this).parent();
                    wrapper.addClass('wpd-bubble-hover');
                });
                link_bubble_wrapper.find('#wpd-bubble').find('svg').css('-webkit-transform', 'rotate(45deg)');
                // 关闭只点 SVG,点弹出的链接就不会关闭了
                link_bubble_wrapper.find('#wpd-bubble').find('svg').click(function(event) {
                    let wrapper = $(this).parent().parent();
                    wrapper.removeClass('wpd-bubble-hover');
                });
                comment_bubble_wrapper.after(link_bubble_wrapper);
                // 找到了链接,主动打开一下
                if (hash_match.length > 0) {
                    link_bubble_wrapper.find('#wpd-bubble-count').click();
                }
            }
            // 过滤无效的HASH
            function FilterHash(content, hash_match_raw) {
                let hash_match = [];
                let hash_set = {};

                function IsFound(content, regex) {
                    let match = content.match(regex);
                    if (match && match.length > 0) {
                        return true;
                    }
                    return false;
                }
                $.each(hash_match_raw, function(index, hash) {
                    // 包含前缀,不检查
                    if (IsFound(content, 'magnet:\\?xt=urn:btih:' + hash)) {
                        if (hash_match.indexOf('magnet:?xt=urn:btih:' + hash) == -1) {
                            hash_match.push('magnet:?xt=urn:btih:' + hash);
                        }
                        return;
                    }
                    let regexs = [
                        '\/' + hash, // 前面跟了一个斜杠,可能是目录名
                        hash + '\/', // 后面跟了一个斜杠,可能是目录名
                        hash + '\.', // 后面一个点,可能是文件名
                    ];
                    let is_valid = true;
                    $.each(regexs, function(index_, regex) {
                        if (IsFound(content, regex)) {
                            is_valid = false;
                            return false;
                        }
                    });
                    if (is_valid && hash_match.indexOf(hash) == -1) {
                        hash_match.push(hash);
                    }
                });

                return hash_match;
            }
            // 查找字符串所在的元素
            function FindElementByText(root, text) {
                let result = [];
                let found_in_children = false;
                $.each(root.children(), function(i, child) {
                    let _this = $(child);
                    if (_this.text().indexOf(text) != -1) {
                        let e = FindElementByText(_this, text);
                        if (e.length > 0) {
                            found_in_children = true;
                            result = result.concat(e);
                        }
                    }
                });
                if (!found_in_children) {
                    result.push(root);
                }
                return result;
            }

            let e_content = $('.entry-content');
            let content = e_content.text();
            let hash_match_raw = content.match(/([a-zA-Z0-9]{40})|([a-zA-Z0-9]{32})/g);
            ELEM(hash_match_raw);
            let hash_match = FilterHash(content, hash_match_raw);
            ELEM(hash_match);

            // HASH 替换成老司机链接
            $.each(hash_match, function(index, hash) {
                let replace_text = '';
                let hash_only = GetHashFromMagnet(hash);
                replace_text = '<br><a id="od_link_' + hash_only + '" href="magnet:?xt=urn:btih:' + hash + '">老司机链接</a>(' + hash_only + ')<br>';
                // 不能修改整个 content,会导致 toggle 展不开
                let elements = FindElementByText(e_content, hash);
                $.each(elements, function(i, element) {
                    element.get(0).innerHTML = element.get(0).innerHTML.replace(hash, replace_text);
                });
            });

            AddBubble(hash_match);
        }
        // 处理百度链接(仅评论区,新版链接)
        function ProcessBaiduNetdiskInComment() {
            function GetKeyFromBaiduNetdiskLink(link) {
                if (link.indexOf('/s/') != -1) return link.replace('/s/', '');
                if (link.indexOf('s/') != -1) return link.replace('s/', '');
                return link;
            }
            // 过滤无效的提取链接
            function FilterCommentsKey(e_comments_raw) {
                let e_comments = [];

                $.each(e_comments_raw, function(i, comments) {
                    let e = comments.e.find('.wpd-comment-text:first');
                    let text = e.text();
                    let match = comments.key_match;
                    let keys = [];
                    let code = '';
                    $.each(match, function(i, key) {
                        // 前后有数字或字母
                        if (text.match('[0-9a-zA-Z]' + key) ||
                            text.match(key + '[0-9a-zA-Z]')) {
                            return;
                        }
                        // /s/***
                        if (text.match('\/s\/' + key)) {
                            keys.push('/s/' + key);
                            return;
                        }
                        // s/***
                        if (text.match('s\/' + key)) {
                            keys.push('s\/' + key);
                            return;
                        }
                        // 其他的不管
                        keys.push(key);
                    });
                    if (keys.length == 0) {
                        return;
                    }
                    // 只有一个链接时,检查一下提取码
                    if (keys.length == 1) {
                        let code_match = text.match(/[^a-zA-Z0-9]([a-zA-Z0-9]{4})([^a-zA-Z0-9]|$)/);
                        if (code_match) {
                            code = code_match[1];
                        }
                    }
                    e_comments.push({
                        e: e,
                        keys: keys,
                        code: code,
                    });
                });

                return e_comments;
            }

            let comment_count = parseInt($('#wpd-threads').find('.wpd-thread-info ').find('.wpdtc').text());
            if (comment_count == 0) {
                return;
            }
            let itv = setInterval(function() {
                let e_comment_text = $('.wpd_comment_level-1');
                let e_comments_raw = [];
                if (e_comment_text.length == 0) return;
                clearInterval(itv);
                $.each(e_comment_text, function(i, e_comment) {
                    let key_match = $(e_comment).text().match(/[a-zA-Z0-9-]{23}/g);
                    if (key_match && key_match.length > 0) {
                        e_comments_raw.push({e: $(e_comment), key_match: key_match});
                    }
                });
                ELEM(e_comments_raw);
                let e_comments = FilterCommentsKey(e_comments_raw);
                ELEM(e_comments);

                let e_link_count = $('.od_link_count');
                let e_link_message = $('.od_link_message');
                let link_count_now = parseInt(e_link_count.text());
                $.each(e_comments, function(i, comment) {
                    let e = comment.e;
                    let keys = comment.keys;
                    let code = comment.code;

                    for (let key_id = 0; key_id < keys.length; ++key_id) {
                        if (link_count_now > 0) {
                            e_link_message.append('<br>');
                        }
                        let key = keys[key_id];
                        let span = $('<span></span>');
                        let link_jump = $('<a style="color:#fff;">定位到评论</a>');
                        let key_only = GetKeyFromBaiduNetdiskLink(key);
                        let code_text = (code == '' ? '(无提取码)' : '(' + code + ')');
                        let link_download = $('<a target="_blank" href="https://pan.baidu.com/s/' + key_only + '#' + code + '" style="color:#fff; margin-left: 10px;">' + key_only + code_text + '</a>');
                        link_jump.click(function() {
                            $('body, html').animate({scrollTop: e.offset().top}, 500);
                        });
                        span.append(link_jump).append(link_download);
                        e_link_message.append(span);
                        link_count_now += 1;
                    }
                });
            }, 100);
        }

        ProcessMagnetInContent();
        ProcessBaiduNetdiskInComment();
    },
}, {
    name: '灵梦御所',
    pattern: 'https:\/\/blog.reimu.net\/*',
    process: function() {
        // 展开隐藏内容
        function ExpandHideContent() {
            function ResetBtnPosition() {
                let btn = $('#od_link_btn');
                let margin_right = parseInt($('#main').children('article').css('margin-right'));
                let left = $('#main').offset().left + parseInt($('#main').css('width')) - margin_right;
                if (margin_right == 0) {
                    left -= parseInt($('#main').children('article').children('header').css('padding-right'));
                }
                let top = parseInt($('#main').css('padding-top'));
                if ($('.secondary-toggle').css('display') == 'block') {
                    top += parseInt($('.sidebar').css('height'));
                }
                btn.css({
                    'left': left + 'px',
                    'top': top + 'px',
                });
            }

            let e_hide_content = $('.entry-content').find('pre');
            let btn = $('<button id="od_link_btn" style="position: fixed; top: 0px; left: 0px;">前往并展开隐藏内容</button>');
            btn.click(function() {
                e_hide_content.css('display', 'block');
                $('body, html').animate({scrollTop: $(e_hide_content).offset().top}, 500);
            });
            $('body').append(btn);
            ResetBtnPosition();

            resize_functions.reimu_resize_btn_position = ResetBtnPosition;
        }
        // 磁力链接
        function ProcessMagnetInContent() {
            // TODO
        }
        // 秒传链接
        function ProcessFastLinkInContent() {
            let e_content = $('.entry-content').find('pre');
            let content = e_content.text();
            let link_match = content.match(/[0-9A-F]{32}#[0-9A-F]{32}#\d+#.*\n/g);
            ELEM(link_match);

            $.each(link_match, function(i, link) {
                let e = e_content.get(0);
                let encoded = encodeURIComponent(link);
                let replace_html = '<a target="_blank" style="color: #55c3dc;" href="https://pan.baidu.com/disk/home#/all?path=%2F&vmode=list&mc=' + encoded + '">前往百度网盘</a>' + link + '<br>';
                e.innerHTML = e.innerHTML.replace(link, replace_html);
            });
        }

        ExpandHideContent();
        ProcessMagnetInContent();
        ProcessFastLinkInContent();
    },
}, {
    name: '百度网盘-主页-秒传',
    pattern: 'https:\/\/pan.baidu.com\/disk\/home.*&mc=',
    process: function() {
        // 加载秒传链接
        function LoadFastLink() {
            let detect_count = 0;
            let itv = setInterval(function() {
                let href = location.href;
                let match = href.match(/&mc=([^&#]+)/);
                if (!match) {
                    clearInterval(itv);
                    ERROR('找不到秒传链接!');
                    return;
                }
                let fast_link = decodeURIComponent(match[1]);
                let btn = $('#fast_link_btn');
                if (btn.length == 0) {
                    if (++detect_count >= 50) {
                        ERROR('未安装秒传插件,即将退出。');
                        INFO('需要安装:https://greasyfork.org/zh-CN/scripts/397324');
                        clearInterval(itv);
                        return;
                    }
                    if (detect_count % 10 == 0) {
                        WARN('未安装秒传插件,剩余尝试次数:' + (50 - detect_count));
                    }
                    return;
                }
                clearInterval(itv);
                btn.click();
                setTimeout(function() {
                    $('.swal2-textarea').val(fast_link);
                    //$('.swal2-confirm').click();
                }, 100);
            }, 100);
        }

        LoadFastLink();
    },
}];

CheckJQuery().then(function(success) {
    if (!success) {
        return;
    }

    let url = location.href;
    $.each(sites, function(index, site) {
        if (!url.match(site.pattern)) {
            return;
        }
        INFO(site.name);
        site.process();

        return false;
    });

    $(window).resize(function() {
        $.each(resize_functions, function(name, func) {
            func();
        });
    });
});

//执行函数
/*function a(){
    'use strict';
    //灵梦御所
    if(host=="blog.reimu.net"){
        var titleTime;
        if(boxON[1])addBox();
        //开启老司机模式
        if(ifshow()){
            var pre = document.getElementsByTagName('pre');
            for(var rmi=0;rmi<pre.length;rmi++){
                if (pre[rmi]) pre[rmi].style.display = 'block';
                var textrei=pre[rmi].innerHTML;
                if(textrei){
                    var cilirei=textrei.match(/magnet:?[^\n"]+/);
                    pre[rmi].innerHTML=textrei.replace(cilirei,'<a href="'+cilirei+'">'+cilirei+'</a>');
                }
            }
        }
        //添加直接跳转到下载链接的按钮
        var oD_box=document.createElement("div");
        oD_box.style.zindex="999999";
        oD_box.id="goToDownload";
        oD_box.style="position:fixed;top:60px;right:0px;width:40px;transition: all 0.2s ease;white-space:nowrap;z-index:99998";
        var oD_button=document.createElement("button");
        oD_button.id="goToDownload_button";
        oD_button.type="button";
        oD_button.innerHTML="前往<br/>下载";
        oD_button.style="padding: 4px 0px; position: absolute; top: -1px; right: 0px; width: 40px; height: auto;";
        oD_button.onclick=function (){
            if(document.getElementsByTagName('pre').length>1)alert("下载链接可能不止一个,将跳转到第一个!");
            document.getElementsByTagName('pre')[0].scrollIntoView();
        };
        oD_box.appendChild(oD_button);
        document.body.appendChild(oD_box);
    }
    //调整跳转链接
    else if(host.indexOf('hacg')!=-1||host.indexOf('llss')!=-1||host.indexOf('liuli')!=-1||host.indexOf('tianshit')!=-1){//琉璃神社\天使二次元
        if((host.indexOf('hacg')!=-1 || host.indexOf('llss')!=-1 || host.indexOf('liuli')!=-1)&&boxON[0])addBox();
        if(host.indexOf('tianshit')!=-1&&boxON[4])addBox();
        var aaa=$(".entry-title a");
        for(var j=0;j<aaa.length;j++){
            var ax=aaa[j];
            var dir=ax.href.indexOf(':');
            ax.href="https"+ax.href.substring(dir);
        }
        //调整神秘代码
        var toogle = document.getElementsByClassName('toggle-box')[0];
        if (toogle) toogle.style.display = 'block';
        var oldDriver = document.getElementsByClassName('entry-content')[0];
        if(host.indexOf('tianshit')!=-1)oldDriver=document.getElementsByClassName('article-content')[0];
        var childDriver = oldDriver.childNodes;
        for (var i = childDriver.length - 1; i >= 0; i--){
            var takeMe = childDriver[i].textContent.match(/(\w{40})|(([A-Za-z0-9]{2,39})( ?)[\u4e00-\u9fa5 ]{2,}( ?)+(\w{2,37})\b)/g);
            if (takeMe){
                for (j = 0; j < takeMe.length; ++j){
                    var has = takeMe[j].toString().replace(/(\s|[\u4e00-\u9fa5])+/g, '').trim();
                    if (has.length >= 40){
                        var fuel = "<a href='magnet:?xt=urn:btih:" + has + "'>老司机链接</a>"+"("+has+")";
                        if(childDriver[i].innerHTML)
                            childDriver[i].innerHTML = childDriver[i].innerHTML.toString().replace(takeMe[j], fuel);
                        else if(childDriver[i].parentElement)
                            if(childDriver[i].parentElement.innerHTML)
                                childDriver[i].parentElement.innerHTML=childDriver[i].parentElement.innerHTML.replace(takeMe[j], fuel);
                    }
                }
            }
            else{
                takeMe=childDriver[i].textContent.match(/(\w{32})|(([A-Za-z0-9]{2,31})( ?)[\u4e00-\u9fa5 ]{2,}( ?)+(\w{2,29})\b)/g);
                if(takeMe){
                    for (j = 0; j < takeMe.length; ++j){
                        var has2 = takeMe[j].toString().replace(/(\s|[\u4e00-\u9fa5])+/g, '').trim();
                        if (has2.length >= 32){
                            var fuel2 = "<a href='magnet:?xt=urn:btih:" + has2 + "'>老司机链接</a>"+"("+has2+")";
                            childDriver[i].innerHTML = childDriver[i].innerHTML.toString().replace(takeMe[j], fuel2);
                        }
                    }
                }
            }
        }
        //小八链接
        var buDang=document.getElementsByClassName('comment-content');
        for (i in buDang){
            if(buDang[i].innerHTML){
                buDang[i].innerHTML=buDang[i].innerHTML.replace(/b?\/?s?\/?\b(\w{8})\b/g,"<a href='http://pan.baidu.com/s/$1'>百度网盘</a>");
            }
        }
    }
    //百度云填写验证码
    else{
        var sCode = hash.slice(1).trim();
        if(sCode==='')return;
        setTimeout (function (){
            codeBox = $('.pickpw').find('input');
            btnOk = $('.pickpw').find('.g-button');
            if(codeBox)
            {
                codeBox.val(sCode);
                btnOk.click();
            } else {
                var codeBox = $(conf.code),btnOk = $(conf.btn);
                codeBox.val(sCode);
                if (conf.preSubmit)
                    if (conf.preSubmit (codeBox, btnOk))
                        return ;
                btnOk.click();
            }
        }, 10);
    }
})();
var hostName = location.host.match(/\w+\.\w+$/)[0].toLowerCase();
var conf = site[hostName];
var HostArr = [];
for(var i in site) HostArr.push(i);
var HostExp = new RegExp(HostArr.join("|"),'i');
if(site.JumpUrl[host]){
    site.JumpUrl[host].each(function(){
        $(this).attr({'href':$(this).text(),'target':'blank'});
    });
}
//跳转(点击链接、前进后退)时开启老司机模式
function lsjmodeON(){
    if(urls.indexOf("archives")!=-1){
        var pret = document.getElementsByTagName('pre')[0];
        if(pret)pret.style.display='inline';//文章页跳转文章页特殊处理
    }
    if(urls==location.href){
        var pret2 = document.getElementsByTagName('pre')[0];
        if(pret2)pret2.style.display='block';//文章页跳转文章页特殊处理
        return;
    }
    $("#attention").remove();
    urls=location.href;
    var re=urls.indexOf("archives");
    if(re!=-1){
        var pre = document.getElementsByTagName('pre')[0];
        var trytime=0;
        var itval=setInterval(function (){
            var pre = document.getElementsByTagName('pre')[0];
            trytime+=1;
            if(trytime==40)clearInterval(itval);
            if(pre){
                if(pre.style.display!='inline'){
                    if(ifshow()){
                        var prex = document.getElementsByTagName('pre');
                        for(var rmi=0;rmi<prex.length;rmi++)
                            if (prex[rmi]) prex[rmi].style.display = 'block';
                        //pre.style.display='block';
                        clearInterval(itval);
                    }
                    else clearInterval(itval);
                }
            }
        },500);
    }
}
//监控点击事件
$('body').on('click', 'a', function (){
    if(host=="blog.reimu.net")lsjmodeON();
    //整合提取码和链接
    if(aiON===0)return;
    var target=this;
    if(this.hash) return;
    if(HostExp.test(this.href)&&!/(?:eyun|tieba)\.baidu\.com/i.test(this.href)){
        if(target.nextSibling&&site['codeRule'].test(target.nextSibling.textContent.trim())){
            if(!/#/i.test(target.href)) target.href+='#'+extCode(target.nextSibling);}
        else{
            var cajhc=target.nextSibling.data;
            if(!cajhc)cajhc=target.nextSibling.text;
            if(cajhc.indexOf(":")!=-1){
                target.href+='#'+cajhc.substring(cajhc.indexOf(":")+1,cajhc.indexOf(":")+3);
            }
            else target.href+='#8酱';
        }
    }
});
//提取码
function extCode(obj){
    text=obj.textContent.trim();
    var rule=new RegExp('(?:提取|访问)[码碼]?\s*[:: ]?\\s*([a-z\\d]{4})','i');
    return rule.test(text)?text.match(rule)[1]:text.match(site['codeRule'])[1];
}
//老司机快捷键,并移除重口味提示
jQuery(document).keypress(function(e){
    if(odON===0)return;//快捷键无效
    if(e.ctrlKey && e.which == 13 || e.which == 10) {
        var pre = document.getElementsByTagName('pre');
        for(var rmi=0;rmi<pre.length;rmi++)
            if (pre[rmi]) pre[rmi].style.display = 'block';
        $("#attention").remove();
    }
});
//支持前进后退
jQuery(document).ready(function ($) {
    if (window.history && window.history.pushState) {
        $(window).on('popstate', function () {
            var hashLocation = location.hash;
            var hashSplit = hashLocation.split("#!/");
            var hashName = hashSplit[1];
            if (hashName !== '') {
                var hash = window.location.hash;
                if (hash === '') lsjmodeON();
            }
        });
    }
});*/