// ==UserScript==
// @name 磁力快显
// @namespace http://tampermonkey.net/
// @description 在磁力宝、磁力管家、Skrbt、无极磁链ØMagnet网站的搜索列表增加磁力链接显示,方便下载资源。
// @author zxf10608
// @version 1.9
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @homepageURL https://greasyfork.org/zh-CN/scripts/397490
// @include *://cilibao.biz/*
// @include *://www.ciliguanjia*
// @include *://skrbt*.icu/*
// @include *://*0mag.net/search*
// @grant GM_xmlhttpRequest
// @connect 0mag.net
// @grant GM_setClipboard
// @grant GM_notification
// @run-at document-end
// @compatible chrome
// @license MIT License
// @downloadURL none
// ==/UserScript==
(function() {
var href1 = location.href.indexOf('cilibao');
var href2 = location.href.indexOf('ciliguanjia');
var href3 = location.href.indexOf('skrbt');
var href4 = location.href.indexOf('0mag.net/search');
if (href1 != -1 || href2 != -1 || href3 != -1) {
var magnet2 = function() {
if (href3 != -1) {
$('.common-link:odd').remove();
};
var hrefx = 'a[href*="detail"],a[href*="cili-"]';
$(hrefx).each(function() {
if (href2 != -1 || href3 != -1) {
$(this).attr('href', $(this).attr('href').replace(/cili-|detail\/(\w{5})\//, 'detail/'));
} else {
$('.search-tips,#cps-wrap').hide();
};
var tempLink = $(this).attr('href').split('/detail/');
var magnetHref = 'magnet:?xt=urn:btih:' + tempLink[1].substring(0,40);
$(this).after(' 复制');
$(this).after(' 磁力链接');
});
};
magnet2();
};
//ØMagnet
if (href4 != -1) {
var magnetCall = function(href,callback) {
GM_xmlhttpRequest({
method: "GET",
url: href,
onload: function(data,status) {
if(data.readyState==4 && data.status==200){
var txt = data.responseText;
var hashtemp = txt.split('data=');
var magnetHref =hashtemp[1].substring(0,60);
callback(null,magnetHref);
};
},
onerror: function (error) {//加载失败
callback(error);
},
ontimeout: function (error) {//请求超时
callback(error);
},
});
};
var magnetEl = $('a[href*="/!"]');
console.log('磁力链接有'+magnetEl.length+'个');
$(document).ready(function(){
magnetEl.attr({'target':'_blank','style':'display:inline-block;'});
});
magnetEl.each(function(i) {
var tempLink = $(this).attr('href');
magnetCall(tempLink,function(error,magnetHref) {
if (error) {
console.log('异步加载请求失败');
return
};
magnetEl.eq(i).after(' 复制');
magnetEl.eq(i).after(' 磁力链接');
});
if (i>25){
console.log('磁力链接过多,已停止异步加载');
return false;
};
});
};
// 复制磁力链接
$('body').on('click','.copy', function(event) {
GM_setClipboard($(this).data('href'));
GM_notification({
title:'磁力快显提示:',
text:'磁力链接复制成功!',
timeout:2000,
});
return false;
});
})();