草榴社区一夜精品磁力搜索

在skrbt网站中搜索资源,复制磁力哈希下载资源,而不是使用那些什么垃圾网盘,大多数资源都能在skrbt网站搜索到。

Od 27.08.2021.. Pogledajte najnovija verzija.

// ==UserScript==
// @name         草榴社区一夜精品磁力搜索
// @namespace    https://greasyfork.org/zh-CN/scripts/431166
// @version      0.3
// @description  在skrbt网站中搜索资源,复制磁力哈希下载资源,而不是使用那些什么垃圾网盘,大多数资源都能在skrbt网站搜索到。
// @author       木羊羽
// @include      https://cl.308x.xyz/*
// @include      https://t66y.com/*
// @include      http://t66y.com/*
// @require      https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.8/clipboard.js    
// @resource css https://www.layuicdn.com/layui/css/layui.css
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @grant        GM_getResourceText
// ==/UserScript==

(async function () {

    GM_addStyle(GM_getResourceText("css"))

    let headers = {
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'zh-CN,zh;q=0.9',
        'dnt': '1',
        'referer': 'https://skrbtca.xyz/',
        'sec-fetch-dest': 'document',
        'sec-fetch-mode': 'navigate',
        'sec-fetch-site': 'same-origin',
        'sec-fetch-user': '?1',
        'upgrade-insecure-requests': '1',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
    }

    function get_url() {

        return new Promise((resolve, reject) => {
            GM_xmlhttpRequest({
                url: `https://skrbtca.xyz/`,
                method: 'get',
                onload: function (response) {
                    let html = $(response.responseText)
                    let targetUrl = html.find('#targetUrl').attr("href")
                    resolve(targetUrl)
                }
            })
        })
    }

    let targetUrl = await get_url()
    targetUrl && (headers.referer = targetUrl)
    let host_url = headers.referer

    function skipCaptcha() {

        const charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
        const randStr = len => {
            let str = '';
            for (let i = 0; i < len; i++) {
                const poz = Math.floor(Math.random() * charSet.length)
                str += charSet.charAt(poz)
            }
            return str
        }
        const token = randStr(100)
        const formatDate = new Date().toJSON().split('.')[0].replace(/\D/g, '')
        const aywcUid = randStr(10) + '_' + formatDate
        const costtime = Math.floor(Math.random() * 1000 + 10001) //必须大于10000
        return new Promise((resolve, reject) => {
            GM_xmlhttpRequest({
                url: `${host_url}anti/recaptcha/v3/verify?token=${token}&aywcUid=${aywcUid}&costtime=${costtime}`,
                method: 'get',
                responType: 'text',
                onload: res => res.status === 200 && res.finalUrl === host_url ? resolve() : reject(),
                onerror: () => reject()
            })
        })
    }
    await skipCaptcha()

    let content = $($("div[class^='tpc_c']")[0])
    let flag = content.find('a:even')
    let reg = /【影片名称】([\s\S]*?)<br>/g
    let title_list = content.html().match(reg)

    GM_xmlhttpRequest({
        method: 'GET',
        url: host_url + 'search?keyword=%E8%A7%A6%E4%B8%8D%E5%8F%AF%E5%8F%8A',
        headers: headers,
        onload: function (response) {
            let doc = $(response.responseText)
            if (doc.find('.sr-only').length) {
                return alert('请更新bt搜索网站referer!')
            }
        }
    })

    for (let i = 0; i < flag.length; i++) {
        let keywords = title_list[i].replace('【影片名称】', '')

        keywords = keywords.replace(':', '')
        keywords = keywords.replace('<br>', '')
        keywords = keywords.replace('[', '')
        keywords = keywords.replace(']', '')

        let search_url = `${host_url}search?keyword=${keywords}`

        GM_xmlhttpRequest({
            method: 'GET',
            url: search_url,
            headers: headers,
            onload: function (response) {

                let data_list = []
                let doc = $(response.responseText)

                let search_results = $(doc.find('.list-unstyled'))
                let count = search_results.length

                if (doc.find('.sr-only').length) {
                } else if (count === 0) {
                } else {
                    count <= 5 ? count : count = 5
                    for (let i = 0; i < count; i++) {
                        let title = $(search_results[i]).children('li')[0].innerText
                        let info = $(search_results[i]).children('li')[1].innerText
                        let href = host_url + $($(search_results[i]).children('li')[0]).children('a').attr("href")
                        data_list.push({
                            title: title,
                            info: info,
                            href: href
                        })
                    }

                    $(flag[i]).before(`<br>title:${keywords}<br>`)


                    for (let k = 0; k < data_list.length; k++) {

                        headers.referer = search_url

                        let content_url = data_list[k].href

                        GM_xmlhttpRequest({
                            method: 'GET',
                            url: content_url,
                            headers: headers,
                            onload: function (response) {

                                let doc = $(response.responseText)

                                try {
                                    data_list[k].magnet = $(doc.find('.list-unstyled')[0]).children('li')[3].innerText.match(/[A-Z0-9]{40,40}$/)[0]
                                }

                                catch (err) {
                                    console.log(headers.referer)

                                    return console.log(`出错啦【${err.message}】`)
                                }

                                $(flag[i]).after(`<br>****************************************************************************************<br>
                                ${data_list[k].title}<br>
                                ${data_list[k].info}<br>
                                <button class="copy layui-btn layui-btn-xs" data-clipboard-text="${data_list[k].magnet}">点击复制磁力哈希</button>`)

                                headers.referer = host_url


                            }
                        })


                    }
                }


            }
        })
    }

    let clipboard = new ClipboardJS('.copy')

    clipboard.on('success', function (e) {
        $(e.trigger).addClass("layui-btn-normal")
        e.clearSelection()
    })


})()