picture_collector

Collect pictures of paginated structure picture website

目前为 2023-02-26 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name picture_collector
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.5
  5. // @description Collect pictures of paginated structure picture website
  6. // @author petitepluie
  7. // @match http://pic.netbian.com/*
  8. // @match http://www.gaoimg.com/*
  9. // @match *://desk.zol.com.cn/*
  10. // @match https://588ku.com/*
  11. // @match https://www.pixivacg.com/*
  12. // @match https://www.10wallpaper.com/*
  13. // @match http://www.netbian.com/*
  14. // @grant none
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18.  
  19. (function(){
  20. //获取本页地址
  21. var selfUrl=window.location.href;
  22. //添加界面css
  23. var mystyle=document.createElement("style");
  24. mystyle.innerHTML=`#popUpBox {
  25. position:fixed;
  26. top:0;
  27. right:-618px;
  28. z-index:10000;
  29. width:650px;
  30. height:20px;
  31. overflow-y:scroll;
  32. border:1px solid blue;
  33. background:#fff;
  34. }
  35. #boxCont {
  36. display:none;
  37. }
  38. #showAllConfig {
  39. width:100%;
  40. }
  41. #boxTitle {
  42. width:100%;
  43. height:22px;
  44. color:#fff;
  45. background:#0451ad;
  46. }
  47. #show_hid {
  48. width:32px;
  49. height:18px;
  50. line-height:15px;
  51. color:#0451ad;
  52. font-size:15px;
  53. font-weight:bold;
  54. }
  55. #baseOptionPlace {
  56. width:100%;
  57. height:50px;
  58. }
  59. #baseOptionCont {
  60. float:left;
  61. width:90%;
  62. height:100%;
  63. }
  64. #baseOptionCont span {
  65. font-size:12px;
  66. }
  67. #baseOptionCont input {
  68. height:10px;
  69. }
  70. .baseOption {
  71. width:100%;
  72. height:50%;
  73. }
  74. .reqLinkTitle {
  75. float:left;
  76. width:15%;
  77. height:100%;
  78. text-indent:5px;
  79. background:#c5dcfb;
  80. }
  81. .reqLinkCont {
  82. float:left;
  83. width:85%;
  84. height:100%;
  85. }
  86. #baseOptionTitle {
  87. float:right;
  88. width:10%;
  89. height:100%;
  90. background:#438dec;
  91. }
  92. #boxOptionPlace {
  93. width:100%;
  94. }
  95. .boxOption {
  96. width:100%;
  97. height:100px;
  98. margin-top:6px;
  99. border-top:2px solid blue;
  100. border-bottom:2px solid blue;
  101. }
  102. .boxOptionCont {
  103. float:left;
  104. width:90%;
  105. height:100%;
  106. }
  107. .options {
  108. width:100%;
  109. height:33%;
  110. border-bottom:0.5px solid blue;
  111. }
  112. .optionsTitle {
  113. float:left;
  114. width:15%;
  115. height:100%;
  116. line-height:30px;
  117. text-indent:5px;
  118. background:#c5dcfb;
  119. }
  120. .optionsCont {
  121. float:right;
  122. width:85%;
  123. height:100%;
  124. }
  125. .options span {
  126. font-size:12px;
  127. }
  128. .options input {
  129. height:10px;
  130. }
  131. .optionsContCube {
  132. float:left;
  133. width:50%;
  134. height:100%;
  135. }
  136. .optionsContName {
  137. width:100%;
  138. height:40%;
  139. line-height:10px;
  140. text-align:center;
  141. border-left:2px solid #fff;
  142. background:#deebf3;
  143. }
  144. .optionsContInput {
  145. width:100%;
  146. height:60%;
  147. line-height:15px;
  148. }
  149. .inputName {
  150. width:28%;
  151. }
  152. .inputNumb {
  153. width:12%;
  154. }
  155. .inputLink {
  156. width:56%;
  157. }
  158. .boxOptionTitle {
  159. float:right;
  160. width:10%;
  161. height:100%;
  162. background:#438dec;
  163. }
  164. .boxOptionTitle span {
  165. font-size:18px;
  166. color:#fff;
  167. }
  168. #dealOptionPlace {
  169. width:100%;
  170. height:36px;
  171. }
  172. .dealBtn {
  173. float:left;
  174. width:14%;
  175. height:25px;
  176. line-height:25px;
  177. margin:5px 10px;
  178. font-size:12px;
  179. text-align:center;
  180. border-radius:3px;
  181. background:rgba(0,0,0,0.5);
  182. transition:all 0.1s linear;
  183. cursor: pointer;
  184. }
  185. #start {
  186. background:#438dec;
  187. color:#fff;
  188. }
  189. #add {
  190. background:#c9defb;
  191. }
  192. #redu {
  193. background:#c9defb;
  194. }
  195. #add:hover {
  196. background:#438dec;
  197. color:#fff;
  198. }
  199. #redu:hover {
  200. background:#438dec;
  201. color:#fff;
  202. }
  203. #showCollectState {
  204. width:100%;
  205. height:40px;
  206. border-top:1px solid blue;
  207. }
  208. #sCsTitle {
  209. float:left;
  210. width:13%;
  211. height:100%;
  212. line-height:40px;
  213. font-size:14px;
  214. font-weight:bold;
  215. text-align:center;
  216. color:#0451ad;
  217. }
  218. #sCsCont {
  219. float:left;
  220. width:87%;
  221. height:100%;
  222. line-height:40px;
  223. }
  224. #showAllPicture {
  225. width:100%;
  226. height:490px;
  227. background:#438dec;
  228. overflow-y:scroll;
  229. }
  230. .cubeBox {
  231. float:left;
  232. width:85px;
  233. height:50px;
  234. margin:1px;
  235. background:rgba(0,0,0,0.5);
  236. overflow:hidden;
  237. }
  238. .cubeBox img {
  239. width:100%;
  240. }`;
  241. document.head.append(mystyle);
  242. //创建界面html
  243. var interFace=document.createElement('div');
  244. interFace.id='popUpBox';
  245. interFace.innerHTML=`
  246. <div id="boxTitle">
  247. <button id="show_hid">&lt;&lt;</button>
  248. <span>图片采集器(v.1.0.5)</span>
  249. </div>
  250. <div id="boxCont">
  251. <div id="showAllConfig">
  252. <div id="baseOptionPlace">
  253. <div id="baseOptionCont">
  254. <div class="baseOption">
  255. <div class="reqLinkTitle"><span>分页链接拆分</span></div>
  256. <div class="reqLinkCont">
  257. <span>索引前:</span><input class="inputLink" type="text">
  258. <span>索引后:</span><input class="inputNumb" type="text">
  259. </div>
  260. </div>
  261. <div class="baseOption">
  262. <div class="reqLinkTitle"><span>采集分页范围</span></div>
  263. <div class="reqLinkCont">
  264. <span>开始索引:</span><input class="inputNumb" type="number" min="2">
  265. <span>结束索引:</span><input class="inputNumb" type="number" min="2">
  266. </div>
  267. </div>
  268. </div>
  269. <div id="baseOptionTitle">基础信息配置</div>
  270. </div>
  271. <div id="boxOptionPlace"></div>
  272. <div id="dealOptionPlace">
  273. <div id="start" class="dealBtn">开始采集</div>
  274. <div id="add" class="dealBtn">选择器+</div>
  275. <div id="redu" class="dealBtn">选择器-</div>
  276. </div>
  277. </div>
  278. <div id="showCollectState">
  279. <div id="sCsTitle">采集状态:</div>
  280. <div id="sCsCont">null</div>
  281. </div>
  282. <div id="showAllPicture">
  283. <div class="cubeBox"></div>
  284. <div class="cubeBox"></div>
  285. <div class="cubeBox"></div>
  286. <div class="cubeBox"></div>
  287. <div class="cubeBox"></div>
  288. <div class="cubeBox"></div>
  289. <div class="cubeBox"></div>
  290. </div>
  291. </div>`;
  292. document.body.append(interFace);
  293. //添加界面逻辑
  294. var popUpBox=document.getElementById("popUpBox");
  295. var boxCont=document.getElementById("boxCont");
  296. var show_hid=document.getElementById("show_hid");
  297. var display=false;
  298. show_hid.onclick=function(){
  299. if(display){
  300. startMove(popUpBox,{
  301. "height":20,
  302. "right":-618
  303. },function(){
  304. display=false;
  305. show_hid.innerHTML="&lt;&lt;";
  306. })
  307. } else {
  308. boxCont.style.display="block";
  309. startMove(popUpBox,{
  310. "height":750,
  311. "right":0
  312. },function(){
  313. display=true;
  314. show_hid.innerHTML="&gt;&gt;";
  315. })
  316. }
  317. }
  318. var boxOptionPlace=document.getElementById('boxOptionPlace');
  319. boxOptionPlace.n=0;
  320. var boxOption=document.getElementsByClassName("boxOption");
  321. var add=document.getElementById("add");
  322. var redu=document.getElementById("redu");
  323. add.onclick=function(){
  324. var boxOptionTemp=document.createElement('div');
  325. boxOptionTemp.className='boxOption';
  326. boxOptionTemp.innerHTML=`
  327. <div class="boxOptionCont">
  328. <div class="options">
  329. <div class="optionsTitle"><span>父级节点</span></div>
  330. <div class="optionsCont parent">
  331. <div class="optionsContCube">
  332. <div class="optionsContName"><span>id</span></div>
  333. <div class="optionsContInput">
  334. <span>名称:</span><input class="inputName" type="text">
  335. </div>
  336. </div>
  337. <div class="optionsContCube">
  338. <div class="optionsContName"><span>class</span></div>
  339. <div class="optionsContInput">
  340. <span>名称:</span><input class="inputName" type="text">
  341. <span>索引:</span><input class="inputNumb" type="number" min="0">
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. <div class="options">
  347. <div class="optionsTitle"><span>子级节点集</span></div>
  348. <div class="optionsCont children">
  349. <div class="optionsContCube">
  350. <div class="optionsContName"><span>tag</span></div>
  351. <div class="optionsContInput">
  352. <span>名称:</span><input class="inputName" type="text">
  353. </div>
  354. </div>
  355. <div class="optionsContCube">
  356. <div class="optionsContName"><span>class</span></div>
  357. <div class="optionsContInput">
  358. <span>名称:</span><input class="inputName" type="text">
  359. </div>
  360. </div>
  361. </div>
  362. </div>
  363. <div class="options">
  364. <div class="optionsTitle"><span>目标元素位置</span></div>
  365. <div class="optionsCont flower">
  366. <div class="optionsContCube">
  367. <div class="optionsContName"><span>tag</span></div>
  368. <div class="optionsContInput">
  369. <span>名称:</span><input class="inputNumb" type="text">
  370. <span>索引:</span><input class="inputNumb" type="number" min="0">
  371. <span>属性:</span><input class="inputNumb" type="text" min="0">
  372. </div>
  373. </div>
  374. <div class="optionsContCube">
  375. <div class="optionsContName"><span>class</span></div>
  376. <div class="optionsContInput">
  377. <span>名称:</span><input class="inputNumb" type="text">
  378. <span>索引:</span><input class="inputNumb" type="number" min="0">
  379. <span>属性:</span><input class="inputNumb" type="text" min="0">
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. </div>
  385. <div class="boxOptionTitle"><span>${++boxOptionPlace.n}级</span>页面元素选择器</div>`;
  386. boxOptionPlace.appendChild(boxOptionTemp);
  387. }
  388. redu.onclick=function(){
  389. if(boxOptionPlace.n==0) return;
  390. boxOptionPlace.removeChild(boxOption[--boxOptionPlace.n]);
  391. }
  392. add.click();
  393. /**
  394. * 输入数据处理
  395. */
  396. //基础数据获取
  397. var baseOptionCont=document.getElementById('baseOptionCont');
  398. var baseOptionData=baseOptionCont.getElementsByTagName('input');
  399. var arrUrlFirst=[];
  400. var start=document.getElementById('start');
  401. //父级选择器获取
  402. var parent=document.getElementsByClassName('parent');
  403. //子级选择器获取
  404. var children=document.getElementsByClassName('children');
  405. //flower选择器获取
  406. var flower=document.getElementsByClassName('flower');
  407. //存放临时选择器数据的容器
  408. var arrPCFselect=[[],[],[]];
  409. //存放最终选择器数据的容器
  410. var arrSelector=[];
  411. //显示提示的容器
  412. var sCsCont=document.getElementById('sCsCont');
  413. start.onclick=function(){
  414. arrUrlFirst=[];
  415. if(baseOptionData[0].value!=''&&baseOptionData[1].value!=''&&baseOptionData[2].value!=''&&baseOptionData[3].value!=''){
  416. if(parseInt(baseOptionData[2].value)>parseInt(baseOptionData[3].value)){
  417. sCsCont.innerHTML='<span style="color:red">开始索引勿大于结束索引!</span>';
  418. return;
  419. }
  420. for(let i=parseInt(baseOptionData[2].value);i<=parseInt(baseOptionData[3].value);i++){
  421. arrUrlFirst.push(baseOptionData[0].value+i+baseOptionData[1].value);
  422. }
  423. } else {
  424. sCsCont.innerHTML='<span style="color:red">基础数据需填写完全,请检查!</span>';
  425. return;
  426. }
  427. //清空容器
  428. arrPCFselect=[[],[],[]];
  429. arrSelector=[];
  430. //存放临时选择器数据
  431. for(let i=0;i<boxOptionPlace.n;i++){
  432. //父级选择器
  433. var prtInput=parent[i].getElementsByTagName('input');
  434. if(prtInput[0].value!=''){
  435. arrPCFselect[0].push('id___'+prtInput[0].value);
  436. } else if(prtInput[1].value!=''&&prtInput[2].value!='') {
  437. arrPCFselect[0].push('class___'+prtInput[1].value+'___'+prtInput[2].value);
  438. } else {
  439. sCsCont.innerHTML='<span style="color:red">'+(i+1)+'级页面的父级节点选择器配置不能为空,请检查!</span>';
  440. return;
  441. }
  442. //子级选择器
  443. var cldInput=children[i].getElementsByTagName('input');
  444. if(cldInput[0].value!=''){
  445. arrPCFselect[1].push('tag___'+cldInput[0].value);
  446. } else if(cldInput[1].value!='') {
  447. arrPCFselect[1].push('class___'+cldInput[1].value);
  448. } else {
  449. sCsCont.innerHTML='<span style="color:red">'+(i+1)+'级页面的子级节点集选择器配置不能为空,请检查!</span>';
  450. return;
  451. }
  452. //flower选择器
  453. var flrInput=flower[i].getElementsByTagName('input');
  454. if(flrInput[0].value!=''&&flrInput[1].value!=''&&flrInput[2].value!=''){
  455. arrPCFselect[2].push('tag___'+flrInput[0].value+'___'+flrInput[1].value+'___'+flrInput[2].value);
  456. } else if(flrInput[3].value!=''&&flrInput[4].value!=''&&flrInput[5].value!='') {
  457. arrPCFselect[2].push('class___'+flrInput[3].value+'___'+flrInput[4].value+'___'+flrInput[5].value);
  458. } else {
  459. sCsCont.innerHTML='<span style="color:red">'+(i+1)+'级页面的目标元素选择器配置不能为空,请检查!</span>';
  460. return;
  461. }
  462. }
  463. //console.log("临时选择器数据如下:");
  464. //console.log(JSON.stringify(arrPCFselect));
  465. //获取最终选择器数据
  466. for(let i=0;i<boxOptionPlace.n;i++){
  467. var timerObj={
  468. parent:`${arrPCFselect[0][i]}`,
  469. children:`${arrPCFselect[1][i]}`,
  470. flower:`${arrPCFselect[2][i]}`
  471. }
  472. arrSelector.push(timerObj);
  473. }
  474. console.log("基础配置数据如下:");
  475. console.log(arrUrlFirst);
  476. console.log("最终选择器结果如下:");
  477. console.log(arrSelector);
  478. //清空待请求队列
  479. watingRequest=[];
  480. //设置清秋层级
  481. intDiving=arrSelector.length;
  482. //放入待请求队列集合
  483. watingRequest.push(arrUrlFirst);
  484. //记录队列长度
  485. watingLength.push(arrUrlFirst.length);
  486. console.log("队列结果如下:");
  487. console.log(watingRequest);
  488. if("当前没有其他采集任务"){
  489. console.log("执行采集任务");
  490. sCsCont.innerHTML='<span style="color:purple">采集中,请稍等...</span>';
  491. //开启采集程序
  492. spider();
  493. }
  494. }
  495. /*******************采集核心代码**************************/
  496. //存放各级待请求队列集合
  497. var watingRequest=[];
  498. var watingLength=[];
  499. var intDiving=0;
  500. var j=0;
  501. var finalResult=[];
  502. function spider(){
  503. ajax({
  504. url:watingRequest[j][0],
  505. type:"GET",
  506. sync:true,
  507. responseType:"document",
  508. success:function(xhr){
  509. var _document=xhr.responseXML.documentElement;
  510. var nowSelector=arrSelector[j];
  511. var parent=null;
  512. var children=null;
  513. var flower=null;
  514.  
  515. var ArrUrl=[];
  516. var parentMegs=nowSelector.parent.split("___");
  517.  
  518. switch(parentMegs[0]){
  519. case "id":parent=_document.getElementById(parentMegs[1]);break;
  520. case "class":parent=_document.getElementsByClassName(parentMegs[1])[parentMegs[2]];break;
  521. default: alert("parent空缺!");
  522. }
  523. var childrenMegs=nowSelector.children.split("___");
  524. switch(childrenMegs[0]){
  525. case "class":children=parent.getElementsByClassName(childrenMegs[1]);break;
  526. case "tag":children=parent.getElementsByTagName(childrenMegs[1]);break;
  527. default: alert("children空缺!");
  528. }
  529. var flowerMegs=nowSelector.flower.split("___");
  530. switch(flowerMegs[0]){
  531. case "class":getArrUrlByClass();break;
  532. case "tag":getArrUrlByTag();break;
  533. default: alert("flower空缺!");
  534. }
  535. function getArrUrlByClass(){
  536. for(let i=0;i<children.length;i++){
  537. flower=children[i].getElementsByClassName(flowerMegs[1])[flowerMegs[2]];
  538. var url=flower.getAttribute(flowerMegs[3]);
  539. if(url!=null){
  540. ArrUrl.push(url);
  541. }
  542. }
  543. }
  544. function getArrUrlByTag(){
  545. for(let i=0;i<children.length;i++){
  546. flower=children[i].getElementsByTagName(flowerMegs[1])[flowerMegs[2]];
  547. var url=flower.getAttribute(flowerMegs[3]);
  548. if(url!=null){
  549. ArrUrl.push(url);
  550. }
  551. }
  552. }
  553. if(ArrUrl.length==0){
  554. alert("队列为空!");
  555. console.log(xhr);
  556. console.log(_document);
  557. console.log(arrSelector[j]);
  558. console.log(ArrUrl);
  559. } else {
  560. //console.log("成功获取队列!");
  561. //console.log(_document);
  562. //console.log(arrSelector[j]);
  563. //console.log(ArrUrl);
  564. }
  565. watingRequest[j].shift();
  566. if((j+1)==intDiving){
  567. var strName="_";
  568. for(let i=0;i<=j;i++){
  569. strName += (watingLength[i]-watingRequest[i].length)+"_";
  570. }
  571. /**
  572. * 获取到图片链接
  573. */
  574. //1.直接下载
  575. /*
  576. for(var i=0;i<ArrUrl.length;i++){
  577. var imgName=strName+(i+1)+".jpg";
  578. var imgUrl=ArrUrl[i];
  579. //downloadPicture(imgName,imgUrl);
  580. console.log("下载了: "+strName+(i+1)+".jpg"+" :"+ArrUrl[i]); //后缀动态生成
  581. }
  582. */
  583. //2.添加到最终下载集合(推荐)
  584. /*
  585. for(var i=0;i<ArrUrl.length;i++){
  586. finalResult.push(ArrUrl[i]);
  587. }
  588. */
  589. //3.添加到页面显示 showAllPicture
  590. for(let i=0;i<ArrUrl.length;i++){
  591. var imgName=strName+(i+1)+".jpg";
  592. var imgUrl=ArrUrl[i];
  593. var elem=document.createElement('div');
  594. elem.className='cubeBox';
  595. elem.innerHTML=`<img src="${imgUrl}" title="${imgName}">`;
  596. showAllPicture.appendChild(elem);
  597. }
  598. if(watingRequest[j].length!=0){
  599. spider();
  600. } else {
  601. console.log("判断是否完成前的j和队列:");
  602. console.log(j);
  603. console.log(JSON.stringify(watingRequest));
  604. //判断是否完成
  605. function isEnd(){
  606. for(var i=j;i>=0;i--){
  607. if(watingRequest[i].length!=0){
  608. j=i;
  609. return false;
  610. } else {
  611. watingRequest.pop();
  612. }
  613. }
  614. return true;
  615. }
  616. var end=isEnd();
  617. console.log("判断是否完成后的j和队列:");
  618. console.log(j);
  619. console.log(JSON.stringify(watingRequest));
  620. if(end){
  621. console.log("程序结束,任务队列如下");
  622. var allImgLoaded=checkImgLoaded();
  623. var startCheckTime=Date.now();
  624. var timer=setInterval(function(){
  625. if(allImgLoaded){
  626. clearInterval(timer);
  627. console.log('图片加载完,改变页面形态');
  628.  
  629. var showAllConfig=document.getElementById('showAllConfig');
  630. boxCont.removeChild(showAllConfig);
  631. while(mystyle.previousElementSibling){
  632. document.head.removeChild(document.head.firstChild);
  633. }
  634. var title=document.createElement('title');
  635. title.innerHTML='采集图片——文件夹';
  636. document.head.appendChild(title);
  637. while(popUpBox.previousElementSibling){
  638. document.body.removeChild(document.body.firstChild);
  639. }
  640. sCsCont.innerHTML='<span style="color:green">完成,请按组合键"Ctrl+S"选择一个位置保存采集的图片</span>&nbsp;&nbsp;&nbsp;&nbsp;'+
  641. `<a href="${selfUrl}" alt="返回">否则返回</a>`;
  642. } else {
  643. if(Date.now()-startCheckTime>10000){
  644. sCsCont.innerHTML='<span style="color:yellowgreen">图片大部分加载完...可以按组合键"Ctrl+S"选择一个位置保存采集的图片</span>';
  645. allImgLoaded='true';
  646. }
  647. sCsCont.innerHTML='<span style="color:red">图片还未加载完,请稍等...</span>';
  648. }
  649. },200);
  650. return;
  651. } else {
  652. spider();
  653. }
  654. }
  655. } else {
  656. watingRequest.push(ArrUrl);
  657. watingLength.push(ArrUrl.length);
  658. j++;
  659. spider();
  660. }
  661. },
  662. error:function(xhr){
  663. alert(xhr.status+":ajax请求"+this.url+"失败!");
  664. console.log(xhr);
  665. }
  666. })
  667. }
  668. //ajax工具函数
  669. function ajax(obj){
  670. var xhr=null;
  671. if(window.XMLHttpRequest){
  672. xhr=new window.XMLHttpRequest();
  673. } else {
  674. xhr=new ActiveXObject("Microsoft.XMLHTTP");
  675. }
  676. xhr.responseType=obj.responseType;
  677. xhr.onreadystatechange=function(){
  678. if (xhr.readyState!=4) return;
  679. if(xhr.status==200){
  680. obj.success(xhr);
  681. } else {
  682. obj.error(xhr);
  683. }
  684. }
  685. xhr.open(obj.type,obj.url,obj.sync);
  686. xhr.send();
  687. }
  688. //工具函数4 下载图片(待完善)
  689. function downloadPicture(imgName,imgUrl){
  690. //return new Promise(function(resolve,reject){
  691. var anchor=document.createElement("A");
  692. anchor.href=imgUrl;
  693. anchor.download=imgName;
  694. anchor.target="_blank";
  695. document.body.appendChild(anchor);
  696. anchor.click();
  697. //给单个图片下载任务分配0.5s
  698. // setTimeout(function(){
  699. // resolve();
  700. // },500)
  701. //})
  702. }
  703. //动画工具函数
  704. function startMove(obj,json,fn){
  705. clearInterval(obj.timer);
  706. obj.timer=setInterval(function(){
  707. var now='';
  708. var onStop=true;
  709. for(var attr in json){
  710. if(attr=='opacity'){
  711. now=parseInt(parseFloat(getStyle(obj,attr))*100);
  712. } else {
  713. now=parseInt(getStyle(obj,attr));
  714. }
  715. var speed=(json[attr]-now)/5;
  716. speed=speed>0?Math.ceil(speed):Math.floor(speed);
  717. if(now!=json[attr]){
  718. onStop=false;
  719. }
  720. if(attr=='opacity'){
  721. obj.style[attr]=(now+speed)/100;
  722. } else {
  723. obj.style[attr]=now+speed+'px';
  724. }
  725. }
  726. if(onStop){
  727. clearInterval(obj.timer);
  728. if(fn){
  729. fn();
  730. }
  731. }
  732. },50);
  733. }
  734. function getStyle(obj,attr){
  735. if(obj.currentStyle){
  736. return obj.currentStyle(attr);
  737. } else {
  738. return getComputedStyle(obj,false)[attr];
  739. }
  740. }
  741. var showAllPicture=document.getElementById('showAllPicture');
  742. var allImg=showAllPicture.getElementsByTagName('img');
  743. //检查所有图片是否加载完全(待优化:不一定是所有图片都加载);
  744. function checkImgLoaded(){
  745. for(let i=0;i<allImg.length;i++){
  746. if(allImg[i].complete==false){
  747. return false;
  748. }
  749. }
  750. return true;
  751. }
  752. })()

QingJ © 2025

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