漫猫/爱恋/MioBT 生存模式BT下载链接

漫猫/爱恋/MioBT 生存战略模式下为页面添加BT种子下载链接

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         漫猫/爱恋/MioBT 生存模式BT下载链接
// @namespace    http://kisssub.org/
// @version      3.1
// @description  漫猫/爱恋/MioBT 生存战略模式下为页面添加BT种子下载链接
// @author       Kernel
// @match        http://miobt.com/*
// @match        http://www.miobt.com/*
// @match        http://m.miobt.com/*
// @match        http://kisssub.org/*
// @match        http://www.kisssub.org/*
// @match        http://m.kisssub.org/*
// @match        http://comicat.org/*
// @match        http://www.comicat.org/*
// @match        http://m.comicat.org/*
// @grant        none
// ==/UserScript==

(function () {
    if (typeof acgscript_config === 'undefined') {
        acgscript_config = {};
    }

    if (typeof acgscript_config['miobt'] === 'undefined') {
        acgscript_config['miobt'] = {};
    }

    if (typeof acgscript_config['miobt']['4'] === 'undefined') {
        acgscript_config['miobt']['4'] = {
            'api_url': 'http://v2.uploadbt.com',
            'loaded': false,
            'source': 'greasyfork.org'
        };
    }
})();

(function ($) {
    if (acgscript_config['miobt']['4']['loaded']) {
        return false;
    }

    acgscript_config['miobt']['4']['loaded'] = true;

    var log_name = 'acgscript/miobt/bt_download';

    console.log([log_name, {
        'source': acgscript_config['miobt']['4']['source'],
        'loaded': acgscript_config['miobt']['4']['loaded'],
        'api_url': acgscript_config['miobt']['4']['api_url'],
        'mika_mode': Config['mika_mode']['enabled'],
        'in_script': Config['in_script'],
        'platform': Config['user_script']['platform']
    }]);

    if (!Config['mika_mode']['enabled']) {
        return false;
    }

    if (Config['in_script'] !== 'show') {
        return false;
    }

    if (!$('#box_download')) {
        return false;
    }

    var api_url = acgscript_config['miobt']['4']['api_url'];

    var torrent_url = {
        "lite": api_url + '/?r=down&hash=' + Config['hash_id'],
        'full': api_url + '/?r=down&hash=' + Config['hash_id'] + '&name=' + Config['down_torrent_format'].replace('%s', Config['bt_data_title'])
    };

    var magnet_url = {
        'lite': 'magnet:?xt=urn:btih:' + Config['hash_id'],
        'full': 'magnet:?xt=urn:btih:' + Config['hash_id'] + '&tr=' + Config['announce']
    };

    if (Config['user_script']['platform'] == 'desktop') {
        // var html =
        //     '<div class="box">' +
        //     '   <h2 class="title">下载地址</h2>' +
        //     '   <div class="intro basic_info">' +
        //     '   <ul>' +
        //     '       <li><a id="magnet" href="' + magnet_url.full + '">磁链下载</a></li>' +
        //     '       <li><a id="download" href="' + torrent_url.full + '">种子下载</a></li>' +
        //     '       <li><a id="qrcode_magnet" style="cursor: pointer;">磁链扫码</a></li>' +
        //     '       <li><a id="qrcode_download" style="cursor: pointer;">种子扫码</a></li>' +
        //     '   </ul>' +
        //     '   </div>' +
        //     '   <div class="qrcode_enlarged" id="qrcode_magnet_enlarged"  qr_label="磁链扫码" qr_content="' + magnet_url.full + '"></div>' +
        //     '   <div class="qrcode_enlarged" id="qrcode_download_enlarged"  qr_label="种子扫码" qr_content="' + torrent_url.lite + '"></div>' +
        //     '</div>';
        //
        // $('#box_download').append($(html));

        $('#box_download h2.title').text('下载地址');
        $('#magnet').attr('href', magnet_url.full).text('磁链下载');
        $('#download').attr('href', torrent_url.full).text('种子下载');
        $('#qrcode_magnet').removeAttr('href').text('磁链扫码');
        $('#qrcode_download').removeAttr('href').text('种子扫码');
        $('#qrcode_magnet_enlarged').attr('qr_content', magnet_url.full);
        $('#qrcode_download_enlarged').attr('qr_content', torrent_url.lite);

        var register_qrcode_event = function (sel, sel_enlarged) {
            $(sel).click(function () {
                $('.qrcode_enlarged').html('').hide();
                $(sel_enlarged).qrcode({
                    render: "canvas",
                    size: 256,
                    fill: '#0480BE',
                    background: '#FFF',
                    quiet: 1,
                    mode: 2,
                    minVersion: 10,
                    label: $(sel_enlarged).attr('qr_label'),
                    fontname: '"Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif',
                    fontcolor: 'darkorange',
                    text: $(sel_enlarged).attr('qr_content')
                });

                $(sel_enlarged).fadeIn(200);
            });

            $(sel_enlarged).click(function () {
                $(this).hide();
            });
        };

        $(document).ready(function () {
            register_qrcode_event('#qrcode_magnet', '#qrcode_magnet_enlarged');
            register_qrcode_event('#qrcode_download', '#qrcode_download_enlarged');
        });
    }
    else if (Config['user_script']['platform'] == 'mobile') {
        $('#torrent_url').attr('href', torrent_url.full).text('种子下载').click(function () {
            return (prompt('确认下载该种子', torrent_url.full) ? true : false);
        });
        $('#magnet_url').attr('href', magnet_url.full).text('磁力下载').click(function () {
            return (prompt('确认下载磁链', magnet_url.full) ? true : false);
        });
    }
    else {
        return false;
    }
})(jQuery);