Greasy Fork is available in English.

Youdao Fanyi's Friend

有道翻译免费导出

  1. // ==UserScript==
  2. // @name Youdao Fanyi's Friend
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.1
  5. // @description 有道翻译免费导出
  6. // @author Zzn
  7. // @match *://c.youdao.com/dict_document_web/#/*
  8. // @match *://c.youdao.com/dict_document_web/*
  9. // @match *://c.youdao.com/*
  10. // @match *://pdf.youdao.com/docview.html/*
  11. // @match *://pdf.youdao.com/docview.html?key=*
  12. // @icon http://shared.ydstatic.com/images/favicon.ico
  13. // @grant none
  14. // @require https://cdn.jsdelivr.net/npm/jspdf@2.4.0/dist/jspdf.umd.min.js
  15. // @require https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
  16. // @require https://unpkg.com/pdf-lib/dist/pdf-lib.min.js
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. 'use strict';
  21.  
  22. //public SakiProgress
  23. var SakiProgress = {
  24. isLoaded: false,
  25. progres: false,
  26. pgDiv: false,
  27. textSpan: false,
  28. first: false,
  29. alertMode: false,
  30. init: function (color) {
  31. if (!this.isLoaded) {
  32. this.isLoaded = true;
  33. console.info("SakiProgress Initializing!\nVersion:1.0.3\nQinlili Tech:Github@qinlili23333");
  34. this.pgDiv = document.createElement("div");
  35. this.pgDiv.id = "pgdiv";
  36. this.pgDiv.style = "z-index:9999;position:fixed;background-color:white;min-height:32px;width:auto;height:32px;left:0px;right:0px;top:0px;box-shadow:0px 2px 2px 1px rgba(0, 0, 0, 0.5);transition:opacity 0.5s;display:none;";
  37. this.pgDiv.style.opacity = 0;
  38. this.first = document.body.firstElementChild;
  39. document.body.insertBefore(this.pgDiv, this.first);
  40. this.first.style.transition = "margin-top 0.5s"
  41. this.progress = document.createElement("div");
  42. this.progress.id = "dlprogress"
  43. this.progress.style = "position: absolute;top: 0;bottom: 0;left: 0;background-color: #F17C67;z-index: -1;width:0%;transition: width 0.25s ease-in-out,opacity 0.25s,background-color 1s;"
  44. if (color) {
  45. this.setColor(color);
  46. }
  47. this.pgDiv.appendChild(this.progress);
  48. this.textSpan = document.createElement("span");
  49. this.textSpan.style = "padding-left:4px;font-size:24px;";
  50. this.textSpan.style.display = "inline-block"
  51. this.pgDiv.appendChild(this.textSpan);
  52. var css = ".barBtn:hover{ background-color: #cccccc }.barBtn:active{ background-color: #999999 }";
  53. var style = document.createElement('style');
  54. if (style.styleSheet) {
  55. style.styleSheet.cssText = css;
  56. } else {
  57. style.appendChild(document.createTextNode(css));
  58. }
  59. document.getElementsByTagName('head')[0].appendChild(style);
  60. console.info("SakiProgress Initialized!");
  61. } else {
  62. console.error("Multi Instance Error-SakiProgress Already Loaded!");
  63. }
  64. },
  65. destroy: function () {
  66. if (this.pgDiv) {
  67. document.body.removeChild(this.pgDiv);
  68. this.isLoaded = false;
  69. this.progres = false;
  70. this.pgDiv = false;
  71. this.textSpan = false;
  72. this.first = false;
  73. console.info("SakiProgress Destroyed!You Can Reload Later!");
  74. }
  75. },
  76. setPercent: function (percent) {
  77. if (this.progress) {
  78. this.progress.style.width = percent + "%";
  79. } else {
  80. console.error("Not Initialized Error-Please Call `init` First!");
  81. }
  82. },
  83. clearProgress: function () {
  84. if (this.progress) {
  85. this.progress.style.opacity = 0;
  86. setTimeout(function () { SakiProgress.progress.style.width = "0%"; }, 500);
  87. setTimeout(function () { SakiProgress.progress.style.opacity = 1; }, 750);
  88. } else {
  89. console.error("Not Initialized Error-Please Call `init` First!")
  90. }
  91. },
  92. hideDiv: function () {
  93. if (this.pgDiv) {
  94. if (this.alertMode) {
  95. setTimeout(function () {
  96. SakiProgress.pgDiv.style.opacity = 0;
  97. SakiProgress.first.style.marginTop = "";
  98. setTimeout(function () {
  99. SakiProgress.pgDiv.style.display = "none";
  100. }, 500);
  101. }, 3000);
  102. } else {
  103. this.pgDiv.style.opacity = 0;
  104. this.first.style.marginTop = "";
  105. setTimeout(function () {
  106. SakiProgress.pgDiv.style.display = "none";
  107. }, 500);
  108. }
  109. }
  110. else {
  111. console.error("Not Initialized Error-Please Call `init` First!");
  112. }
  113. },
  114. showDiv: function () {
  115. if (this.pgDiv) {
  116. this.pgDiv.style.display = "";
  117. setTimeout(function () { SakiProgress.pgDiv.style.opacity = 1; }, 10);
  118. this.first.style.marginTop = (this.pgDiv.clientHeight + 8) + "px";
  119. }
  120. else {
  121. console.error("Not Initialized Error-Please Call `init` First!");
  122. }
  123. },
  124. setText: function (text) {
  125. if (this.textSpan) {
  126. if (this.alertMode) {
  127. setTimeout(function () {
  128. if (!SakiProgress.alertMode) {
  129. SakiProgress.textSpan.innerText = text;
  130. }
  131. }, 3000);
  132. } else {
  133. this.textSpan.innerText = text;
  134. }
  135. }
  136. else {
  137. console.error("Not Initialized Error-Please Call `init` First!");
  138. }
  139. },
  140. setTextAlert: function (text) {
  141. if (this.textSpan) {
  142. this.textSpan.innerText = text;
  143. this.alertMode = true;
  144. setTimeout(function () { this.alertMode = false; }, 3000);
  145. }
  146. else {
  147. console.error("Not Initialized Error-Please Call `init` First!");
  148. }
  149. },
  150. setColor: function (color) {
  151. if (this.progress) {
  152. this.progress.style.backgroundColor = color;
  153. }
  154. else {
  155. console.error("Not Initialized Error-Please Call `init` First!");
  156. }
  157. },
  158. addBtn: function (img) {
  159. if (this.pgDiv) {
  160. var btn = document.createElement("img");
  161. btn.style = "display: inline-block;right:0px;float:right;height:32px;width:32px;transition:background-color 0.2s;"
  162. btn.className = "barBtn"
  163. btn.src = img;
  164. this.pgDiv.appendChild(btn);
  165. return btn;
  166. }
  167. else {
  168. console.error("Not Initialized Error-Please Call `init` First!");
  169. }
  170. },
  171. removeBtn: function (btn) {
  172. if (this.pgDiv) {
  173. if (btn) {
  174. this.pgDiv.removeChild(btn);
  175. }
  176. }
  177. else {
  178. console.error("Not Initialized Error-Please Call `init` First!");
  179. }
  180. }
  181. }
  182.  
  183.  
  184. // Your code here...
  185. SakiProgress.init();
  186. console.log("Initializing ZnDownloader...");
  187. var jsPDF = null;
  188. try{
  189. jsPDF=jspdf.jsPDF;
  190. console.log("jsPDF Ready!")
  191. }catch{
  192. console.error("jsPDF Not Ready!")
  193. }
  194.  
  195. //init param
  196. var pageTotal = 0;
  197. var PDFfile=false;
  198. var currentTime = 0;
  199. var imgList=[];
  200. var imgDataList=[];
  201. var imgEle=document.createElement("img");
  202. document.body.appendChild(imgEle);
  203.  
  204.  
  205. //多线程快速下载
  206. function downloadPicList(list) {
  207. var donePage = 0;
  208. for(var j=0;j<list.length;j++){
  209. toDataURL(list[j],j,function(data,page){
  210. imgDataList[page]=data;
  211. donePage++
  212. SakiProgress.setPercent(donePage/pageTotal*90)
  213. SakiProgress.setText("已下载"+donePage+"页...")
  214. if(donePage==pageTotal){
  215. SakiProgress.setText("准备生成PDF...")
  216. makePDF();
  217. }
  218. })
  219. }
  220.  
  221. //读取图片并转base64
  222. function toDataURL(url,page, callback) {
  223. var xhr = new XMLHttpRequest();
  224. xhr.onload = function() {
  225. var reader = new FileReader();
  226. reader.onloadend = function() {
  227. callback(reader.result,page);
  228. }
  229. reader.readAsDataURL(xhr.response);//to base64
  230. //console.log(j + "---" + xhr.response)
  231. };
  232. xhr.open('GET', url);
  233. xhr.responseType = 'blob';
  234. xhr.setRequestHeader('Access-Control-Allow-Origin','*');
  235. xhr.setRequestHeader('Access-Control-Allow-Methods','OPTIONS, GET, POST');
  236. xhr.setRequestHeader('Access-Control-Allow-Headers','x-requested-with');
  237. xhr.setRequestHeader('Access-Control-Max-Age','86400');
  238.  
  239. xhr.setRequestHeader('Access-Control-Allow-Credentials','true');
  240. xhr.withCredentials = true;
  241. xhr.send();
  242. }
  243.  
  244. }
  245.  
  246.  
  247. //制作PDF
  248. function makePDF(){
  249. console.log('make pdf...')
  250. //console.log(imgDataList)
  251.  
  252. for(var k=0;imgDataList[k];k++){
  253. //imgEle.src=imgDataList[k];
  254. PDFfile.addImage(imgDataList[k],"JPEG",0,0,imgEle.naturalWidth,imgEle.naturalHeight,"Page"+(k+1),"SLOW")
  255. PDFfile.addPage();
  256. SakiProgress.setText("已生成"+k+"页...")
  257. }
  258. PDFfile.deletePage(imgDataList.length + 1);//delete the end blank page
  259. SakiProgress.setText("正在制作PDF...")
  260. PDFfile.save(getPdfName(),{returnPromise:true}).then(finish => {
  261. SakiProgress.clearProgress;
  262. SakiProgress.hideDiv();
  263. });
  264. }
  265.  
  266. //批量下载
  267. function batchDownload() {
  268. SakiProgress.showDiv()
  269. SakiProgress.setText("正在读取页面信息...")
  270. console.log("Initializing image list...")
  271.  
  272. // https://doctrans-service.youdao.com/trandoc/doc/getFullOriginModeImg?docKey=64EBF13E1D134669B72DF4C694089EF5&pageName=tran-0.jpeg&src=new-fanyiweb&isCheckTermUpdate=false&isUseTerm=false
  273.  
  274. $("#docTranslationImg").children().each(function(i,el){
  275. imgList[i]=$(this).children("img").attr("data-src")
  276. });
  277. //get docKey
  278. var docKey = getDocKey(imgList[0]);
  279. //calculate total page
  280. getTotalPage(docKey);
  281. for(var i=0;i<pageTotal;i++){
  282. imgList[i]=getImgUrl(docKey,i);
  283. }
  284.  
  285. SakiProgress.setText("正在读取参数并建立PDF...")
  286. imgEle.onload=function(){
  287. var ori
  288. if(imgEle.naturalWidth>imgEle.naturalHeight){ori="l"}else{ori="p"}
  289. PDFfile=new jsPDF({
  290. orientation: ori,
  291. unit: 'px',
  292. format: [imgEle.naturalWidth,imgEle.naturalHeight],
  293. putOnlyUsedFonts:true,
  294. });
  295. SakiProgress.setText("正在准备下载页面...")
  296. downloadPicList(imgList,imgDataList)
  297. }
  298. imgEle.src=imgList[0]
  299. }
  300.  
  301. //获取文件名
  302. function getPdfName(){
  303. // return $(".original-doc-name").first().html() + ".pdf";
  304. return "(" + $('#filenameInput').html() + ").pdf";
  305. // return "(" + $('.docName-text').children().html() + ").pdf";
  306. }
  307.  
  308. function getTotalPage(docKey){
  309. var viewPage = 1;
  310. var isEnd = false;
  311. pageTotal = 0;
  312. var s = genSign(docKey);
  313. getTotalPage0()
  314. SakiProgress.setText("加载完成,共"+pageTotal+"页,等待下载...")
  315. function getTotalPage0(){
  316. var url = "https://doctrans-service.youdao.com/trandoc/doc/viewFullOriginModeJSON?docKey=" + docKey + "&viewPage=" + viewPage + "&src=new-fanyiweb";
  317.  
  318. //调用url之前先调用其他两个url,
  319. SakiProgress.setText('viewPage: ' + viewPage + ' 正在加载')
  320. console.log('viewPage: ' + viewPage + ' 正在加载')
  321. var isGoOn = getFullOrign(docKey,s.sign,s.salt,viewPage)
  322. if(isGoOn != 205){//是否继续获取未加载页面
  323. //console.log('viewPage: ' + viewPage + ' 正在获取')
  324. var jsonStr = getUrlJson(url + "&_=" + getTimestamp());//同步获取json
  325. //console.log('viewPage: ' + viewPage + ' 正在判定')
  326. var recvJson = JSON.parse(jsonStr);
  327. isEnd = recvJson['data']
  328. //若isEnd不存在,可能真的不存在,也可能还未加载出来,但是既然能isGoOn,isEnd肯定是存在的,所以不需要其他判断
  329. if(isEnd != undefined){
  330. var tranLength = recvJson['data']['tran'].length
  331. //console.log(recvJson['data']['tran']);
  332. pageTotal += (recvJson['data']['tran'][tranLength-1].pageOrder - recvJson['data']['tran'][0].pageOrder + 1); //TODO
  333. //console.log('viewPage: ' + viewPage + ' 当前页数: ' + pageTotal)
  334. SakiProgress.setText("正在加载翻译,已翻译"+pageTotal+"页")
  335. if(!(isEnd=recvJson['data']['isEnd'])){
  336. console.log('viewPage: ' + viewPage + ' 后面还有,继续')
  337. viewPage++;
  338. getTotalPage0();
  339. }
  340. }else{//用于解决youdaofanyi后台反应不过来的问题
  341. SakiProgress.setText("youdao太慢,正在重新访问链接...")
  342. sleep(5000)
  343. getTotalPage0()
  344. }
  345. }
  346. }
  347. }
  348. function sleep(delay) {
  349. for(var t = Date.now(); Date.now() - t <= delay;);
  350. }
  351. function getFullOrign(docKey,sign,salt,page){
  352. var url = "https://doctrans-service.youdao.com/trandoc/doc/genFullOriginPage?docKey=" + docKey + "&viewPage=" + page + "&isCheckTermUpdate=false&isUseTerm=false&imei=&sign=" + sign + "&salt=" + salt + "&src=new-fanyiweb"
  353. var url2 = "https://doctrans-service.youdao.com/trandoc/doc/originFullProgress?key=" + docKey + "&imei=&viewPage=" + page + "&src=new-fanyiweb"
  354.  
  355. var jsonStr = getUrlJson(url + "&_=" + getTimestamp());//同步获取json
  356. var recvJson = JSON.parse(jsonStr);
  357. var errorcode = recvJson['errorcode']
  358. var docname = recvJson['docname']
  359. $('#filenameInput').html(docname)
  360. if(errorcode != 205){
  361. var jsonStr2 = getUrlJson(url2 + "&_=" + getTimestamp());//激活未加载的页面(此操作后可获取出未加载的页面)
  362. //return true;
  363. }//else{
  364. // return false;
  365. //}
  366. return errorcode
  367. }
  368.  
  369. function getDocKey(imgUrl){
  370. // 通过当前页url获取docKey,而不是imgUrl
  371. return getQueryString(window.location.href, 'docKey')
  372. //TODO 兼容老版本
  373. //return getQueryString(window.location.href, 'key')
  374. }
  375.  
  376. function getQueryString(url, name) {
  377. var arrObj = url.split("?");
  378. if (arrObj.length > 1) {
  379. var arrPara = arrObj[1].split("&");
  380. var arr;
  381. for (var i = 0; i < arrPara.length; i++) {
  382. arr = arrPara[i].split("=");
  383.  
  384. if (arr != null && arr[0] == name) {
  385. return arr[1];
  386. }
  387. }
  388. return "";
  389. }
  390. else {
  391. return "";
  392. }
  393. }
  394.  
  395. //获取json
  396. function getUrlJson(url) {
  397. var xhr = new XMLHttpRequest();
  398. // xhr.onload = function() {//异步
  399. // callback(xhr.response);
  400. // };
  401. xhr.open('GET', url, false);
  402. //xhr.responseType = 'json';//同步不能设置该项
  403. xhr.setRequestHeader('Access-Control-Allow-Origin','*');
  404. xhr.setRequestHeader('Access-Control-Allow-Methods','OPTIONS, GET, POST');
  405. xhr.setRequestHeader('Access-Control-Allow-Headers','x-requested-with');
  406. xhr.setRequestHeader('Access-Control-Max-Age','86400');
  407. xhr.setRequestHeader('Access-Control-Allow-Credentials','true');
  408. xhr.withCredentials = true;
  409. xhr.send(null);
  410. if (xhr.status === 200) {//同步
  411. return xhr.response
  412. }
  413. }
  414.  
  415. //根据下标获取拼接好的图片url
  416. function getImgUrl(docKey, idx){
  417. return 'https://doctrans-service.youdao.com/trandoc/doc/getFullOriginModeImg?docKey=' + docKey + '&pageName=tran-' + idx + '.jpeg&src=new-fanyiweb&isCheckTermUpdate=false&isUseTerm=false'
  418.  
  419. }
  420.  
  421. //获取sign和salt
  422. function genSign(docKey) {
  423. var t = "new-fanyiweb"
  424. var n = "ydsecret://newfanyiweb.doctran/sign/0j9n2{3mLSN-$Lg]K4o0N2}"
  425. , o = (new Date).getTime();
  426. return {
  427. salt: o,
  428. sign: getSign_r(t + o + n + docKey)
  429. }
  430. }
  431.  
  432. function getTimestamp(){
  433. currentTime++
  434. return currentTime;
  435. }
  436.  
  437. //private
  438. function getSign_r(e,t){
  439. if(null==e)
  440. throw new Error("Illegal argument "+e);
  441. //r
  442. var r = {
  443. rotl: function(e, t) {
  444. return e << t | e >>> 32 - t
  445. },
  446. rotr: function(e, t) {
  447. return e << 32 - t | e >>> t
  448. },
  449. endian: function(e) {
  450. if (e.constructor == Number)
  451. return 16711935 & r.rotl(e, 8) | 4278255360 & r.rotl(e, 24);
  452. for (var t = 0; t < e.length; t++)
  453. e[t] = r.endian(e[t]);
  454. return e
  455. },
  456. randomBytes: function(e) {
  457. for (var t = []; e > 0; e--)
  458. t.push(Math.floor(256 * Math.random()));
  459. return t
  460. },
  461. bytesToWords: function(e) {
  462. for (var t = [], n = 0, r = 0; n < e.length; n++,
  463. r += 8)
  464. t[r >>> 5] |= e[n] << 24 - r % 32;
  465. return t
  466. },
  467. wordsToBytes: function(e) {
  468. for (var t = [], n = 0; n < 32 * e.length; n += 8)
  469. t.push(e[n >>> 5] >>> 24 - n % 32 & 255);
  470. return t
  471. },
  472. bytesToHex: function(e) {
  473. for (var t = [], n = 0; n < e.length; n++)
  474. t.push((e[n] >>> 4).toString(16)),
  475. t.push((15 & e[n]).toString(16));
  476. return t.join("")
  477. },
  478. hexToBytes: function(e) {
  479. for (var t = [], n = 0; n < e.length; n += 2)
  480. t.push(parseInt(e.substr(n, 2), 16));
  481. return t
  482. },
  483. bytesToBase64: function(e) {
  484. for (var t = [], r = 0; r < e.length; r += 3)
  485. for (var o = e[r] << 16 | e[r + 1] << 8 | e[r + 2], i = 0; i < 4; i++)
  486. 8 * r + 6 * i <= 8 * e.length ? t.push(n.charAt(o >>> 6 * (3 - i) & 63)) : t.push("=");
  487. return t.join("")
  488. },
  489. base64ToBytes: function(e) {
  490. e = e.replace(/[^A-Z0-9+\/]/gi, "");
  491. for (var t = [], r = 0, o = 0; r < e.length; o = ++r % 4)
  492. 0 != o && t.push((n.indexOf(e.charAt(r - 1)) & Math.pow(2, -2 * o + 8) - 1) << 2 * o | n.indexOf(e.charAt(r)) >>> 6 - 2 * o);
  493. return t
  494. },
  495. stringToBytes: function(e) {
  496. for (var t = [], n = 0; n < e.length; n++)
  497. t.push(255 & e.charCodeAt(n));
  498. return t
  499. },
  500. bytesToString: function(e) {
  501. for (var t = [], n = 0; n < e.length; n++)
  502. t.push(String.fromCharCode(e[n]));
  503. return t.join("")
  504. }
  505. }
  506.  
  507. //function u
  508. var u = function(e, t) {
  509. e.constructor == String ? e = t && "binary" === t.encoding ? r.stringToBytes(e) : r.stringToBytes(e) : i(e) ? e = Array.prototype.slice.call(e, 0) : Array.isArray(e) || e.constructor === Uint8Array || (e = e.toString());
  510. for (var n = r.bytesToWords(e), s = 8 * e.length, c = 1732584193, l = -271733879, f = -1732584194, p = 271733878, d = 0; d < n.length; d++)
  511. n[d] = 16711935 & (n[d] << 8 | n[d] >>> 24) | 4278255360 & (n[d] << 24 | n[d] >>> 8);
  512. n[s >>> 5] |= 128 << s % 32,
  513. n[14 + (s + 64 >>> 9 << 4)] = s;
  514. var h = u._ff
  515. , y = u._gg
  516. , v = u._hh
  517. , g = u._ii;
  518. for (d = 0; d < n.length; d += 16) {
  519. var m = c
  520. , b = l
  521. , x = f
  522. , w = p;
  523. c = h(c, l, f, p, n[d + 0], 7, -680876936),
  524. p = h(p, c, l, f, n[d + 1], 12, -389564586),
  525. f = h(f, p, c, l, n[d + 2], 17, 606105819),
  526. l = h(l, f, p, c, n[d + 3], 22, -1044525330),
  527. c = h(c, l, f, p, n[d + 4], 7, -176418897),
  528. p = h(p, c, l, f, n[d + 5], 12, 1200080426),
  529. f = h(f, p, c, l, n[d + 6], 17, -1473231341),
  530. l = h(l, f, p, c, n[d + 7], 22, -45705983),
  531. c = h(c, l, f, p, n[d + 8], 7, 1770035416),
  532. p = h(p, c, l, f, n[d + 9], 12, -1958414417),
  533. f = h(f, p, c, l, n[d + 10], 17, -42063),
  534. l = h(l, f, p, c, n[d + 11], 22, -1990404162),
  535. c = h(c, l, f, p, n[d + 12], 7, 1804603682),
  536. p = h(p, c, l, f, n[d + 13], 12, -40341101),
  537. f = h(f, p, c, l, n[d + 14], 17, -1502002290),
  538. c = y(c, l = h(l, f, p, c, n[d + 15], 22, 1236535329), f, p, n[d + 1], 5, -165796510),
  539. p = y(p, c, l, f, n[d + 6], 9, -1069501632),
  540. f = y(f, p, c, l, n[d + 11], 14, 643717713),
  541. l = y(l, f, p, c, n[d + 0], 20, -373897302),
  542. c = y(c, l, f, p, n[d + 5], 5, -701558691),
  543. p = y(p, c, l, f, n[d + 10], 9, 38016083),
  544. f = y(f, p, c, l, n[d + 15], 14, -660478335),
  545. l = y(l, f, p, c, n[d + 4], 20, -405537848),
  546. c = y(c, l, f, p, n[d + 9], 5, 568446438),
  547. p = y(p, c, l, f, n[d + 14], 9, -1019803690),
  548. f = y(f, p, c, l, n[d + 3], 14, -187363961),
  549. l = y(l, f, p, c, n[d + 8], 20, 1163531501),
  550. c = y(c, l, f, p, n[d + 13], 5, -1444681467),
  551. p = y(p, c, l, f, n[d + 2], 9, -51403784),
  552. f = y(f, p, c, l, n[d + 7], 14, 1735328473),
  553. c = v(c, l = y(l, f, p, c, n[d + 12], 20, -1926607734), f, p, n[d + 5], 4, -378558),
  554. p = v(p, c, l, f, n[d + 8], 11, -2022574463),
  555. f = v(f, p, c, l, n[d + 11], 16, 1839030562),
  556. l = v(l, f, p, c, n[d + 14], 23, -35309556),
  557. c = v(c, l, f, p, n[d + 1], 4, -1530992060),
  558. p = v(p, c, l, f, n[d + 4], 11, 1272893353),
  559. f = v(f, p, c, l, n[d + 7], 16, -155497632),
  560. l = v(l, f, p, c, n[d + 10], 23, -1094730640),
  561. c = v(c, l, f, p, n[d + 13], 4, 681279174),
  562. p = v(p, c, l, f, n[d + 0], 11, -358537222),
  563. f = v(f, p, c, l, n[d + 3], 16, -722521979),
  564. l = v(l, f, p, c, n[d + 6], 23, 76029189),
  565. c = v(c, l, f, p, n[d + 9], 4, -640364487),
  566. p = v(p, c, l, f, n[d + 12], 11, -421815835),
  567. f = v(f, p, c, l, n[d + 15], 16, 530742520),
  568. c = g(c, l = v(l, f, p, c, n[d + 2], 23, -995338651), f, p, n[d + 0], 6, -198630844),
  569. p = g(p, c, l, f, n[d + 7], 10, 1126891415),
  570. f = g(f, p, c, l, n[d + 14], 15, -1416354905),
  571. l = g(l, f, p, c, n[d + 5], 21, -57434055),
  572. c = g(c, l, f, p, n[d + 12], 6, 1700485571),
  573. p = g(p, c, l, f, n[d + 3], 10, -1894986606),
  574. f = g(f, p, c, l, n[d + 10], 15, -1051523),
  575. l = g(l, f, p, c, n[d + 1], 21, -2054922799),
  576. c = g(c, l, f, p, n[d + 8], 6, 1873313359),
  577. p = g(p, c, l, f, n[d + 15], 10, -30611744),
  578. f = g(f, p, c, l, n[d + 6], 15, -1560198380),
  579. l = g(l, f, p, c, n[d + 13], 21, 1309151649),
  580. c = g(c, l, f, p, n[d + 4], 6, -145523070),
  581. p = g(p, c, l, f, n[d + 11], 10, -1120210379),
  582. f = g(f, p, c, l, n[d + 2], 15, 718787259),
  583. l = g(l, f, p, c, n[d + 9], 21, -343485551),
  584. c = c + m >>> 0,
  585. l = l + b >>> 0,
  586. f = f + x >>> 0,
  587. p = p + w >>> 0
  588. }
  589. return r.endian([c, l, f, p])
  590. }
  591. u._ff = function(e, t, n, r, o, i, a) {
  592. var u = e + (t & n | ~t & r) + (o >>> 0) + a;
  593. return (u << i | u >>> 32 - i) + t
  594. },u._gg = function(e, t, n, r, o, i, a) {
  595. var u = e + (t & r | n & ~r) + (o >>> 0) + a;
  596. return (u << i | u >>> 32 - i) + t
  597. },u._hh = function(e, t, n, r, o, i, a) {
  598. var u = e + (t ^ n ^ r) + (o >>> 0) + a;
  599. return (u << i | u >>> 32 - i) + t
  600. },u._ii = function(e, t, n, r, o, i, a) {
  601. var u = e + (n ^ (t | ~r)) + (o >>> 0) + a;
  602. return (u << i | u >>> 32 - i) + t
  603. },u._blocksize = 16,u._digestsize = 16
  604.  
  605. var n=r.wordsToBytes(u(e,t));
  606. return t&&t.asBytes?n:t&&t.asString?r.bytesToString(n):r.bytesToHex(n)
  607. }
  608.  
  609. //创建下载按钮
  610. var downloadBtn=$("<a id='exportDoc2' href='javascript:;'>导出文档</a>");
  611. var filenameInput = $("<span id='filenameInput'></span>");
  612. $("#app").prepend(filenameInput);
  613. $("#app").prepend(downloadBtn);
  614. // $("#exportDoc").parent().prepend(downloadBtn);
  615. // $("#exportDoc").remove();
  616. //TODO 兼容老版本
  617. $("#exportDoc").parent().prepend(downloadBtn);
  618. $("#exportDoc").remove();
  619.  
  620. downloadBtn.bind("contextmenu",function(){
  621. return false;
  622. })
  623. downloadBtn.mousedown(function(e) {
  624. SakiProgress.showDiv()
  625. SakiProgress.setText("正在加载翻译,信息量大,请勿关闭页面...")
  626. currentTime = Date.now()
  627. setTimeout(function(){//是为了让进度条先显示出来
  628. batchDownload()
  629. },100)
  630. })
  631. // downloadBtn.click(function() {
  632. // SakiProgress.showDiv()
  633. // SakiProgress.setText("正在加载翻译,信息量大,请勿关闭页面...")
  634. // currentTime = Date.now()
  635. // setTimeout(function(){//是为了让进度条先显示出来
  636. // batchDownload()
  637. // },100)
  638. // });
  639.  
  640.  
  641.  
  642. })();