今年一定島 自動下載圖片

汲汲營營大報社

  1. // ==UserScript==
  2. // @name 今年一定島 自動下載圖片
  3. // @description 汲汲營營大報社
  4. // @namespace https://gf.qytechs.cn/zh-TW/scripts/449572
  5. // @author 稻米
  6. // @version 2022.11.27.0051.build16299
  7. // @grant none
  8.  
  9. // @include *://*.komica.org/00/*
  10. // @include *://*.komica.org/00/*
  11. // @exclude *://*.komica.org/00/src/*
  12. // @exclude *://*.komica.org/00/thumb/*
  13. // @exclude *.jpg
  14. // @exclude *.png
  15. // @exclude *.webm
  16. // @license WTFPL
  17.  
  18. // ==/UserScript==
  19.  
  20. $(document).ready(function() {
  21. //poi();
  22. poi();
  23. });
  24.  
  25.  
  26. function poi(){ //只在回應模式套用
  27. //console.log( document.styleSheets );
  28. //console.log(window.location.href);
  29. var tmp=window.location.href;
  30. tmp=tmp.match("\\?res=");
  31. //window.location.href.match("\\?res=")
  32. //console.log(tmp);
  33. if(tmp){
  34. //沒事
  35. }else{
  36. //console.log('非回應');
  37. return 0;//不正確 中止
  38. }
  39.  
  40. if( $('div.thread').length == 1 ){
  41. //沒事
  42. }else{
  43. //回應模式只有一串討論串
  44. return 0;//不正確 中止
  45. }
  46.  
  47.  
  48. var FFF=$('body').attr('poi220815');
  49. if( FFF == 1 ){
  50. return 0;//只執行一個腳本 中止
  51. }else{
  52. $('body').attr('poi220815','1');
  53. }
  54.  
  55. poi建立啟動按鈕();//
  56.  
  57. }
  58.  
  59.  
  60. function poi建立啟動按鈕(){ //建立啟動按鈕
  61. //console.log(arguments.callee.name); //poi2
  62. //$("#threads").before('before');
  63. $(".thread").before('<poi><button type="reset">自動下載</button></poi>');
  64. $("poi >button:contains('自動下載')").click(function(){
  65. poi建立控制台();
  66. });
  67. //
  68.  
  69. }//poi2(){
  70.  
  71. function poi建立控制台(){ //建立控制台
  72. var FFF=$('#poi220814box');
  73. if( FFF.length > 0 ){
  74. return 0;//只產生一個控制台 中止
  75. }else{
  76. //沒事
  77. }
  78.  
  79.  
  80. $('.thread').prepend('<div id="poi220814box">未完成</div>');
  81. //$('#poi220814a').attr('style','');
  82. $('#poi220814box').css({
  83. 'background':'rgb(200,200,200)',
  84. 'color':'rgb(100,100,100)',
  85. 'text-align':'initial',
  86. 'width':'400px',
  87. 'height':'400px',
  88. 'overflow':'auto',
  89. });
  90. $('#poi220814box').text('');
  91.  
  92. $('#poi220814box').append('<button type="reset" id="poi220814f"> 標示樓層</button><br/>');
  93. $("#poi220814f").click(function(){
  94. poi標示樓層();
  95. });
  96.  
  97. $('#poi220814box').append('<input type="text" size="8" value="0,1,2,3-10" placeholder id="poi220814rgi"><button type="reset" id="poi220814rg">輸入範圍</button><br/>');
  98. $("#poi220814rg").click(function(){
  99. poi輸入範圍();
  100. });
  101.  
  102.  
  103. $('#poi220814box').append('<img id="poi220815img01"><a id="poi220815aa01" href="#">†</a><br/>');
  104. $('#poi220815img01').css({
  105. 'width':'100px',
  106. 'height':'100px',
  107. });
  108. $('#poi220815aa01').css({
  109. 'width':'100px',
  110. 'height':'100px',
  111. });
  112. //'border-right':'10px solid red',
  113.  
  114. $('#poi220814box').append('<div id="poi220815m">訊息</div><br/>');
  115. $('#poi220815m').css({
  116. 'display':'block',
  117. 'font-family':'monospace',
  118. 'white-space':'pre',
  119. });
  120.  
  121.  
  122.  
  123. }//
  124.  
  125. function poi輸入範圍(){ //輸入範圍
  126. //console.log( 'poi輸入範圍' );
  127. var FFF='';
  128. FFF=$('#poi220814rgi').val();
  129. //console.log( FFF );
  130. FFF=FFF.split(',');//字串轉陣列
  131. //console.log( FFF );
  132. var str_ary=FFF;
  133. str_ary.forEach(function( item,index ){//遍歷元素
  134. //console.log( item,index );
  135. var aa=item.search("-");
  136. //console.log( aa );
  137. if(aa != -1){
  138. //console.log( 'yy' );
  139. var aa2=item.split('-');
  140. //console.log( aa2 );
  141. var str='';
  142. if(aa2[0]==''){str='skip';}
  143. if(aa2[1]==''){str='skip';}
  144. if(str=='skip'){
  145. $('#poi220815m').append('<br/>輸入範圍 錯誤');
  146. }else{
  147. //console.log( '???' );
  148. aa2[0]=parseInt(aa2[0]);
  149. aa2[1]=parseInt(aa2[1]);
  150. //console.log( aa2 );
  151. for(let i = aa2[0]; i <= aa2[1]; i++) {
  152. //console.log( i );
  153. str_ary.push(i);
  154. }//for
  155. //delete str_ary[index];//處理過的元素就刪除
  156. }
  157. //console.log( str_ary );
  158.  
  159. }//if
  160. });//foreach
  161. //
  162. poi輸入範圍2(str_ary);
  163.  
  164.  
  165. }//輸入範圍
  166. function poi輸入範圍2(in1){
  167. var str_ary=in1;
  168. //
  169. str_ary.forEach(function( item,index ){//遍歷元素
  170. str_ary[index]=parseInt(item);//轉換成整數
  171. });
  172. //console.log( FFF );
  173.  
  174. str_ary=str_ary.filter(function(item,index){
  175. //console.log( FFF );
  176. //var found=item.isInteger();
  177. if( parseInt(item) === item ){return true;}//留下整數
  178. });
  179.  
  180. str_ary.sort(function(a, b){return a - b});//排序 //由小到大
  181.  
  182. str_ary.forEach(function( item,index ){//遍歷元素
  183. str_ary[index]=parseInt(item);//轉換成整數
  184. });
  185.  
  186. str_ary.forEach(function( item,index ){//遍歷元素
  187. var found = str_ary.indexOf( item );
  188. if(found == index){
  189. //沒事
  190. }else{
  191. delete str_ary[index];//刪除
  192. }
  193. });
  194.  
  195. //console.log( str_ary );
  196.  
  197. str_ary=str_ary.filter(function(item,index){
  198. //console.log( FFF );
  199. //var found=item.isInteger();
  200. if( parseInt(item) === item ){return true;}//留下整數
  201. });
  202.  
  203. //console.log( str_ary );//使用者輸入的範圍
  204. poi有效的樓層(str_ary);
  205. }
  206.  
  207. function poi有效的樓層(str_ary){
  208. //console.log( 'poi有效的樓層' );
  209.  
  210. var FFF=$('.thread').find('.post');
  211. //console.log( FFF );
  212.  
  213. var aaa1=[];
  214. str_ary.forEach(function( item,index ){//遍歷元素 item=指定的樓層
  215. //console.log( item,index );
  216. //console.log( FFF[item] );
  217. aaa1.push( FFF[item] );
  218. });
  219.  
  220. //console.log( aaa1 );//指定範圍內的文章
  221.  
  222. FFF='';
  223. var aaa1b=[];
  224. aaa1.forEach(function( item,index ){//遍歷元素
  225. //console.log( item,index );
  226. FFF= $(item).find('.file-thumb');//img
  227.  
  228. if( FFF.length > 0){ //有找到縮圖
  229. //console.log( FFF );
  230. //aaa1b.push( item );
  231. //aaa1b.push( $(FFF[0]).attr('src') );//縮圖
  232.  
  233. var 連結=$(FFF[0]).attr('href');
  234. //console.log( 連結 );
  235. var chk=0;
  236. if(連結.match(/jpg$/)){chk=chk+1;}
  237. if(連結.match(/png$/)){chk=chk+1;}
  238. if( chk >0 ){
  239. aaa1b.push( 連結 );
  240. }else{
  241. //只接受jpg
  242. delete str_ary[index];
  243. }
  244. }else{
  245. //沒找到圖片
  246. delete str_ary[index];
  247. }
  248. });
  249.  
  250. //console.log( str_ary );
  251. str_ary=str_ary.filter(function(item,index){
  252. //console.log( FFF );
  253. //var found=item.isInteger();
  254. if( parseInt(item) === item ){return true;}//留下整數 去掉空陣列
  255. });
  256. //
  257. if( str_ary.length > 0){ //有
  258. FFF=''+str_ary.toString();
  259. }else{
  260. FFF='無';
  261. }
  262.  
  263. console.log( FFF );//有效的樓層
  264. $('#poi220815m').append('<br/>有效的樓層:'+FFF);
  265.  
  266. //console.log( aaa1b );//要下載的圖片連結
  267. FFF='';
  268. FFF=[0,aaa1b];
  269. var traveler=FFF;
  270. //
  271. poi下載圖片(traveler); //啟動下載程序
  272.  
  273. }//
  274.  
  275.  
  276.  
  277.  
  278.  
  279. function poi下載圖片(traveler){
  280. var cc=traveler[0];
  281. var aaa1b=traveler[1];
  282. //
  283. console.log( cc,aaa1b.length );
  284. //
  285. if( cc < aaa1b.length){
  286. //沒事
  287. console.log( 'yy' );
  288. }else{
  289. console.log( 'nn' );
  290. $('#poi220815m').append('<br/>正常結束');
  291. return 0;//不正確 中止
  292. }//if
  293. var FFF=cc+1;
  294. $('#poi220815m').append('<br/>'+'('+FFF+'/'+aaa1b.length+')');
  295.  
  296. var imgurl=aaa1b[cc];//取得原圖網址
  297.  
  298.  
  299.  
  300. console.log( imgurl );
  301. var xhr = new XMLHttpRequest();
  302. xhr.onprogress = function(e){
  303. //console.log( 'xhr.onprogress' );
  304. var aa=0.0 + (e.loaded / e.total);
  305. aa= (aa * 100);//百分比
  306. var aa3 = aa.toFixed(2);//取小數2位
  307. var new_aa='';
  308. new_aa=''+aa3+'%';
  309. //console.log( new_aa );
  310. var ee = document.querySelector("#poi220815aa01");
  311. //var aa = document.getElementById('poi220815aa01');
  312. ee.innerHTML=new_aa;
  313.  
  314.  
  315. };
  316.  
  317. xhr.onreadystatechange = function(e){
  318. if(this.readyState == 4){
  319. if( this.status == 200 ){
  320. console.log( this.getAllResponseHeaders() );
  321. poi下載圖片2(traveler,this);//讀取圖片
  322. }
  323. }
  324. };
  325.  
  326.  
  327.  
  328. xhr.open('GET', imgurl);
  329. xhr.responseType = 'blob';
  330. xhr.send();
  331.  
  332. }
  333.  
  334. function poi下載圖片2(traveler,this2){
  335. //console.log( traveler,this2 );
  336. var cc=traveler[0];
  337. //
  338. var img = document.getElementById('poi220815img01');
  339. img.onload = function(e){
  340. poi下載圖片3(traveler,img.src);
  341. };
  342. img.src = window.URL.createObjectURL(this2.response);
  343.  
  344. }//
  345.  
  346. function poi下載圖片3(traveler,in1){
  347. //console.log( traveler,in1 );
  348. var cc=traveler[0];
  349. //
  350. var aa = document.getElementById('poi220815aa01');
  351. aa.href = in1;
  352. aa.download='';//自動下載blob
  353. aa.click();
  354. //aa.href = '#';
  355. //使用jq動畫做計時器
  356. //$("#poi220815img01").slideUp( 1000 ).slideDown( 1000 ,function(){
  357. $("#poi220815img01").animate({width: "20px"}, 1000).animate({width: "100px"}, 1000 ,function(){
  358. traveler[0]=cc+1;
  359. //console.log( traveler );
  360. poi下載圖片(traveler);
  361. });
  362. }
  363.  
  364.  
  365. function poi標示樓層(){ //標示樓層
  366. var FFF='';
  367. FFF=$('.thread').find('.post-head');
  368. //console.log( FFF );
  369. var cc=0;
  370. FFF.each(function( index,item ){//遍歷元素
  371. //console.log( index,item );
  372. $(item).prepend('<h1 style="text-align:left;">'+cc+'</h1>');//append
  373. cc++;
  374. });
  375.  
  376. }
  377.  
  378.  
  379. function poi_處理(){
  380. var aa = $('.file-text');
  381. //console.log( aa );
  382. aa.each(function( index,item ){//個別討論串
  383. var FFF=$(item).find('a').attr('href');
  384. console.log( FFF );
  385. if( /jpg$/.test( FFF ) ){
  386. poi4(item);
  387. } //不處理
  388. });
  389.  
  390. }
  391.  
  392.  
  393. function 沒用到(){
  394.  
  395. if( /jpg$/.test( imgurl ) ){
  396. //CDN1
  397. //imgurl=imgurl.substr(2);
  398. //imgurl='https://i0.wp.com/'+imgurl+'?fit=2048,2048&quality=85';//&&quality=85
  399. }//允許jpg
  400. if( /png$/.test( imgurl ) ){
  401. //CDN2
  402. //imgurl='http:'+imgurl;
  403. //imgurl='https://images.weserv.nl/?url=' + imgurl + '&output=jpg&q=85&filename=' + imgurl.match(/[0-9]{10,}/) +'&w=2048&h=2048&fit=inside&we';//
  404. }//允許png
  405.  
  406.  
  407. //blocked by CORS policy: No 'Access-Control-Allow-Origin'
  408. //K島圖片沒有允許跨來源資源共用 用圖片CDN處理一下
  409.  
  410.  
  411.  
  412. }

QingJ © 2025

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