macpeers优化

macpeers自动对下载地址做超链接, 方便点击, 验证码和密码均支持点击复制到剪贴板

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         macpeers优化
// @namespace    https://greasyfork.org/zh-CN/scripts/424268
// @version      0.5
// @description  macpeers自动对下载地址做超链接, 方便点击, 验证码和密码均支持点击复制到剪贴板
// @author       zhenhappy<[email protected]>
// @icon         https://hkmacpeers-1259420093.file.myqcloud.com/favicon.ico
// @match        https://www.macpeers.net/*
// @require      https://unpkg.com/jquery/dist/jquery.slim.min.js
// @require      https://unpkg.com/clipboard/dist/clipboard.min.js
// @license      MIT
// ==/UserScript==

(function() {
    console.log('macpeers>>>>>>>>')
    var t = setInterval(function () {
        try {
            var content = $('.post_content .STYLE2, .post_content .STYLE5')
            if (content.length > 0) {
                console.log('找到下载地址, 正在处理下载链接...')
                var _url, url, _code, code, _password, password
                $.each(content, function( index, value ) {
                    _url = /(http.*?)\s/g.exec($(this).text())
                    console.log(_url)
                    _code = /提取码.*?(\w+)\s*/g.exec($(this).text())
                    _password = /解压密码.*?(\w+)\s*/g.exec($(this).text())
                    if (_url && _url.length > 1 && _code && _code.length > 1) {
                        url = _url[1]
                        console.log('url:', url)
                        code = _code[1]
                        console.log('code:', code)
                        if (code) {
                            $(this).html('链接: <a href="' + url + '#' + code + '" target="' + url + '#' + code + '" rel="nofollow noopener noreferrer">' + url + '</a> 提取码: <span style="cursor: pointer;" id="code" data-clipboard-target="#code">'+code+'</span>')
                            new ClipboardJS('#code')
                        }
                    }
                    if (_password && _password.length > 1) {
                        password = _password[1]
                        console.log('password:', password)
                        if (password) {
                            $(this).html('解压密码:<span style="cursor: pointer;" id="password" data-clipboard-target="#password">'+password+'</span>')
                            new ClipboardJS('#password')
                        }
                    }
                })
            } else throw(Error('未找到元素'))
            clearInterval(t)
            console.log('<<<<<<<<macpeers')
        } catch (e) {
            if ((e.message !== '未找到元素')) console.error('macpeers优化出错', e)
        }
    }, 500)
})()