百度網盤自動轉存

自動轉存當前文件至上次轉存路徑。

  1. // ==UserScript==
  2. // @name 百度網盤自動轉存
  3. // @name:zh-CN 百度网盘自动转存
  4. // @namespace moe.jixun.baidu.auto.save
  5. // @version 0.4
  6. // @description 自動轉存當前文件至上次轉存路徑。
  7. // @author Jixun
  8. // @include http://pan.baidu.com/share/link*
  9. // @include https://pan.baidu.com/share/link*
  10. // @include http://pan.baidu.com/s/*
  11. // @include https://pan.baidu.com/s/*
  12. // @grant none
  13. // @run-at document-end
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. (function(yunData, require) {
  18. 'use strict';
  19.  
  20. var errors = {
  21. 0: '成功',
  22. 5: '自己的文件',
  23. 12: '已经保存过了',
  24. 111: '另一保存任务进行中',
  25. '-33': '需要会员 (?)',
  26. 120: '需要会员 (?)',
  27. 130: '需要超级会员 (?)'
  28. };
  29.  
  30. (function (tip, c) {
  31. function getRecentPath() {
  32. var key = window.yunData.MYNAME.replace(/@/g, "") + "_transfer_save_path";
  33. var _recent_path = localStorage.getItem(key);
  34. if (!_recent_path) _recent_path = '/';
  35. else _recent_path = _recent_path.replace(/\?\d+/, '');
  36.  
  37. return _recent_path;
  38. }
  39.  
  40. var $ = require("base:widget/libs/jquery-1.12.4.js");
  41. function doAutoSave (count) {
  42. if (count <= 0) {
  43. tip.hide();
  44. tip.show({
  45. mode: 'error',
  46. msg: '转存失败:请检查网络连接。',
  47. hasClose: true,
  48. autoClose: false,
  49. vipType: 'svip'
  50. });
  51. return;
  52. }
  53. const path = getRecentPath();
  54.  
  55. $.ajax({
  56. type: 'POST',
  57. url: '/share/transfer?shareid=' + yunData.SHARE_ID + '&from=' + yunData.SHARE_UK,
  58. data: {
  59. filelist: JSON.stringify(yunData.FILEINFO.map(function(f){ return f.path; })),
  60. path: path
  61. },
  62. dataType: 'json',
  63. success: function (data) {
  64. var raw = typeof data == 'string' ? $.parseJSON(data) : data;
  65. var err = data.errno;
  66.  
  67. var errMsg = '';
  68. if (err in errors) {
  69. errMsg += errors[err] + ' (' + err + ')';
  70. } else {
  71. errMsg += '未知状态 (' + err + ')';
  72. }
  73.  
  74. var msg = '保存至: ' + path + ', 状态: ' + errMsg;
  75. document.title = errMsg + ' - ' + document.title;
  76.  
  77. tip.hide();
  78. tip.show({
  79. mode: err === 0 ? 'success' : 'caution',
  80. msg: msg,
  81. hasClose: true,
  82. autoClose: false,
  83. vipType: 'svip'
  84. });
  85. },
  86. error: function (error) {
  87. console.warn('网络连接失败,进行重试…');
  88. setTimeout(doAutoSave, 500, count - 1);
  89. }
  90. });
  91. }
  92. doAutoSave(5);
  93.  
  94. tip.show({
  95. mode: 'loading',
  96. msg: "正在转存文件,请稍后...",
  97. hasClose: false,
  98. autoClose: false
  99. });
  100. })(
  101. /*tip: */require("system-core:system/uiService/tip/tip.js")
  102. );
  103. })(window.yunData, window.require);

QingJ © 2025

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