Nyaa Extract Links and Images

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

目前为 2019-11-05 提交的版本。查看 最新版本

// ==UserScript==
// @name Nyaa Extract Links and Images
// @version 0.1
// @description extract links and images from inside the description page to the listing page
// @author JasonC
// @match https://nyaa.si/
// @match https://nyaa.si/?p=*
// @match https://*.nyaa.si/
// @match https://*.nyaa.si/?p=*
// @grant none
// @namespace https://gf.qytechs.cn/users/165799
// ==/UserScript==
var torRows = new Array();
var torlist = document.getElementsByClassName('torrent-list')[0]
for (var i=1;i<torlist.rows.length;i++)
{
	torRows.push(torlist.rows[i]);
    if (i > 10){
        break;}
}

function ExtractImage()
{
	var torRow = torRows.shift();
	var torurl = torRow.getElementsByTagName("A")[1].href;
	var ifrm = document.createElement("IFRAME");
	ifrm.src = torurl;
	ifrm.style.width = "0px";
	ifrm.style.height = "0px";
	ifrm.onload = function() {
	var desc = this.contentDocument.getElementById('torrent-description');
        var LINKs = desc.getElementsByTagName("A");
        while (LINKs.length>0){
            var link = document.createElement("A");
            link.href = LINKs[0].href;
            link.innerHTML = LINKs[0].innerHTML;
            torRow.cells[0].appendChild(document.createElement("br"));
	torRow.cells[0].appendChild(link);
            LINKs[0].parentElement.removeChild(LINKs[0]);
		}
		var IMGs = desc.getElementsByTagName("IMG");
		while (IMGs.length>0){
			var img = document.createElement("IMG");
			img.src = IMGs[0].src;
			img.style.width = "50px";
            torRow.cells[0].appendChild(document.createElement("br"));
			torRow.cells[0].appendChild(img);
            IMGs[0].parentElement.removeChild(IMGs[0]);
		}
		this.parentElement.removeChild(this);
		if (torRows.length > 0){
			ExtractImage();}
	};
	torRow.cells[0].appendChild(ifrm);
}

(function() {
	ExtractImage();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址