macpeers优化

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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)
})()