@@ -3,7 +3,7 @@ managerLinks v0.1
33https://github.com/hoothin/UserScripts/tree/master/True%20URL%20downloads/managerLinks.js
44(c) 2017-2017 by Hoothin Wang. All rights reserved.
55*/
6- var resReg = / .* ( ^ m a g n e t | ^ e d 2 k | \. t o r r e n t $ | \. m p 4 $ | \. r a r $ | \. 7 z $ | \. z i p $ | \. r m v b $ | \. m k v $ | \. a v i $ | \. i s o $ | \. m p 3 $ | \. t x t $ | \. e x e $ | \. c h m $ | \. p d f $ | \. p p t $ | \. d o c $ | \. p p t x $ | \. d o c x $ | \. e p u b $ | \. x l s x $ | \. x l s $ | \. f l a c $ | \. w m a $ | \. w a v $ | \. a a c $ | \. a p e $ | \. m i d $ | \. o g g $ | \. m 4 a $ | \. d t s $ | \. d s d $ | \. a p k $ ) .* / i,
6+ var resReg = / .* ( ^ m a g n e t | ^ e d 2 k | \. t o r r e n t $ | \. m p 4 $ | \. r a r $ | \. 7 z $ | \. z i p $ | \. r m v b $ | \. m k v $ | \. a v i $ | \. i s o $ | \. m p 3 $ | \. t x t $ | \. e x e $ | \. c h m $ | \. p d f $ | \. p p t $ | \. d o c $ | \. p p t x $ | \. d o c x $ | \. e p u b $ | \. x l s x $ | \. x l s $ | \. f l a c $ | \. w m a $ | \. w a v $ | \. a a c $ | \. a p e $ | \. m i d $ | \. o g g $ | \. m 4 a $ | \. d t s $ | \. d s d $ | \. a p k $ | \. f l v $ ) .* / i,
77 linksArr = [ ] ,
88 frame ;
99var by = function ( byName , secName ) {
@@ -33,12 +33,16 @@ var by = function(byName, secName) {
3333}
3434
3535function getLinks ( ) {
36- var links = document . querySelectorAll ( 'a' ) ;
3736 [ ] . forEach . call ( document . querySelectorAll ( 'a' ) , function ( link ) {
38- if ( resReg . test ( link . href ) && linksArr . toString ( ) . indexOf ( link . href ) == - 1 ) {
37+ if ( link . className != "whx-a" && resReg . test ( link . href ) && linksArr . toString ( ) . indexOf ( link . href ) == - 1 ) {
3938 linksArr . push ( link . href ) ;
4039 }
4140 } ) ;
41+ [ ] . forEach . call ( document . querySelectorAll ( 'source' ) , function ( link ) {
42+ if ( resReg . test ( link . src ) && linksArr . toString ( ) . indexOf ( link . src ) == - 1 ) {
43+ linksArr . push ( link . src ) ;
44+ }
45+ } ) ;
4246}
4347
4448function showLinkFrame ( callBack , allBtn , selBtn ) {
@@ -47,16 +51,17 @@ function showLinkFrame(callBack,allBtn,selBtn) {
4751 if ( ! allBtn ) allBtn = "全部复制" ;
4852 if ( ! selBtn ) selBtn = "复制选中" ;
4953 if ( ! frame ) {
54+ $ ( '<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' ) ;
5055 frame = $ ( '<div id="managerLinksContent" style="display:none;">
5156 < div style = "height:100%; width:100%; position:fixed; top:0; z-index:99998; opacity:0.3; filter: alpha(opacity=30); background-color:#000;" > </ div >
5257 < 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;" >
5358 < div id = "managerLinksType" style = "width:290px;margin-left:5px;" > </ div >
54- < div > < input id = "managerLinksSortByName" value = "按文件名排序" style = "width: 33.3%;font-size:12px" type = "button" > < input id = "managerLinksSortByUrl" value = "按网址排序" style = "width: 33.3%;font-size:12px" type = "button" > < input id = "managerLinksSortByType" value = "按扩展名排序" style = "width: 33.3%;font-size:12px " type = "button" >
59+ < div class = "sort" > < input id = "managerLinksSortByName" value = "按文件名排序" type = "button" > < input id = "managerLinksSortByUrl" value = "按网址排序" type = "button" > < input id = "managerLinksSortByType" value = "按扩展名排序" type = "button" >
5560 </ div >
56- < div id = "managerLinksLinks" style = "width:100%;overflow:auto;word-wrap:break-word;font-size:12px " > </ div >
57- < div title = "%i代表递增 %n代表文件名" > < input id = "managerLinksPre" style = "width: 48%;font-size:12px" type = "text" placeholder = "批量前缀" > < input id = "managerLinksAfter" style = "width: 48%;font-size:12px " type = "text" placeholder = "批量后缀" >
61+ < div id = "managerLinksLinks" style = "width:100%;overflow:auto;word-wrap:break-word;" > </ div >
62+ < div title = "%i代表递增 %n代表文件名" class = "addTxt" > < input id = "managerLinksPre" type = "text" placeholder = "批量前缀" > < input id = "managerLinksAfter" type = "text" placeholder = "批量后缀" >
5863 </ div >
59- < div > < input id = "managerLinksCopyAll" value = "'+allBtn+'" style = "width: 33.3%;font-size:12px" type = "button" > < input id = "managerLinksCopySel" value = "'+selBtn+'" style = "width: 33.3%;font-size:12px" type = "button" > < input id = "managerLinksClose" value = "关闭" style = "width: 33.3%;font-size:12px " type = "button" >
64+ < div class = "fun" > < input id = "managerLinksCopyAll" value = "'+allBtn+'" type = "button" > < input id = "managerLinksCopySel" value = "'+selBtn+'" type = "button" > < input id = "managerLinksClose" value = "关闭" type = "button" >
6065 </ div >
6166 </ div >
6267 </ div > ');
@@ -99,11 +104,12 @@ function showLinkFrame(callBack,allBtn,selBtn) {
99104 var resultStr = "" , i = 0 ;
100105 linkItems . forEach ( function ( item ) {
101106 i ++ ;
102- if ( item . item [ 0 ] . checked ) {
107+ if ( item . item . children ( "input" ) [ 0 ] . checked ) {
103108 var linkName = decodeURIComponent ( item . linkName ) ;
104109 resultStr += ( pre . replace ( / % i / g, i + "" ) . replace ( / % n / g, linkName ) + item . href + after . replace ( / % i / g, i + "" ) . replace ( / % n / g, linkName ) + "\n" ) ;
105110 }
106111 } ) ;
112+ if ( resultStr != "" )
107113 callBack ( resultStr ) ;
108114 } );
109115 $("#managerLinksClose").click(function() {
@@ -125,7 +131,7 @@ function showLinkFrame(callBack,allBtn,selBtn) {
125131 if ( typeHtml . indexOf ( type ) == - 1 ) {
126132 typeHtml += '<a href="javascript:void(0);">' + type + "</a> " ;
127133 }
128- var linkItem = $ ( '<input type="checkbox" style="float:left;"/><a href="' + link + '" style="width:230px;display:block;overflow:hidden;word-break:keep-all;white-space:nowrap;text-overflow:ellipsis;float:left">' + decodeURIComponent ( linkName ) + '</a><br >' ) ;
134+ var linkItem = $ ( '<div>< input type="checkbox" style="float:left;"/><a href="' + link + '" style="width:230px;display:block;overflow:hidden;word-break:keep-all;white-space:nowrap;text-overflow:ellipsis;float:left">' + decodeURIComponent ( linkName ) + '</a></div >' ) ;
129135 $ ( "#managerLinksLinks" ) . append ( linkItem ) ;
130136 linkItems . push ( {
131137 item : linkItem ,
@@ -141,7 +147,7 @@ function showLinkFrame(callBack,allBtn,selBtn) {
141147 var type = this . innerHTML ;
142148 linkItems . forEach ( function ( item ) {
143149 if ( item . type == type ) {
144- item . item [ 0 ] . checked = ! selected ;
150+ item . item . children ( "input" ) [ 0 ] . checked = ! selected ;
145151 }
146152 } ) ;
147153 } ) ;
0 commit comments