Greasy Fork

Greasy Fork is available in English.

提取磁力

try to take over the world!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         提取磁力
// @namespace    http://www.busjav.cam/forum
// @version      0.1
// @description  try to take over the world!
// @author       zfy
// @match        *
// @require      https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    // 清除数组里面以图片拓展名结尾的
    // 清除数组里面以图片拓展名结尾的
    window.clrURL = function(arr) {
        let result = [];
        let re2 = /\.(png|jpg|gif|jpeg|webp)$/;
        for (let i in arr) {
            if(arr[i].search(re2) == -1) {
                result.push(arr[i])
            }
        }
        return result;
    }
    // 点击按钮,开始收集磁力
    window.divBtnClick = function() {
        if($(".floatWindow").css("visibility") == "hidden") {
            $(".floatWindow").css({"visibility":"visible"});
            let re = /[a-z0-9A-Z\.]{32,40}/g
            let result = $("body").html().match(re)
            let newResult = Array.from(new Set(result)) // 利用ES6的set去重
            let NewNewResult = clrURL(newResult)
            $(".resultNum").html("共有"+NewNewResult.length+"个");
            let tempMagnet = "";
            for(let item of NewNewResult) {
                tempMagnet = tempMagnet +"magnet:?xt=urn:btih:" +item +"\n";
            }
            // --------------------------------------------------------------------收集完毕
            $(".divInput").text(tempMagnet);
            $(".divInput").select();
            document.execCommand('copy');
        }
        else {
            $(".floatWindow").css({"visibility":"hidden"});
        }
    }
    // 隐藏框框
    window.closeWindow = function() {
        $(".floatWindow").css({"visibility":"hidden"});
    }
    // 创建一个按钮
    $("body").append("<button class='divBtn' onclick='divBtnClick()'>点我收集磁力</button>");
    $(".divBtn").css({"background-color":"#00ff5a78", "cursor":"pointer", "border-radius":"50%", "padding":"42px 12px", "font-size":"22px", "outline":"none"});
    $(".divBtn").css({"z-index":"999", "float":"right", "position":"fixed", "right":"10px", "top":"200px", "user-select":"none"});
    // 创建一个输入框
    $("body").append(`
        <div class="floatWindow">
            <button class="closeInput" onclick="closeWindow()">点击关闭</button>
            <h3 class="resultNum"></h3>
            <div><textarea class='divInput'></textarea></div>
        </div>
        `);
    $(".floatWindow").css({"visibility":"hidden", "z-index":"999", "float":"right", "position":"fixed", "right":"500px", "top":"100px", "border":"solid 2px blue", "background-color":"white"});
    $(".closeInput").css({"background-color":"#1b00ff78", "cursor":"pointer", "font-size":"22px", "padding":"5px 12px", "margin":"5px"});
    $(".resultNum").css({"margin":"5px"});
    $(".divInput").css({"width":"450px", "height":"200px", "margin":"5px"});
})();