1337x Extract Links and Images

extract links and images from inside the description page to the listing page

当前为 2023-06-11 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name 1337x Extract Links and Images
// @version 1.2
// @description extract links and images from inside the description page to the listing page
// @author JasonC
// @match https://1337x.to/
// @match https://1337x.to/*
// @grant none

// @namespace https://greasyfork.org/users/165799
// ==/UserScript==

var pause = true;
var torRows = new Array();
var torlist = document.getElementsByClassName('table-list-wrap')[0].children[0];

function FilterRows()
{
    var filter = parseInt(prompt("Minimum Seeds","-1"));
    if (!isNaN(filter) && filter > 0){
        for(var i=1;i<torlist.rows.length;i++){
            if (parseInt(parseInt(torlist.rows[i].cells[1].innerText)) < filter) {
                torlist.deleteRow(i);i--;
            }
        }
    }
    filter = parseInt(prompt("Minimum Leeches","-1"));
    if (!isNaN(filter) && filter > 0){
        for(var j=1;j<torlist.rows.length;j++){
            if (parseInt(parseInt(torlist.rows[j].cells[2].innerText)) < filter) {
                torlist.deleteRow(j);j--;
            }
        }
    }
    for (var l=1;l<torlist.rows.length;l++)
    {
        torRows.push(torlist.rows[l]);
    }
}

function ExtractImage()
{
    if (pause){return;}
	var torRow = torRows.shift();
    torRow.cells[0].style.overflow = "auto";
    torRow.cells[0].style.maxWidth = "400px";
    torRow.cells[1].style.verticalAlign = "top";
	var torurl = torRow.cells[0].children[1].href;
    console.log(torurl);
    $.get(torurl, function (html) {
        if (html) {
            try
            {
                var UsedArr = new Array();
                $(html).find("#description").find("A").each(function() {
                    UsedArr.push($(this)[0].outerHTML);
                    var link = document.createElement("A");
                    link.style.maxWidth = "400px";
                    link.href = $(this).attr('href');
                    link.innerHTML = $(this).html();
                    torRow.cells[0].appendChild(document.createElement("br"));
                    torRow.cells[0].appendChild(link);
                    var IMGs = link.getElementsByTagName("IMG");
                    for (var i = 0;i<IMGs.length;i++)
                    {
                        if (IMGs[i].attributes["data-original"])
                            IMGs[i].src = IMGs[i].attributes["data-original"].value;
                    }
                });
                $(html).find("#description").find("IMG").each(function() {
                    var imgHTML = $(this)[0].outerHTML;
                    var SkipThis = false;
                    for(var i=0;i<UsedARR.length;i++)
                    {
                        if (UsedARR[i].indexOf(imgHTML) != -1){
                            SkipThis = true;
                        }
                    }
                    if (!SkipThis)
                    {
                        var img = document.createElement("IMG");
                        img.src = $(this).attr('data-original');
                        img.style.maxWidth = "400px";
                        torRow.cells[0].appendChild(document.createElement("br"));
                        torRow.cells[0].appendChild(img);
                    }
                });
            }
            catch(e){}
            finally
            {
                //this.parentElement.removeChild(this);
                if (torRows.length > 0){
                    ExtractImage();}
            }
        }
    },'html');
}

(function() {
    var MainBtn = document.createElement('INPUT');
    MainBtn.type = 'button';
    MainBtn.style.position = 'fixed';
    MainBtn.style.top = '10px';
    MainBtn.style.left = '10px';
    MainBtn.style.zIndex = "9999";
    MainBtn.value = 'Start';
    MainBtn.onclick = function() {
        pause = !pause;
        if (pause){
            MainBtn.value = "Stop";
        }
        else{
            MainBtn.value = "Start";
        }
        FilterRows();
        ExtractImage();
    };
    document.body.appendChild(MainBtn);
})();