managerLinks

manager download links

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/26615-managerlinks/code/managerLinks.js?version=186539

function getLinks(){[].forEach.call(document.querySelectorAll("a"),function(e){"whx-a"!=e.className&&(specialUrl.test(e.href)||!simplefilter.test(e.href)&&resReg.test(e.href))&&-1==linksArr.indexOf(e.href)&&linksArr.push(e.href)}),[].forEach.call(document.querySelectorAll("source"),function(e){(specialUrl.test(e.href)||!simplefilter.test(e.href)&&resReg.test(e.href))&&-1==linksArr.indexOf(e.src)&&linksArr.push(e.src)})}function showLinkFrame(e,n,i){var t=[],a="类型:";return n||(n="全部复制"),i||(i="复制选中"),frame||($("<style>#managerLinksContent input{border-width:2px;border-style:outset;border-color:buttonface;border-image:initial;font-size:12px}#managerLinksBody>.sort>input{width:33.3%}#managerLinksBody>.addTxt>input{width: 48%;}#managerLinksBody>.fun>input{width: 33.3%;}#managerLinksLinks>div{width:100%;height:20px;overflow:hidden}</style>").appendTo("head"),frame=$('<div id="managerLinksContent" style="display:none;">\n		<div style="height:100%; width:100%; position:fixed; top:0; z-index:99998; opacity:0.3; filter: alpha(opacity=30); background-color:#000;"></div>\n		<div id="managerLinksBody" style="width:300px;height:300px;position:fixed;left:50%;top:50%;margin-top:-150px;margin-left:-150px;z-index:99998;background-color:#ffffff;border:1px solid #afb3b6;border-radius:10px;opacity:0.95;filter:alpha(opacity=95);box-shadow:5px 5px 20px 0px #000;">\n			<div id="managerLinksType" style="width:290px;margin-left:5px;"></div>\n			<div class="sort"><input id="managerLinksSortByName" value="按文件名排序" type="button"><input id="managerLinksSortByUrl" value="按网址排序" type="button"><input id="managerLinksSortByType" value="按扩展名排序" type="button">\n			</div>\n			<div id="managerLinksLinks" style="width:100%;overflow:auto;word-wrap:break-word;"></div>\n			<div title="%i代表递增 %n代表文件名" class="addTxt"><input id="managerLinksPre" type="text" placeholder="批量前缀"><input id="managerLinksAfter" type="text" placeholder="批量后缀">\n			</div>\n			<div class="fun"><input id="managerLinksCopyAll" value="'+n+'" type="button"><input id="managerLinksCopySel" value="'+i+'" type="button"><input id="managerLinksClose" value="关闭" type="button">\n			</div>\n		</div>\n		</div>'),$(document.body).append(frame),$("#managerLinksSortByName").click(function(){$("#managerLinksLinks").html(""),t.sort(by("linkName","href")),t.forEach(function(e){$("#managerLinksLinks").append(e.item)})}),$("#managerLinksSortByUrl").click(function(){$("#managerLinksLinks").html(""),t.sort(by("href","type")),t.forEach(function(e){$("#managerLinksLinks").append(e.item)})}),$("#managerLinksSortByType").click(function(){$("#managerLinksLinks").html(""),t.sort(by("type","href")),t.forEach(function(e){$("#managerLinksLinks").append(e.item)})}),$("#managerLinksCopyAll").click(function(){var n=$("#managerLinksPre").val(),i=$("#managerLinksAfter").val(),a="",r=0;t.forEach(function(e){r++;var t=decodeURIComponent(e.linkName);a+=n.replace(/%i/g,r+"").replace(/%n/g,t)+e.href+i.replace(/%i/g,r+"").replace(/%n/g,t)+"\n"}),e(a)}),$("#managerLinksCopySel").click(function(){var n=$("#managerLinksPre").val(),i=$("#managerLinksAfter").val(),a="",r=0;t.forEach(function(e){if(r++,e.item.children("input")[0].checked){var t=decodeURIComponent(e.linkName);a+=n.replace(/%i/g,r+"").replace(/%n/g,t)+e.href+i.replace(/%i/g,r+"").replace(/%n/g,t)+"\n"}}),""!=a&&e(a)}),$("#managerLinksClose").click(function(){frame.hide()}),$("#managerLinksContent>div")[0].onclick=function(){frame.hide()}),getLinks(),0==linksArr.length?void e():($("#managerLinksLinks").html(""),linksArr.forEach(function(e){var n=e.replace(resReg,"$1"),i=-1==n.indexOf(".")?e:e.replace(/.*\/([^\/]+)$/i,"$1");-1==a.indexOf(n)&&(a+='<a href="javascript:void(0);">'+n+"</a> ");var r=$('<div><input type="checkbox" style="float:left;"/><a href="'+e+'" style="width:230px;display:block;overflow:hidden;word-break:keep-all;white-space:nowrap;text-overflow:ellipsis;float:left">'+decodeURIComponent(i)+"</a></div>");$("#managerLinksLinks").append(r),t.push({item:r,href:e,type:n,linkName:i})}),$("#managerLinksType").html(a),$("#managerLinksType>a").click(function(){var e="underline"==this.style.textDecoration;this.style.textDecoration=e?"":"underline";var n=this.innerHTML;t.forEach(function(i){i.type==n&&(i.item.children("input")[0].checked=!e)})}),frame.show(),$("#managerLinksLinks").height($("#managerLinksBody").height()-$("#managerLinksType").height()-3*$("#managerLinksSortByName").height()-20),$("#managerLinksBody").hide(),void $("#managerLinksBody").show())}var specialUrl=/^magnet|^ed2k/i,simplefilter=/\.php|\.htm|\.jsp|\.asp|\/[^\.]+$/i,resReg=/.*(^magnet|^ed2k|\.torrent$|\.mp4$|\.rar$|\.7z$|\.zip$|\.rmvb$|\.mkv$|\.avi$|\.iso$|\.mp3$|\.txt$|\.exe$|\.chm$|\.pdf$|\.ppt$|\.doc$|\.pptx$|\.docx$|\.epub$|\.xlsx$|\.xls$|\.flac$|\.wma$|\.wav$|\.aac$|\.ape$|\.mid$|\.ogg$|\.m4a$|\.dts$|\.dsd$|\.apk$|\.flv$).*/i,linksArr=[],frame,by=function(e,n){var i=function(e,n,i){var t,a;if("object"==typeof e&&"object"==typeof n&&e&&n)return t=e[i],a=n[i],t===a?0:typeof t==typeof a?a>t?-1:1:typeof a>typeof t?-1:1;throw"error"};return function(t,a){var r=i(t,a,e);return n&&0==r&&(r=i(t,a,n)),r}};Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var n=-1,i=0,t=this.length;t>i;i++)this[i]==e&&(n=i);return n});