网盘有效性检查

网盘助手,自动识别并检查链接状态,自动填写密码并跳转。现已支持 ✅百度网盘 ✅蓝奏云 ✅腾讯微云 ✅阿里云盘 ✅天翼云盘 ✅123网盘 ✅迅雷云盘 ✅夸克网盘 ✅奶牛网盘 ✅文叔叔 ✅115网盘 ✅移动彩云

  1. // ==UserScript==
  2. // @name 网盘有效性检查
  3. // @namespace https://www.877855.xyz
  4. // @version 1.8.21
  5. // @icon https://pan.baidu.com/ppres/static/images/favicon.ico
  6. // @author appppplayer
  7. // @license AGPL-3.0-or-later
  8. // @match *://*/*
  9. // @description 网盘助手,自动识别并检查链接状态,自动填写密码并跳转。现已支持 ✅百度网盘 ✅蓝奏云 ✅腾讯微云 ✅阿里云盘 ✅天翼云盘 ✅123网盘 ✅迅雷云盘 ✅夸克网盘 ✅奶牛网盘 ✅文叔叔 ✅115网盘 ✅移动彩云
  10. // @note 支持百度云、蓝奏云、腾讯微云、阿里云盘、天翼云盘、123网盘、夸克网盘、迅雷网盘、奶牛网盘、文叔叔、115网盘、移动彩云
  11. // @note 24-03-24 1.8.21 修正阿里云盘 TooManyRequests状态错误,优化无效链接判断, 快传失效链接识别错误
  12. // @connect lanzoub.com
  13. // @connect baidu.com
  14. // @connect weiyun.com
  15. // @connect aliyundrive.com
  16. // @connect cloud.189.cn
  17. // @connect 123pan.com
  18. // @connect quark.cn
  19. // @connect xunlei.com
  20. // @connect cowtransfer.com
  21. // @connect wenshushu.cn
  22. // @connect 115.com
  23. // @connect caiyun.139.com
  24. // @exclude *://baike.baidu.com/*
  25. // @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-y/jquery/3.6.0/jquery.min.js
  26. // @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-y/findAndReplaceDOMText/0.4.6/findAndReplaceDOMText.min.js
  27. // @run-at document-start
  28. // @grant GM_getValue
  29. // @grant GM_setValue
  30. // @grant GM_deleteValue
  31. // @grant GM_listValues
  32. // @grant GM_openInTab
  33. // @grant GM_notification
  34. // @grant GM_xmlhttpRequest
  35. // @homepageURL https://www.877855.xyz
  36. // @noframes
  37. // ==/UserScript==
  38. (function () {
  39. 'use strict';
  40.  
  41. var manifest = {
  42. "debugId": "1p4fyOm",
  43. "logger_level": 3,
  44. "checkTimes": 20,
  45. "checkInterval": 4,
  46. "options_page": ""
  47. };
  48. var passMap = {};
  49. var panRule = /lanzou|115|baidu|weiyun|aliyundrive|123pan|189|quark|caiyun|xunlei|cowtransfer|wss/gi;
  50. var excludingPwdHosts = ["pan.baidu.com", "baike.baidu.com"];
  51.  
  52. function getQuery(param) {
  53. return new URLSearchParams(location.search).get(param);
  54. }
  55. var container = (function () {
  56. var obj = {
  57. defines: {},
  58. modules: {}
  59. };
  60.  
  61. obj.define = function (name, requires, callback) {
  62. name = obj.processName(name);
  63. obj.defines[name] = {
  64. requires: requires,
  65. callback: callback
  66. };
  67. };
  68.  
  69. obj.require = function (name, cache) {
  70. if (typeof cache == "undefined") {
  71. cache = true;
  72. }
  73.  
  74. name = obj.processName(name);
  75. if (cache && obj.modules.hasOwnProperty(name)) {
  76. return obj.modules[name];
  77. } else if (obj.defines.hasOwnProperty(name)) {
  78. var requires = obj.defines[name].requires;
  79. var callback = obj.defines[name].callback;
  80. var module = obj.use(requires, callback);
  81. cache && obj.register(name, module);
  82. return module;
  83. }
  84. };
  85.  
  86. obj.use = function (requires, callback) {
  87. var module = {
  88. exports: undefined
  89. };
  90. var params = obj.buildParams(requires, module);
  91. var result = callback.apply(this, params);
  92. if (typeof result != "undefined") {
  93. return result;
  94. } else {
  95. return module.exports;
  96. }
  97. };
  98.  
  99. obj.register = function (name, module) {
  100. name = obj.processName(name);
  101. obj.modules[name] = module;
  102. };
  103.  
  104. obj.buildParams = function (requires, module) {
  105. var params = [];
  106. requires.forEach(function (name) {
  107. params.push(obj.require(name));
  108. });
  109. params.push(obj.require);
  110. params.push(module.exports);
  111. params.push(module);
  112. return params;
  113. };
  114.  
  115. obj.processName = function (name) {
  116. return name.toLowerCase();
  117. };
  118.  
  119. return {
  120. define: obj.define,
  121. use: obj.use,
  122. register: obj.register,
  123. modules: obj.modules
  124. };
  125. })();
  126.  
  127. /**
  128. * 配置网盘参数 网盘名
  129. * reg 匹配正则
  130. * replaceReg dom替换正则
  131. * prefix shareId前缀
  132. * checkFun 有效性检测函数
  133. **/
  134. container.define("constant", ["logger", "http"], function (logger, http) {
  135. return {
  136. baidu: {
  137. reg: /(?:https?:\/\/)?\b(e?yun|pan)\.baidu\.com\/s\/([\w\-]{5,})(?!\.)/gi,
  138. replaceReg: /(?:https?:\/\/)?(?:e?yun|pan)\.baidu\.com\/s\/([\w\-]{5,})(?!\.)/gi,
  139. prefix: "https://pan.baidu.com/s/",
  140. checkFun: (shareId, callback) => {
  141. let url = shareId.includes("http") ? shareId : "https://pan.baidu.com/s/" + shareId;
  142. logger.info("baiddu checkFun", url, shareId);
  143. http.ajax({
  144. type: "get",
  145. url: url,
  146. success: (response) => {
  147. let state = 1;
  148. if (response.includes("过期时间:")) {
  149. state = 1;
  150. } else if (response.includes("输入提取")) {
  151. state = 2;
  152. } else if (response.includes("不存在") || response.includes("已失效")) {
  153. state = -1;
  154. }
  155. callback && callback({
  156. state: state
  157. });
  158. },
  159. error: function () {
  160. callback && callback({
  161. state: 0
  162. });
  163. }
  164. });
  165. }
  166. },
  167. baidu2: {
  168. reg: /(?:https?:\/\/)?\b(e?yun|pan)\.baidu\.com\/(?:share|wap)\/init\?surl=([\w\-]{5,})(?!\.)/gi,
  169. replaceReg: /(?:https?:\/\/)?(?:e?yun|pan)\.baidu\.com\/(?:share|wap)\/init\?surl=([\w\-]{5,})(?!\.)/gi,
  170. prefix: "https://pan.baidu.com/share/init?surl=",
  171. checkFun: (shareId, callback) => {
  172. let url = shareId.includes("http") ? shareId : "https://pan.baidu.com/share/init?surl=" + shareId;
  173. logger.info("baiddu checkFun", url, shareId);
  174. http.ajax({
  175. type: "get",
  176. url: url,
  177. success: (response) => {
  178. let state = 1;
  179. if (response.includes("过期时间:")) {
  180. state = 1;
  181. } else if (response.includes("输入提取")) {
  182. state = 2;
  183. } else if (response.includes("已失效") || response.includes("不存在")) {
  184. state = -1;
  185. }
  186. callback && callback({
  187. state: state
  188. });
  189. },
  190. error: function () {
  191. callback && callback({
  192. state: 0
  193. });
  194. }
  195. });
  196. }
  197. },
  198. weiyun: {
  199. reg: /(?:https?:\/\/)?\bshare\.weiyun\.com\/([\w\-]{7,})(?!.)(?!\.)/gi,
  200. replaceReg: /(?:https?:\/\/)?share\.weiyun\.com\/([\w\-]{7,})(?!\.)/gi,
  201. prefix: "https://share.weiyun.com/",
  202. checkFun: (shareId, callback) => {
  203. let url = shareId.includes("http") ? shareId : "https://share.weiyun.com/" + shareId;
  204. http.ajax({
  205. type: "get",
  206. url: url,
  207. success: (response) => {
  208. let state = 0;
  209. logger.info(shareId, "weiyun", response);
  210. // 请求限制
  211. if (!response) {
  212. state = 0
  213. } else if (response.includes("已删除")
  214. || response.includes("违反相关法规")
  215. || response.includes("已过期")
  216. || response.includes("已经删除")
  217. || response.includes("目录无效")) {
  218. state = -1;
  219. } else if (response.includes('"need_pwd":null') && response.includes('"pwd":""')) {
  220. state = 1;
  221. } else if (response.includes('"need_pwd":1') || response.includes('"pwd":"')) {
  222. state = 2;
  223. }
  224. callback && callback({
  225. state: state
  226. });
  227. },
  228. error: function () {
  229. callback && callback({
  230. state: 0
  231. });
  232. }
  233. });
  234. }
  235. },
  236. lanzou: {
  237. reg: /(?:https?:\/\/)?(?:[\w\-]+\.)?\blanzou.?\.com\/([\w\-]{7,})(?!\.)(?:\/)?/gi,
  238. replaceReg: /(?:https?:\/\/)?(?:[\w\-]+\.)?lan(?:zou?|.v|z).?\.com\/([\w\-]{7,})(?!\.)(?:\/)?/gi,
  239. aTagRepalce: [/(?:[\w\-]+\.)?lanzou.?/, "www.lanzoub"],
  240. prefix: "https://www.lanzoub.com/",
  241. checkFun: (shareId, callback) => {
  242. let url = shareId.includes("http") ? shareId : "https://www.lanzoub.com/" + shareId;
  243. http.ajax({
  244. type: "get",
  245. url: url,
  246. success: (response) => {
  247. let state = 1;
  248. // 请求限制
  249. if (!response) {
  250. state = 0
  251. } else if (response.includes("输入密码")) {
  252. state = 2;
  253. } else if (response.includes("来晚啦") || response.includes("不存在")) {
  254. state = -1;
  255. }
  256. callback && callback({
  257. state: state
  258. });
  259. },
  260. error: function () {
  261. callback && callback({
  262. state: 0
  263. });
  264. }
  265. });
  266. }
  267. },
  268. aliyun: {
  269. reg: /(?:https?:\/\/)?www\.aliyundrive\.com\/s\/([\w\-]{8,})(?![.\/])$/gi,
  270. replaceReg: /(?:https?:\/\/)?www\.ali(?:pan|yundrive)\.com\/s\/([\w\-]{8,})(?![.\/])/gi,
  271. prefix: "https://www.aliyundrive.com/s/",
  272. checkFun: (shareId, callback) => {
  273. logger.info("aliyun id ", shareId);
  274. http.ajax({
  275. type: "post",
  276. url: "https://api.aliyundrive.com/adrive/v3/share_link/get_share_by_anonymous",
  277. data: JSON.stringify({
  278. share_id: shareId
  279. }),
  280. headers: {
  281. "Content-Type": "application/json"
  282. },
  283. dataType: "json",
  284. success: (response) => {
  285. logger.debug("aliyun response ", response);
  286. let state = 1;
  287. // 请求限制
  288. if (!response) {
  289. state = 0
  290. } else if (response['code'] && (response['code'].indexOf("ShareLink") > -1)) {
  291. // 网盘ShareLink异常
  292. state = -1;
  293. } else if (response['code'] || response['file_count'] && response['file_count'] == 0) {
  294. // 其他状态未知,下次重新请求
  295. state = 0;
  296. }
  297.  
  298. callback && callback({
  299. state: state
  300. });
  301. },
  302. error: function () {
  303. callback && callback({
  304. state: 0
  305. });
  306. }
  307. });
  308. }
  309. },
  310. aliyun2: {
  311. reg: /(?:https?:\/\/)?www\.aliyundrive\.com\/t\/([\w\-]{8,})(?![.\/])$/gi,
  312. replaceReg: /(?:https?:\/\/)?www\.ali(?:pan|yundrive)\.com\/t\/([\w\-]{8,})(?![.\/])/gi,
  313. prefix: "https://www.aliyundrive.com/t/",
  314. checkFun: (shareId, callback) => {
  315. logger.info("aliyun2 id ", shareId);
  316. http.ajax({
  317. type: "post",
  318. url: "https://api.aliyundrive.com/adrive/v1/share/getByAnonymous?share_id=" + shareId,
  319. data: JSON.stringify({
  320. share_id: shareId
  321. }),
  322. headers: {
  323. "Content-Type": "application/json"
  324. },
  325. dataType: "json",
  326. success: (response) => {
  327. logger.debug("aliyun2 response ", response);
  328. let state = 1;
  329. // 请求限制
  330. if (!response) {
  331. state = 0
  332. } else if (response['code'] && (response['code'].includes("Exceed") || response['code'].includes("Share"))) {
  333. state = -1;
  334. }
  335.  
  336. callback && callback({
  337. state: state
  338. });
  339. },
  340. error: function () {
  341. callback && callback({
  342. state: 0
  343. });
  344. }
  345. });
  346. }
  347. },
  348. pan123: {
  349. reg: /(?:h?ttps?:\/\/)?(?:www\.)?\bpan123\.com\/s\/([\w\-]{8,})\b/gi,
  350. replaceReg: /(?:h?ttps?:\/\/)?(?:www\.)?123pan\.com\/s\/([\w\-]{8,})(\.html)?\b/gi,
  351. prefix: "https://www.123pan.com/s/",
  352. checkFun: (shareId, callback) => {
  353. logger.info("Pan123 check id " + shareId);
  354. http.ajax({
  355. type: "get",
  356. url: "https://www.123pan.com/api/share/info?shareKey=" + shareId,
  357. success: (response) => {
  358. logger.debug("Pan123 check response", response);
  359. let rsp = typeof response == "string" ? JSON.parse(response) : response;
  360. let state = 1;
  361. // 请求限制
  362. if (!response) {
  363. state = 0
  364. } else if (response.includes("分享页面不存在") || rsp.code != 0) {
  365. state = -1;
  366. } else if (rsp.data.HasPwd) {
  367. state = 2;
  368. }
  369.  
  370. callback && callback({
  371. state: state
  372. });
  373. },
  374. error: function () {
  375. callback && callback({
  376. state: 0
  377. });
  378. }
  379. });
  380. }
  381. },
  382. ty189: {
  383. reg: /(?:https?:\/\/)?cloud\.189\.cn\/(?:t\/|web\/share\?code=)([\w\-]{8,})(?!\.)/gi,
  384. replaceReg: /(?:https?:\/\/)?cloud\.189\.cn\/(?:t\/|web\/share\?code=)([\w\-]{8,})(?!\.)/gi,
  385. prefix: "https://cloud.189.cn/t/",
  386. aTagRepalce: [/\/web\/share\?code=/, "/t/"],
  387. checkFun: (shareId, callback) => {
  388. http.ajax({
  389. type: "post",
  390. url: "https://api.cloud.189.cn/open/share/getShareInfoByCodeV2.action",
  391. data: {
  392. shareCode: shareId
  393. },
  394. success: (response) => {
  395. logger.debug("Ty189 chec", shareId, response);
  396. let state = 1;
  397. // 请求限制
  398. if (!response) {
  399. state = 0
  400. } else if (response.includes("ShareInfoNotFound")
  401. || response.includes("ShareNotFound")
  402. || response.includes("FileNotFound")
  403. || response.includes("ShareExpiredError")
  404. || response.includes("ShareAuditNotPass")) {
  405. state = -1;
  406. } else if (response.includes("needAccessCode")) {
  407. state = 2;
  408. }
  409.  
  410. callback && callback({
  411. state: state
  412. });
  413. },
  414. error: () =>
  415. callback && callback({
  416. state: 0
  417. })
  418.  
  419. });
  420. }
  421. },
  422. quark: {
  423. reg: /(?:https?:\/\/)?\bpan.quark\.cn\/s\/([\w\-]{8,})(?!\.)/gi,
  424. replaceReg: /(?:https?:\/\/)?pan.quark\.cn\/s\/([\w\-]{8,})(?!\.)/gi,
  425. prefix: "https://pan.quark.cn/s/",
  426. checkFun: (shareId, callback) => {
  427. logger.info("Quark check id " + shareId);
  428. http.ajax({
  429. type: "post",
  430. data: JSON.stringify({
  431. pwd_id: shareId,
  432. passcode: ""
  433. }),
  434. url: "https://drive.quark.cn/1/clouddrive/share/sharepage/token?pr=ucpro&fr=pc",
  435. success: (response) => {
  436. logger.debug("Quark token response", response);
  437. let rsp = typeof response == "string" ? JSON.parse(response) : response;
  438. let state = 0;
  439. // 请求限制
  440. if (!response) {
  441. state = 0
  442. } else if (rsp.message.includes("需要提取码")) {
  443. state = 2;
  444. } else if (rsp.message.includes("ok")) {
  445. state = 1;
  446. } else {
  447. state = -1;
  448. }
  449.  
  450. callback && callback({
  451. state: state
  452. });
  453.  
  454. },
  455. error: function () {
  456. callback && callback({
  457. state: 0
  458. });
  459. }
  460. });
  461. }
  462. },
  463. xunlei: {
  464. reg: /(?:https?:\/\/)?\bpan.xunlei\.com\/s\/([\w\-]{25,})(?!\.)/gi,
  465. replaceReg: /(?:https?:\/\/)?pan.xunlei\.com\/s\/([\w\-]{25,})(?!\.)/gi,
  466. prefix: "https://pan.xunlei.com/s/",
  467. checkFun: (shareId, callback) => {
  468. logger.info("checkXunlei id", shareId);
  469. http.ajax({
  470. type: "post",
  471. data: JSON.stringify({
  472. client_id: "Xqp0kJBXWhwaTpB6",
  473. device_id: "925b7631473a13716b791d7f28289cad",
  474. action: "get:/drive/v1/share",
  475. meta: {
  476. package_name: "pan.xunlei.com",
  477. client_version: "1.45.0",
  478. captcha_sign: "1.fe2108ad808a74c9ac0243309242726c",
  479. timestamp: "1645241033384"
  480. }
  481. }),
  482. url: "https://xluser-ssl.xunlei.com/v1/shield/captcha/init",
  483. success: (response) => {
  484. logger.debug("xunlei token response", response);
  485. let rsp = JSON.parse(response);
  486. let token = rsp.captcha_token;
  487. http.ajax({
  488. type: "get",
  489. url: "https://api-pan.xunlei.com/drive/v1/share?share_id=" + shareId.replace("https://pan.xunlei.com/s/", ""),
  490. headers: {
  491. "x-captcha-token": token,
  492. "x-client-id": "Xqp0kJBXWhwaTpB6",
  493. "x-device-id": "925b7631473a13716b791d7f28289cad",
  494. },
  495. success: (response) => {
  496. logger.debug("checkXunlei detail response", response);
  497. let state = 1;
  498. // 请求限制
  499. if (!response) {
  500. state = 0
  501. } else if (response.includes("NOT_FOUND")
  502. || response.includes("SENSITIVE_RESOURCE")
  503. || response.includes("EXPIRED")) {
  504. state = -1;
  505. } else if (response.includes("PASS_CODE_EMPTY")) {
  506. state = 2;
  507. }
  508.  
  509. callback && callback({
  510. state: state
  511. });
  512. },
  513. error: function () {
  514. callback && callback({
  515. state: 0
  516. });
  517. }
  518.  
  519. })
  520. },
  521. error: function () {
  522. callback && callback({
  523. state: 0
  524. });
  525. }
  526. });
  527. }
  528. },
  529. nainiu: {
  530. reg: /(?:https?:\/\/)?(?:[\w\-]+\.)?\bcowtransfer\.com\/s\/([\w\-]{10,})(?!\.)/gi,
  531. replaceReg: /(?:https?:\/\/)?(?:[\w\-]+\.)?cowtransfer\.com\/s\/([\w\-]{10,})(?!\.)/gi,
  532. prefix: "https://cowtransfer.com/s/",
  533. checkFun: (shareId, callback) => {
  534. logger.info("nainiu check id", shareId);
  535. http.ajax({
  536. type: "get",
  537. url: "https://cowtransfer.com/core/api/transfer/share?uniqueUrl=" + shareId,
  538. success: (response) => {
  539. logger.debug("nainiu check response", response);
  540. let rsp = typeof response == "string" ? JSON.parse(response) : response;
  541. let state = 1;
  542.  
  543. // 请求限制
  544. if (!response) {
  545. state = 0
  546. } else if (rsp.code != "0000") {
  547. state = -1;
  548. } else if (rsp.data.needPassword && rsp.data.needPassword) {
  549. state = 2;
  550. }
  551.  
  552. callback && callback({
  553. state: state
  554. });
  555. },
  556. error: function () {
  557. callback && callback({
  558. state: 0
  559. });
  560. }
  561. });
  562. }
  563. },
  564. wenshushu: {
  565. reg: /(?:https?:\/\/)?\bt.wss.ink\/f\/([\w\-]{8,})(?!\.)/gi,
  566. replaceReg: /(?:https?:\/\/)?wss1.cn\/f\/([\w\-]{8,})(?!\.)/gi,
  567. prefix: "https://t.wss.ink/f/",
  568. checkFun: (shareId, callback) => {
  569. logger.info("wenshushu id", shareId);
  570. http.ajax({
  571. type: "post",
  572. url: "https://www.wenshushu.cn/ap/task/mgrtask",
  573. data: JSON.stringify({
  574. tid: shareId
  575. }),
  576. headers: {
  577. "Content-Type": "application/json",
  578. "x-token": "wss:7pmakczzw6i"
  579. },
  580. dataType: "json",
  581. success: (response) => {
  582. logger.debug("wenshushu response ", response);
  583. let state = 1;
  584. // 请求限制
  585. if (!response) {
  586. state = 0
  587. } else if (response.code != 0) {
  588. state = -1;
  589. }
  590.  
  591. callback && callback({
  592. state: state
  593. });
  594. },
  595. error: function () {
  596. callback && callback({
  597. state: 0
  598. });
  599. }
  600. });
  601. }
  602. },
  603. pan115: {
  604. reg: /(?:h?ttps?:\/\/)?(?:www\.)?\b115\.com\/s\/([\w\-]{8,})(?!\.)/gi,
  605. replaceReg: /(?:h?ttps?:\/\/)?(?:www\.)?115\.com\/s\/([\w\-]{8,})(?!\.)/gi,
  606. prefix: "https://115.com/s/",
  607. checkFun: (shareId, callback) => {
  608. logger.info("Pan115 check id " + shareId);
  609. shareId = shareId.replace("https://115.com/s/", "");
  610. http.ajax({
  611. type: "get",
  612. url: "https://webapi.115.com/share/snap?share_code=" + shareId + "&receive_code=",
  613. success: (response) => {
  614. logger.debug("115Pan check response", response);
  615. let rsp = typeof response == "string" ? JSON.parse(response) : response;
  616. let state = 0;
  617. // 请求限制
  618. if (!response) {
  619. state = 0
  620. } else if (rsp.state) {
  621. state = 1;
  622. } else if (rsp.error.includes("访问码")) {
  623. state = 2;
  624. } else if (rsp.error.includes("链接")) {
  625. state = -1;
  626. }
  627.  
  628. callback && callback({
  629. state: state
  630. });
  631. },
  632. error: function () {
  633. callback && callback({
  634. state: 0
  635. });
  636. }
  637. });
  638. }
  639. },
  640. caiyun: {
  641. reg: /(?:https?:\/\/)?\bcaiyun\.139\.com\/[mw]\/i[\?\/]([\w-]+)(?!\.)/gi,
  642. replaceReg: /(?:https?:\/\/)?caiyun\.139\.com\/[mw]\/i[\?\/]([\w-]+)(?!\.)/gi,
  643. prefix: "https://caiyun.139.com/w/i/",
  644. checkFun: (shareId, callback) => {
  645. logger.debug("caiyun checkFun", shareId);
  646. http.ajax({
  647. type: "post",
  648. url: "https://caiyun.139.com/stapi/custom/outlink/brief",
  649. data: "linkId=" + shareId,
  650. headers: {
  651. "Content-Type": "application/x-www-form-urlencoded"
  652. },
  653. success: (response) => {
  654. let rsp = typeof response == "string" ? JSON.parse(response) : response;
  655. logger.debug("caiyun chec", shareId, rsp);
  656.  
  657. let state = 0;
  658. // 请求限制
  659. if (!response) {
  660. state = 0
  661. } else if (rsp.code == 0) {
  662. state = rsp.data.isPasswd === "1" ? 2 : 1;
  663. } else {
  664. state = -1;
  665. }
  666.  
  667. callback && callback({
  668. state: state
  669. });
  670. },
  671. error: () =>
  672. callback && callback({
  673. state: 0
  674. })
  675.  
  676. });
  677. }
  678. }
  679. };
  680. });
  681.  
  682. /** step 2 auto_fill **/
  683. container.define("auto_fill", ["checkManage"], function (checkManage) {
  684.  
  685. var obj = {
  686. run() {
  687. this.autoFillPassword();
  688. return false;
  689. },
  690. opt: {
  691. baidu: {
  692. reg: /((?:https?:\/\/)?(?:yun|pan)\.baidu\.com\/(?:s\/\w*(((-)?\w*)*)?|share\/\S{4,}))/,
  693. host: /(pan|yun)\.baidu\.com/,
  694. input: ['#accessCode'],
  695. button: ['#submitBtn'],
  696. name: '百度网盘'
  697. },
  698. aliyun: {
  699. reg: /((?:https?:\/\/)?(?:(?:www\.)?aliyundrive\.com\/s|alywp\.net)\/[A-Za-z0-9]+)/,
  700. host: /www\.aliyundrive\.com|alywp\.net/,
  701. input: ['.ant-input[placeholder="请输入提取码"]'],
  702. button: ['.button--fep7l', 'button[type="submit"]'],
  703. name: '阿里云盘'
  704. },
  705. weiyun: {
  706. reg: /((?:https?:\/\/)?share\.weiyun\.com\/[A-Za-z0-9]+)/,
  707. host: /share\.weiyun\.com/,
  708. input: ['.mod-card-s input[type=password]'],
  709. button: ['.mod-card-s .btn-main'],
  710. name: '微云'
  711. },
  712. lanzou: {
  713. reg: /((?:https?:\/\/)?(?:[A-Za-z0-9\-.]+)?lanzou[a-z]\.com\/[A-Za-z0-9_\-]+)/,
  714. host: /(?:[A-Za-z0-9.]+)?lanzou[a-z]\.com/,
  715. input: ['#pwd'],
  716. button: ['.passwddiv-btn', '#sub'],
  717. name: '蓝奏云'
  718. },
  719. tianyi: {
  720. reg: /((?:https?:\/\/)?cloud\.189\.cn\/(?:t\/|web\/share\?code=)?[A-Za-z0-9]+)/,
  721. host: /cloud\.189\.cn/,
  722. input: ['.access-code-item #code_txt'],
  723. button: ['.access-code-item .visit'],
  724.  
  725. },
  726. caiyun: {
  727. reg: /((?:https?:\/\/)?caiyun\.139\.com\/m\/i\?[A-Za-z0-9]+)/,
  728. host: /caiyun\.139\.com/,
  729. input: ['.token-form input[type=text]'],
  730. button: ['.token-form .btn-token'],
  731. name: '和彩云',
  732. },
  733. xunlei: {
  734. reg: /((?:https?:\/\/)?pan\.xunlei\.com\/s\/[\w-]{10,})/,
  735. host: /pan\.xunlei\.com/,
  736. input: ['.pass-input-wrap .td-input__inner'],
  737. button: ['.pass-input-wrap .td-button'],
  738. name: '迅雷云盘'
  739. },
  740. pan123: {
  741. reg: /((?:https?:\/\/)?www\.123pan\.com\/s\/[\w-]{6,})/,
  742. host: /www\.123pan\.com/,
  743. input: ['.ca-fot input'],
  744. button: ['.ca-fot button'],
  745. name: '123云盘'
  746.  
  747. },
  748. pan115: {
  749. reg: /((?:https?:\/\/)?115\.com\/s\/[\w-]{6,})/,
  750. host: /115\.com/,
  751. input: ['.form-decode input'],
  752. button: ['.form-decode .button'],
  753. name: '115'
  754. },
  755. quark: {
  756. reg: /((?:https?:\/\/)?pan\.quark\.cn\/s\/[\w-]{6,})/,
  757. host: /pan\.quark\.cn/,
  758. input: ['.ant-input[placeholder="请输入提取码,不区分大小写"]'],
  759. button: ['button[type="button"]'],
  760. name: 'quark'
  761. },
  762. },
  763. //根据域名检测网盘类型
  764. panDetect() {
  765. let hostname = location.hostname;
  766. for (let name in this.opt) {
  767. let val = this.opt[name];
  768. if (val.host.test(hostname)) {
  769. return name;
  770. }
  771. }
  772. return '';
  773. },
  774. isHidden(el) {
  775. try {
  776. return el.offsetParent === null;
  777. } catch (e) {
  778. return false;
  779. }
  780. },
  781.  
  782. sleep(time) {
  783. return new Promise((resolve) => setTimeout(resolve, time));
  784. },
  785. //自动填写密码
  786. autoFillPassword() {
  787. let query = getQuery('pwd');
  788. let hash = location.hash.slice(1).replace("/list/share", "");
  789. let pwd = query || hash;
  790. let panType = this.panDetect();
  791. let val = this.opt[panType];
  792. console.warn(">>>>autoFillPassword", query, hash, panType);
  793. // 从本地数据库查找
  794. if (!pwd) {
  795. let shareId = window.location.pathname.substring(window.location.pathname.lastIndexOf("/") + 1);
  796. if (shareId === "init")
  797. shareId = getQuery('surl');
  798. console.warn(">>>>>>>", panType, val, shareId)
  799. let item = checkManage.getItem(panType, shareId);
  800. // 百度有两种格式,默认没找到,查找baidu2
  801. if (!item && panType === "baidu") {
  802. item = checkManage.getItem("baidu2", shareId);
  803. console.warn(">>>>baidu2", shareId)
  804. }
  805. console.warn(">>>>item", item)
  806. if (item) {
  807. pwd = item.pwd;
  808. }
  809. console.warn(">>>>pwd", pwd)
  810. }
  811. pwd && this.doFillAction(val.input, val.button, pwd);
  812.  
  813. },
  814. doFillAction(inputSelector, buttonSelector, pwd) {
  815. let maxTime = 10;
  816. let ins = setInterval(async () => {
  817. maxTime--;
  818. let input = document.querySelector(inputSelector[0]) || document.querySelector(inputSelector[1]);
  819. let button = document.querySelector(buttonSelector[0]) || document.querySelector(buttonSelector[1]);
  820.  
  821. if (input && !this.isHidden(input)) {
  822. clearInterval(ins);
  823. let lastValue = input.value;
  824. input.value = pwd;
  825. //Vue & React 触发 input 事件
  826. let event = new Event('input', {
  827. bubbles: true
  828. });
  829. let tracker = input._valueTracker;
  830. if (tracker) {
  831. tracker.setValue(lastValue);
  832. }
  833. input.dispatchEvent(event);
  834.  
  835. await this.sleep(1000); //1秒后点击按钮
  836. button.click();
  837.  
  838. } else {
  839. maxTime === 0 && clearInterval(ins);
  840. }
  841. }, 800);
  842. }
  843. };
  844.  
  845. return obj;
  846. });
  847.  
  848. container.define("gm", [], function () {
  849. return {
  850. ready: function (callback) {
  851. if (typeof GM_getValue != "undefined") {
  852. callback && callback();
  853. } else {
  854. setTimeout(function () {
  855. obj.ready(callback);
  856. }, 100);
  857. }
  858. }
  859. };
  860. });
  861.  
  862. /** common **/
  863. container.define("gmDao", [], function () {
  864. var obj = {
  865. items: {}
  866. };
  867.  
  868. obj.get = function (name) {
  869. return GM_getValue(name);
  870. };
  871.  
  872. obj.getBatch = function (names) {
  873. var items = {};
  874. names.forEach(function (name) {
  875. items[name] = obj.get(name);
  876. });
  877. return items;
  878. };
  879.  
  880. obj.getAll = function () {
  881. return obj.getBatch(GM_listValues());
  882. };
  883.  
  884. obj.set = function (name, item) {
  885. GM_setValue(name, item);
  886. };
  887.  
  888. obj.setBatch = function (items) {
  889. for (var name in items) {
  890. obj.set(name, items[name]);
  891. }
  892. };
  893.  
  894. obj.setAll = function (items) {
  895. var names = GM_listValues();
  896. names.forEach(function (name) {
  897. if (!items.hasOwnProperty(name)) {
  898. obj.remove(name);
  899. }
  900. });
  901. obj.setBatch(items);
  902. };
  903.  
  904. obj.remove = function (name) {
  905. GM_deleteValue(name);
  906. };
  907.  
  908. obj.removeBatch = function (names) {
  909. names.forEach(function (name) {
  910. obj.remove(name);
  911. });
  912. };
  913.  
  914. obj.removeAll = function () {
  915. obj.removeBatch(GM_listValues());
  916. };
  917.  
  918. return obj;
  919. });
  920.  
  921. container.define("ScopeDao", [], function () {
  922. return function (dao, scope) {
  923. var obj = {
  924. items: {}
  925. };
  926.  
  927. obj.get = function (name) {
  928. return obj.items[name];
  929. };
  930.  
  931. obj.getBatch = function (names) {
  932. var items = {};
  933. names.forEach(function (name) {
  934. if (obj.items.hasOwnProperty(name)) {
  935. items[name] = obj.items[name];
  936. }
  937. });
  938. return items;
  939. };
  940.  
  941. obj.getAll = function () {
  942. return obj.items;
  943. };
  944.  
  945. obj.set = function (name, item) {
  946. obj.items[name] = item;
  947.  
  948. obj.sync();
  949. };
  950.  
  951. obj.setBatch = function (items) {
  952. obj.items = Object.assign(obj.items, items);
  953.  
  954. obj.sync();
  955. };
  956.  
  957. obj.setAll = function (items) {
  958. obj.items = Object.assign({}, items);
  959.  
  960. obj.sync();
  961. };
  962.  
  963. obj.remove = function (name) {
  964. delete obj.items[name];
  965.  
  966. obj.sync();
  967. };
  968.  
  969. obj.removeBatch = function (names) {
  970. names.forEach(function (name) {
  971. delete obj.items[name];
  972. });
  973.  
  974. obj.sync();
  975. };
  976.  
  977. obj.removeAll = function () {
  978. obj.items = {};
  979.  
  980. obj.getDao().remove(obj.getScope());
  981. };
  982.  
  983. obj.init = function () {
  984. var items = obj.getDao().get(obj.getScope());
  985. if (items instanceof Object) {
  986. obj.items = items;
  987. }
  988. };
  989.  
  990. obj.sync = function () {
  991. obj.getDao().set(obj.getScope(), obj.items);
  992. };
  993.  
  994. obj.getDao = function () {
  995. return dao;
  996. };
  997.  
  998. obj.getScope = function () {
  999. return scope;
  1000. };
  1001.  
  1002. return obj.init(),
  1003. obj;
  1004. };
  1005. });
  1006.  
  1007. // 网络请求库 GM_xmlhttpRequest
  1008. container.define("http", ["logger"], function (logger) {
  1009. return {
  1010. ajax: function (option) {
  1011. var details = {
  1012. method: option.type,
  1013. url: option.url,
  1014. responseType: option.dataType,
  1015. onload: function (result) {
  1016. option.success && option.success(result.response);
  1017. },
  1018. onerror: function (result) {
  1019. option.error && option.error(result.error);
  1020. }
  1021. };
  1022.  
  1023. // 提交数据
  1024. if (option.data instanceof Object) {
  1025. if (option.data instanceof FormData) {
  1026. details.data = option.data;
  1027. } else {
  1028. var formData = new FormData();
  1029. for (var i in option.data) {
  1030. formData.append(i, option.data[i]);
  1031. }
  1032. details.data = formData;
  1033. }
  1034. } else {
  1035. details.data = option.data;
  1036. details.dataType = "json";
  1037. }
  1038.  
  1039. // 自定义头
  1040. if (option.headers) {
  1041. details.headers = option.headers;
  1042. }
  1043.  
  1044. // 超时
  1045. if (option.timeout) {
  1046. details.timeout = option.timeout;
  1047. }
  1048.  
  1049. logger.debug("xmlhttpRequest", details)
  1050. GM_xmlhttpRequest(details);
  1051. }
  1052. };
  1053. });
  1054. //日志库
  1055. container.define("logger", [], function () {
  1056. var obj = {
  1057. constant: {
  1058. DEBUG: 0,
  1059. INFO: 1,
  1060. WARN: 2,
  1061. ERROR: 3,
  1062. NONE: 4
  1063. }
  1064. };
  1065.  
  1066. obj.debug = function () {
  1067. obj.log(obj.constant.DEBUG, ...arguments);;
  1068. }
  1069. obj.info = function () {
  1070. obj.log(obj.constant.INFO, ...arguments)
  1071. };
  1072. obj.warn = function () {
  1073. obj.log(obj.constant.WARN, ...arguments)
  1074. };
  1075. obj.error = function () {
  1076. obj.log(obj.constant.ERROR, ...arguments)
  1077. };
  1078. obj.d = function () {
  1079. obj.log(obj.constant.NONE, ...arguments)
  1080. };
  1081. obj.log = function () {
  1082. if (arguments[0] < manifest["logger_level"]) {
  1083. return false;
  1084. }
  1085.  
  1086. console.log(...Array.from(arguments).slice(1).filter(data => data))
  1087. console.groupEnd();
  1088. };
  1089.  
  1090. return obj;
  1091. });
  1092.  
  1093. container.define("appRunner", ["logger", "$"], function (logger, $, require) {
  1094. var obj = {};
  1095.  
  1096. obj.run = function (appList) {
  1097. $(function () {
  1098. obj.runAppList(appList);
  1099. });
  1100. };
  1101.  
  1102. obj.runAppList = function (appList) {
  1103. var url = location.href;
  1104. // 网盘页面不提取密码
  1105. $(document).ready(function () {
  1106. if (excludingPwdHosts.indexOf(location.host) == -1) {
  1107. // 移除知乎错误的attr
  1108. setTimeout(() => $("div").removeAttr("href"), 5000);
  1109. var hasClicks = !!document.querySelector(".clicks");
  1110. var bodyEle = hasClicks ? $("body").clone(true) : $("body");
  1111. if (hasClicks)
  1112. bodyEle.find(".clicks,.only-like").remove();
  1113. var rrr = bodyEle.text()
  1114. .replaceAll("如遇到有带x的提取码请手打输入", "提取码")
  1115. .match(/(?<=\.baidu\.com|lanzou.\.com|weiyun.com|189\.cn|115\.com|139\.com|aliyundrive.com|123pan.com|quark.cn|xunlei.com)\/\S+(\s*([\((])?(?:(提取|访问|訪問|密)[码碼]|Code:)\s*[::﹕ ]?\s*|[\?&](?:pwd|password)=|#)([a-zA-Z\d]{4,8})/g);
  1116. for (let s in rrr) {
  1117. console.log(typeof s, "---", typeof rrr[s])
  1118.  
  1119. if (typeof rrr[s] === "function")
  1120. continue;
  1121. console.log(s, "---", rrr[s])
  1122.  
  1123. let r = /([\w-]{4,})(?:\.html)?[\W]*?(?:(?:[&?]pwd=|[&?]password=)|#)?([a-z\d]{4,8})\s*/ig.exec(rrr[s]
  1124. .replace("/web/share?code=", "")
  1125. .replace("/share/init?surl=", ""));
  1126. if (r) {
  1127. passMap[r[1]] = r[2];
  1128. console.log(r[1], " 密码---", r[2])
  1129. }
  1130. }
  1131. // 百度知道 网盘链接解析
  1132. var baiduZhidaos = document.querySelectorAll(".ikqb-reply-yun");
  1133. if (baiduZhidaos) {
  1134. for (let baiduZhidao of baiduZhidaos) {
  1135. var bdcode = baiduZhidao.attributes['data-code'].value
  1136. var bdlink = baiduZhidao.attributes['data-href'].value
  1137. passMap[bdlink.substring(bdlink.lastIndexOf("/") + 1)] = bdcode;
  1138. }
  1139. }
  1140. var freedict = document.querySelectorAll("a.inline-onebox");
  1141. if (freedict) {
  1142. for (let free of freedict) {
  1143. if (free.textContent.includes("请输入提取码")) {
  1144. var bdcode = /提取码: *(\w+)\b/ig.exec(free.parentElement.textContent)[1];
  1145. var bdlink = free.href;
  1146. passMap[bdlink.substring(bdlink.lastIndexOf("/") + 1)] = bdcode;
  1147. if (bdcode && free.href.indexOf("pwd=") === -1) {
  1148. var linker = free.href.indexOf("?") > -1 ? "&" : "?"
  1149. free.href = free.href + linker + "pwd=" + bdcode
  1150. }
  1151. }
  1152. }
  1153. }
  1154. }
  1155. for (var i in appList) {
  1156. var app = appList[i];
  1157. var match = obj.matchApp(url, app);
  1158. if (match == false) {
  1159. continue;
  1160. }
  1161. if (require(app.name).run() == true) {
  1162. break;
  1163. }
  1164. }
  1165. });
  1166.  
  1167. };
  1168.  
  1169. obj.matchApp = function (url, app) {
  1170. var match = false;
  1171.  
  1172. app.matchs && app.matchs.forEach(function (item) {
  1173. //console.error("matchApp",url,app)
  1174. if (item == "*" || (url && url.match(item))) {
  1175. match = true;
  1176. }
  1177. });
  1178. return match;
  1179. };
  1180.  
  1181. return obj;
  1182. });
  1183.  
  1184. /** custom **/
  1185. container.define("factory", ["gmDao", "ScopeDao"], function (gmDao, ScopeDao) {
  1186. var obj = {
  1187. daos: {}
  1188. };
  1189.  
  1190. obj.getStorageDao = () => obj.getDao("storage", () => ScopeDao(gmDao, "$storage"));
  1191. obj.getCheckDao = () => obj.getDao("check", () => ScopeDao(gmDao, "$check"));
  1192.  
  1193. obj.getDao = function (key, createFunc) {
  1194. if (!obj.daos.hasOwnProperty(key)) {
  1195. obj.daos[key] = createFunc();
  1196. }
  1197. return obj.daos[key];
  1198. };
  1199.  
  1200. return obj;
  1201. });
  1202. //网盘状态icon资源
  1203. container.define("resource", [], function () {
  1204. var obj = {};
  1205. obj.getErrorIcon = () => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAACm0lEQVR4Xu2Xv47TQBDGfSf+iGQdCSS4gpKr4I6TvQl0lLwEb0HFS9BQ09JR8wQ0UNDQIihAoCsgdhJfOHF3ZsaSrfG36/U6cVIgPumnKPbM7Hh2Z70Ogv/aotI4fJPqcDrXYT4fE/S7oN+ZDpczrb4u9PAx+mxEeRDspFH4jgbO0w7kD0b5/L66hfF6URqpV10TQrii9HCXMPbK4oA4yHqoFzhGJ2XjQWQG7YdEhz9xPC9lR4OIpu4CA/ZJEodfcNxWYZBNQQ//FsduVP9ryk1+GFzHHAzNYvUaHTcNdzvmURPd3UWnPvCZgUQPn2E+lWgnf48OSKKv3ilsPRtDVsO1D/4eO6rmcsRBWGcT00ZyAoPRa+o72kjm++qmtK+Ehg1cSJ+m5DApujZFGxM1lT6Fklh9NA3tnE+wEvX7WFm6lmIMG5ltOunGDA1dcKWkPyfL17FSSce40reQT+dYqE0rnyLkf2qmXxYfJ9K/EJ+n0MgHrFyp1GtNmWCcVStWkD+ESml1ijbe3BvdkLFWTmxpW7BBc7e2gXH4KTM0asPsPnVW/++3CUukfxnkBxq5wEqV3YdrjhsCfV1I30LTSD1CoyYwqdRc6F6bMPJnUl+rldDQhjl99s0TK5d6TOs0Gj6VPpXanowbRNq3bZ74hjhtiU/GO9K+0uJguIfGElmt1Jy+Jqppben8T6WdVXz8sDhVcHL0Xv2G111wTP4QxusSzMNQroPL6LQF/M79tHZeWpw3Aq87HN+pZIUNtysL3TGpUvRhcozB+oKTyu8GV3BMb/FHKQZdF+f5vouyw4FuaXVvaIl8wPhri7aK53z8xcE8+YzxetfJ0bXb9OTLtr3pnF/g8egJzdsuxtiajg+CPTrk7dvfKf+Q/gIqVFE2PCWqFwAAAABJRU5ErkJggg==";
  1206. obj.getSuccessIcon = () => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAACrUlEQVR4Xt2Yu2sUQRzHV/BFxNzMXhEQkRAEJbd763+gnYIWVjYitrYBC8FaSzttFBs7LQQLMdnZ3SSKWFhoYWFvOl+IoImJ5283Znf2O7PPmz3QL3zIcff9PZidnUcs63/V4Nm07QTskhvaC8PAvuoIfu7Y0tQh9E1EjmD3qIn1YWiP6G8xESHsNYw3qtlodv9wmavFa+Kt9keu35vDvGNpGPAnWKgtruDrmL+V3IBvYfKxoSkwEPYZrFVPI2uXt6JJahAn4texbKW6bmoHJ+xdwNqFooBNTNAlWF8rmlMPMLBzoorm5h9ae5WgSSHYXewnFb3K5t/AuoQlo6aYTRLvEhU7BW1nt7EnGi32CI0GebVThz5/0fye4C1rRo1W9w00GkGw93KdOZ/3FI+E7E1UNcxtoDn7Dus4Pj+LvlyMzxYydwdvIzW1khXY1syidaDGAGSnEc+3T2sMKiG/QWvOYTrKqL9JUFNvpX5Soa+A71mAYJc1hhx0EPSlGhTDP6En8QX8jeyLlYyUxlvARhroBPyKxgDwO1KtRPR9rjk3YEvoqfn4ZDbTYFoqzmsMeQoWQGr487aHp0uCLCVPBW5g/0iD531+BA1FSDVT0ZwL8LuGjy+FpsLHXCI0FFK14VqtHl+Gz0QuWXJxQFMRFc0p/gaciqzdmOwDmkrRzLm2j08GcyZCUyXSyLnPe7z145OQ+0nlrarGOnhNpkEJg5fTNvaUKL73oXlSxIOC/eSEAZPi6FNrH/aiyMRcaYIn2GPsQSs3ZCcxuDOEvYX1S0Ur8DUliWHiuyvWrSU34hcxmUF+Y73GMj3n6BSS33bGEe3698dt8MSL/iheiDG3EVGDt+LbDBYtg+brz+PiYB9zdSa6B96kwmvEN+LX3xGN/+/xNTmfvbb2YMw/rz8ZKxg+Um5CmgAAAABJRU5ErkJggg==";
  1207. obj.getLockIcon = () => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAABwUlEQVR4Xu1XvUoDQRA+0EoMub+oJBpv9wQLFSzsbASfwc4nsLMwcffERPEJbH0BQXwG2zQWEmttRIuA2Ch2Ohs4vMzueUncjRDug6/Zmdnvy85m99aycuQYIzi0XnWr9RU8/i/wKLv3aPTlUY4IY4S94HzjcEK+KptR0yH8HNcbgVNlm1g8iy5hj3ge7cCiom1OwC5LwcGcHTTs4kK04YcNyZxDDs/wXNoAe+qzR5DwZ5wTA1q4i83hHD0o7U33CIVHmUIu4afJGmhpC+f8GSBykRQpl5tTOEcF8QOMrhr8/d/jycUewvE0uJRfGTUGAm3YYy1BWL07HE9Dkda24zowpr+VRuCFx93NaoIujTpYry/Asj8ke2yE8/sVrJsJ6O2HNJFmwgW+hnUzMZix7oX8ChygxrQxdATMED4r5aTQqLFChXlSLWE3OE9Fo8Ysa2dCruUM56lo1Jgd8HVc61L2hvNUNGpM0LK2JuM6OOmvcTyNxo1B7m1c5y81FXE1c2MCubH++PPk8sXFL8XVHIEx+PztvhX5Ex7/jSMxNgyHMgbnUQdPpJs2iRaxbib85VpB/YzXQz880f8dnyPHuOIbV69cHR4KWOMAAAAASUVORK5CYII=";
  1208. obj.getOtherIcon = () => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAD5UlEQVR4Xr2YT2jTUBzHMxR0wmDaNXndxIk6EA9TEPQo/rns5MHtJjK2JrHrhhcRBP/cRHYTFMXDQBAVdhVBBGEHDx48iHhQEQ8DFYS5Jenabd3i71eX9uXbpE3S6gce697vb977vT+JoiTAVZSOwlhPr2WIT+v5jLt8UbgONdsUboH+rk5k3JUJ4Vq6pv8a6+lC+7Zjm+nhNQrKCcRpnLxjimfor2VKo+kBJyBg3MY+LFN7i/4TUcrVB8BgPJW2ITbo/zX+zdOJemhTzHf3Y6xIcB1xraBTbpv9s4uGuh/tZGxTm+JpRPta0x6iTUPcEWVL0NQVc/y06mHUb8b8yO7OyqgG+LQN7T3qhxKUFDl4hXpxoQfuDJpmx1BfoG4dQUPv6OkjqNcKgaOXTZ1CvSo0KnUGPA2o1w7KE/DwlCzXNeopTlbVMKliTt2HemFY+b7UgpHZ40ykhTt1YBvKg1jJ+WdnjZJFnbq6sgxtBnUQ2tnH3Mn6qee2wf165hzaIBj3u9G7oypc1NUzsrBETyLZBkL71rxsw1sI12d9catzaCtjG+pdeKhCVYjOSk32Jzojr3i6/MQoXzZSx2V/KEdw1Lz+DrmTz0LZKAh55aLMgxbSm1ry6m2Uy1immJFzcAwxrfwe7+6XO6nNoiEi6a6jzIPq72otkPYU5TK8WOQcVnkRYK1YRuogGiaBpvub55OOLhPlSFmaBd7nfB1B9ZIEOgOveT65flEeBOl+lQfItwtHddIISuqDHID3R9QJgnTv+RILWxFJKMu3EboGobwRli4uhyZGv8toEBXfGUtXbpQ3g2xyvsTkqawUXUJa9WHr4oYvMfkymLT4HVO7VHWqa09QHgWyfe1LDK85aBAFKvDBJTNznlshmzmK8ihUzlY5D37FkjtorifR6H9QkHLgJBWX3vvkxHhfQ6N/jW3uOuQbHFP8PfhxOt3RvdvBtinuTWUrjfZJ7I8CXp2qpw+/rciCJBttzV77gbJG8HuAHLtuVeNG6w4pkW6hzPKFVF/VjusjBhiXVvgtnwJ1zskKcUeNjyK6viy4Qff2ECy6RDYcLQ/MPlSxDRSyqbNyLG6hNxs335VCZf5qg3qtUtTFCYxDF8ufqOeDFB6gEX+/QL2k0JQ/Rv+Ry4a/e6Fx5fuXod1B3TiQn3X0G7tc6PXtOTqpJGjypyTx6MtQtHdHJ7tzEPcpr0UeKcQZ1057XwqD2ubG/JGSneajzDK1cfp7nabrJZ8g+Pblb9pnjBcLXv7NvpHFaTx1S6PpAYyTmOERZQs5LmGgqI0TohKYRr9thQLdD6sbuVW+1xriHSV1DH004w9PygmOZFyzWwAAAABJRU5ErkJggg==";
  1209. obj.getStyleText = () => ".one-pan-tip { cursor: pointer;}" +
  1210. ".one-pan-tip::before {background-position: center;background-size: 100% 100%;background-repeat: no-repeat;box-sizing: border-box;width: 1em;height: 1em;margin: 0 1px .15em 1px;vertical-align: middle;display: inline-block;}" +
  1211. ".one-pan-tip-success::before {content: '';background-image: url(" + obj.getSuccessIcon() + ")}" +
  1212. ".one-pan-tip-error {text-decoration: line-through;}" +
  1213. ".one-pan-tip-error::before {content: '';background-image: url(" + obj.getErrorIcon() + ")}" +
  1214. ".one-pan-tip-other::before {content: '';background-image: url(" + obj.getOtherIcon() + ")}" +
  1215. ".one-pan-tip-lock::before{content: '';background-image: url(" + obj.getLockIcon() + ")}";
  1216. return obj;
  1217. });
  1218.  
  1219. //检测网盘链接
  1220. container.define("api", ["logger", "constant"], function (logger, constant) {
  1221. return {
  1222. checkLinkLocal: function (shareSource, shareId, callback) {
  1223. logger.info("checkLinkLocal", shareSource, shareId);
  1224. var rule = constant[shareSource];
  1225. if (rule) {
  1226. rule["checkFun"](shareId, callback)
  1227. } else {
  1228. callback({
  1229. state: 0
  1230. });
  1231. }
  1232. }
  1233. };
  1234. });
  1235.  
  1236. container.define("checkManage", ["logger", "factory", "api"], function (logger, factory, api) {
  1237. var obj = {
  1238. active: false,
  1239. timer: null,
  1240. queues: []
  1241. };
  1242.  
  1243. obj.activeQueue = function () {
  1244. if (!obj.active) {
  1245. obj.active = true;
  1246. obj.consumeQueue();
  1247. }
  1248. };
  1249.  
  1250. obj.consumeQueue = function () {
  1251. if (obj.queues.length) {
  1252. obj.timer && clearTimeout(obj.timer);
  1253.  
  1254. var items = [];
  1255. while (obj.queues.length && items.length < 5) {
  1256. items.push(obj.queues.shift());
  1257. }
  1258. obj.checkLinkBatch(items, obj.consumeQueue);
  1259. } else {
  1260. obj.active = false;
  1261. obj.timer = setTimeout(obj.consumeQueue, 1000);
  1262. }
  1263. };
  1264.  
  1265. obj.checkLinkAsync = function (shareSource, shareId, pwd, bearTime, callback) {
  1266. obj.queues.push({
  1267. share_source: shareSource,
  1268. share_id: shareId,
  1269. bear_time: bearTime,
  1270. pwd,
  1271. callback
  1272. });
  1273. obj.activeQueue();
  1274. };
  1275.  
  1276. obj.checkLinkBatch = function (items, callback) {
  1277. obj.syncLinkBatch(items, function () {
  1278. callback();
  1279. items.forEach(function (item) {
  1280. try {
  1281. obj.checkLink(item.share_source, item.share_id, item.pwd, item.bear_time, item.callback);
  1282. } catch (err) {
  1283. logger.error(err);
  1284. }
  1285. });
  1286. });
  1287. };
  1288.  
  1289. obj.checkLink = function (shareSource, shareId, pwd, bearTime, callback) {
  1290. let item = obj.getItem(shareSource, shareId);
  1291. bearTime || (bearTime = 86400 * 1000);
  1292. //失效链接,不再进行请求,有效及带密码链接(1 ,2 )1天内更新, 异常(0)链接重新请求
  1293. if (item && item.check_time && (item.check_state < 0 || (item.check_state >= 1 && new Date()).getTime() - item.check_time < bearTime)) {
  1294. if (item.check_state < 0) {
  1295. logger.info("=====checkLink state from db===== ", "无效链接,不再进行网络请求");
  1296. } else {
  1297. logger.info("=====checkLink state from db===== 剩余缓存时效(min) ", Math.round((bearTime - new Date().getTime() + item.check_time) / 1000 / 60));
  1298. }
  1299. callback && callback({
  1300. state: item.check_state
  1301. });
  1302. } else {
  1303. logger.info("=====checkLink state from net=====")
  1304. api.checkLinkLocal(shareSource, shareId, function (item) {
  1305. if (item instanceof Object && item.state != 0) {
  1306. obj.setItem(shareSource, shareId, item.state, pwd);
  1307. }
  1308. callback && callback(item);
  1309. });
  1310. }
  1311. };
  1312.  
  1313. obj.syncLinkBatch = function (items, callback) {
  1314. var linkList = [];
  1315. items.forEach(function (item) {
  1316. linkList.push(obj.buildShareKey(item.share_source, item.share_id));
  1317. });
  1318. callback && callback();
  1319. };
  1320.  
  1321. obj.getItem = function (shareSource, shareId) {
  1322. let key = obj.buildShareKey(shareSource, shareId);
  1323. var conf = GM_getValue("$check");
  1324. return conf && conf.hasOwnProperty(key) && conf[key];
  1325. };
  1326.  
  1327. obj.setItem = function (shareSource, shareId, checkState, pwd) {
  1328. pwd = pwd == undefined || pwd === "undefined" ? "" : pwd
  1329. obj.getDao().set(obj.buildShareKey(shareSource, shareId), obj.buildItem(shareId, shareSource, checkState, pwd));
  1330. };
  1331.  
  1332. obj.buildItem = function (shareId, shareSource, checkState, pwd) {
  1333. return {
  1334. share_id: shareId,
  1335. share_source: shareSource,
  1336. check_state: checkState,
  1337. pwd,
  1338. check_time: (new Date()).getTime()
  1339. };
  1340. };
  1341.  
  1342. obj.buildShareKey = function (shareSource, shareId) {
  1343. return shareSource + "#" + shareId;
  1344. };
  1345. obj.getDao = function () {
  1346. return factory.getCheckDao();
  1347. };
  1348. return obj;
  1349. });
  1350.  
  1351. container.define("core", ["resource", "$"], function (resource, $) {
  1352. var obj = {};
  1353. obj.appendStyle = function () {
  1354. var styleText = resource.getStyleText();
  1355. $("<style></style>").text(styleText).appendTo($("head"));
  1356. };
  1357.  
  1358. obj.ready = function (callback) {
  1359. obj.appendStyle();
  1360. callback && callback();
  1361. };
  1362.  
  1363. return obj;
  1364. });
  1365.  
  1366. /** step 2 app_check_url **/
  1367. container.define("app_check_url", ["constant", "checkManage", "findAndReplaceDOMText", "$", "logger"], function (constant, checkManage, findAndReplaceDOMText, $, logger) {
  1368. var obj = {
  1369. index: 0
  1370. };
  1371.  
  1372. obj.run = function () {
  1373. obj.runMatch();
  1374. return false;
  1375. };
  1376.  
  1377. obj.runMatch = function () {
  1378.  
  1379. // 创建链接span
  1380. for (var rule in constant) {
  1381. obj.replaceTextAsLink(constant[rule]["replaceReg"], rule, function (match) {
  1382. return match[1];
  1383. });
  1384. }
  1385.  
  1386. // 补超链接ATTR
  1387. $("a:not([one-link-mark])").each(function () {
  1388. var $this = $(this);
  1389. var href = $this.attr("href");
  1390. if (panRule.exec(href) == null) {
  1391. return;
  1392. }
  1393. // logger.error("@@@@@@@@@@", href)
  1394. if (href) {
  1395. href = href.replace("#list/path=%2F", "");
  1396. // 匹配域名
  1397. if (href.includes(manifest["debugId"])) {
  1398. logger.error("补超链接 --" + href + "--");
  1399. }
  1400.  
  1401. for (var rule in constant) {
  1402. if (constant[rule]["reg"].exec(href) && $this.find(".one-pan-tip").length == 0) {
  1403. $this.attr("one-link-mark", "yes");
  1404. logger.error(constant[rule]["reg"], href, constant[rule]["reg"].exec(href), "___")
  1405.  
  1406. // 知乎卡片不处理
  1407. if ($this.hasClass("LinkCard")) {
  1408. break;
  1409. }
  1410. var node = obj.createOneSpanNode(href, rule);
  1411. if (href.includes(manifest["debugId"])) {
  1412. logger.error("create node", node);
  1413. }
  1414. logger.error("node", node)
  1415. $this.wrapInner(node);
  1416. break;
  1417. }
  1418. }
  1419. }
  1420. });
  1421.  
  1422. // 检查链接状态并加上超链接
  1423. $(".one-pan-tip:not([one-tip-mark])").each(function () {
  1424. let $this = $(this);
  1425. $this.attr("one-tip-mark", "yes");
  1426. let shareSource = $this.attr("one-source");
  1427. let shareId = $this.attr("one-id");
  1428.  
  1429. var shareId2 = RegExp(shareId + "[\\w-]+").exec(document.body.innerHTML);
  1430. if (shareId2 && shareId != shareId2[0]) {
  1431. logger.error("shareId 2 ", shareId, shareId2[0]);
  1432. shareId = shareId2[0];
  1433. }
  1434. let pwd = $this.attr("one-pwd");
  1435.  
  1436. let parentNode = this.parentNode;
  1437. let pp = parentNode.parentNode;
  1438. let shareUrl = obj.buildShareUrl(shareId, shareSource, pwd);
  1439. pwd = $this.attr("one-pwd");
  1440.  
  1441. if (shareId.includes(manifest["debugId"])) {
  1442. logger.error("check link " + shareUrl);
  1443. }
  1444. if (parentNode.nodeName != "A") {
  1445. // 转超链接
  1446. $this.wrap('<a href="' + shareUrl + '" target="_blank"></a>');
  1447. } else if (constant[shareSource]["aTagRepalce"]) {
  1448. let replacePair = constant[shareSource]["aTagRepalce"];
  1449. // 失效域名替换
  1450. parentNode.href = shareUrl.replace(replacePair[0], replacePair[1])
  1451. } else {
  1452. parentNode.href = shareUrl;
  1453. }
  1454.  
  1455. checkManage.checkLinkAsync(shareSource, shareId, pwd, 0, (response) => {
  1456. if (response.state == 2) {
  1457. $this.addClass("one-pan-tip-lock");
  1458. } else if (response.state == 1) {
  1459. $this.addClass("one-pan-tip-success");
  1460. } else if (response.state == -1) {
  1461. $this.addClass("one-pan-tip-error");
  1462. } else {
  1463. $this.addClass("one-pan-tip-other");
  1464. }
  1465. });
  1466.  
  1467. });
  1468.  
  1469. // 异常信息重新请求
  1470. $(".one-pan-tip-other").each(function () {
  1471. let $this = $(this);
  1472. let shareSource = $this.attr("one-source");
  1473. let shareId = $this.attr("one-id");
  1474. let pwd = $this.attr("one-pwd");
  1475. checkManage.checkLinkAsync(shareSource, shareId, pwd, 0, (response) => {
  1476. $this.removeClass("one-pan-tip-other")
  1477. if (response.state == 2) {
  1478. $this.addClass("one-pan-tip-lock");
  1479. } else if (response.state == 1) {
  1480. $this.addClass("one-pan-tip-success");
  1481. } else if (response.state == -1) {
  1482. $this.addClass("one-pan-tip-error");
  1483. } else {
  1484. $this.addClass("one-pan-tip-other");
  1485. }
  1486. });
  1487. })
  1488.  
  1489. let checkTimes = manifest["checkTimes"];
  1490. if (checkTimes == 0 || obj.index < checkTimes) {
  1491. obj.index++;
  1492. setTimeout(obj.runMatch, 1000 * manifest["checkInterval"]);
  1493. }
  1494. };
  1495.  
  1496. obj.replaceTextAsLink = function (shareMatch, shareSource, getShareId) {
  1497. findAndReplaceDOMText(document.body, {
  1498. find: shareMatch,
  1499. replace: function (portion, match) {
  1500. let parentNode = portion.node.parentNode;
  1501. let pp = parentNode.parentNode;
  1502. let ppp = pp.parentNode;
  1503. if (parentNode.nodeName == "SPAN" && $(parentNode).hasClass("one-pan-tip")
  1504. || $(portion.node).hasClass("one-pan-tip")
  1505. || (pp.nodeName == "SPAN" && $(pp).hasClass("one-pan-tip"))
  1506. || (ppp.nodeName == "SPAN" && $(ppp).hasClass("one-pan-tip"))
  1507. || !portion.text.includes("/")) {
  1508. return portion.text;
  1509. } else {
  1510. let shareId = getShareId(match);
  1511. if (shareId.includes(manifest["debugId"])) {
  1512. logger.error("replaceTextAsLink 000 ", portion, pp);
  1513. logger.error("replaceTextAsLink 001 ", pp.innerText);
  1514. }
  1515.  
  1516. var shareId2 = RegExp(shareId + "[\\w-]+").exec(document.body.inn);
  1517. if (shareId2) {
  1518. shareId = shareId2[0];
  1519. }
  1520.  
  1521. let node = obj.createOneSpanNode(shareId, shareSource);
  1522. node.textContent = obj.buildShowText(shareId, shareSource);
  1523. if (shareId.includes(manifest["debugId"])) {
  1524. logger.error("replaceTextAsLink " + shareId, node);
  1525. logger.error("replaceTextAsLink shareId2 ", shareId2);
  1526. }
  1527. return node;
  1528. }
  1529. },
  1530. forceContext: function (el) {
  1531. return true;
  1532. }
  1533. });
  1534. };
  1535.  
  1536. obj.findATagCode = function (shareId, shareSource) {
  1537. var tag = document.querySelector("a[href*='" + shareId + "']");
  1538. if (tag) {
  1539. var reg = new RegExp("(?:\\s*(?:[\\((])?(?:(?:提取|访问|訪問|密)[码碼]| Code:)\\s*[::﹕ ]?\\s*|[\\?&]pwd=|#)([a-zA-Z\\d]{4,8})", "g");
  1540. console.log("___ a href 0", tag.href);
  1541. var mm = reg.exec(tag.innerText);
  1542. if (mm && mm[1]) {
  1543. //tag.href =obj.buildShareUrl(shareId,shareSource,mm[1]);
  1544. console.log("___ a href 1", tag.href, mm[1]);
  1545. return mm[1];
  1546. } else {
  1547. var regHref = /(?:pwd=|#)([a-zA-Z\d]{4,8})/g;
  1548. mm = regHref.exec(decodeURIComponent(tag.href));
  1549. if (mm && mm[1]) {
  1550. //tag.href =obj.buildShareUrl(shareId,shareSource,mm[1]);
  1551. console.log("___ a href 2", mm);
  1552. return mm[1];
  1553. }
  1554. }
  1555. }
  1556. }
  1557. obj.createOneSpanNode = function (shareId, shareSource) {
  1558. if (shareId.includes(manifest["debugId"])) {
  1559. logger.error("createOneSpanNode ", shareId);
  1560. }
  1561.  
  1562. var m = /https:\/\/.*\/(?:init\?surl=)?([\w-]+)(?:(?:[\?&]pwd=|#)(\w+))?/g.exec(shareId);
  1563. shareId = m && m[1] || (shareId.includes("http") ? shareId.replace(/^.*?([\w-]+$)/i, "$1") : shareId);
  1564. var code = m && m[2] || passMap[shareId] || obj.findATagCode(shareId, shareSource);
  1565.  
  1566. var node = document.createElementNS(document.lookupNamespaceURI(null) || "http://www.w3.org/1999/xhtml", "span");
  1567. node.setAttribute("class", "one-pan-tip");
  1568. node.setAttribute("one-id", shareId);
  1569. node.setAttribute("one-pwd", code);
  1570. node.setAttribute("one-source", shareSource);
  1571. return node;
  1572. };
  1573.  
  1574. obj.buildShareUrl = function (shareId, shareSource, pwd) {
  1575. var m = /https:\/\/.*\/([\w-]+)(?:(?:\?pwd=|#)(\w+))?/g.exec(shareId);
  1576. shareId = m && m[1] || (shareId.includes("http") ? shareId.replace(/^.*?([\w-]+$)/i, "$1") : shareId);
  1577. let code = m && m[2] || pwd || passMap[shareId] || obj.findATagCode(shareId, shareSource);
  1578. // 如果没有重新查找
  1579. if (code == "undefined" || code == "Code" || typeof (code) == "undefined") {
  1580. if (shareId.includes(manifest["debugId"])) {
  1581. logger.error(shareId + " search");
  1582. }
  1583.  
  1584. var reg = new RegExp(shareId + "(?:\\s*(?:[\\((])?(?:(?:提取|访问|訪問|密)[码碼]| Code:)\\s*[::﹕ ]?\\s*|[\\?&]pwd=|#)([a-zA-Z\\d]{4,8})", "g");
  1585. var mm = reg.exec(document.body.innerText);
  1586. if (mm) {
  1587. passMap[shareId] = mm[1];
  1588. code = mm[1];
  1589. if (shareId.includes(manifest["debugId"])) {
  1590. logger.error(code + " search");
  1591. }
  1592. document.querySelectorAll("span[one-id='" + shareId + "']")
  1593. .forEach(e => e.setAttribute("one-pwd", code));
  1594.  
  1595. logger.info("buildCode reset", code);
  1596. }
  1597. }
  1598.  
  1599. let appendCode = shareSource == "ty189" || shareSource == "pan123" ? "#" : "?pwd=";
  1600. logger.info("buildCode", code, appendCode);
  1601. if (code == "undefined") {
  1602. code = ""
  1603. } else {
  1604. code = code ? (appendCode + code) : "";
  1605. }
  1606. let shareUrl = constant[shareSource]["prefix"] + shareId + code;
  1607. // 修复https://pan.baidu.com/share/init?surl=xxxxxxx
  1608. if (shareUrl.includes("/share/init?surl=")) {
  1609. shareUrl = shareUrl.replace("/share/init?surl=", "/s/1")
  1610. }
  1611. return shareUrl;
  1612. };
  1613. obj.buildShowText = function (shareId, shareSource) {
  1614. return constant[shareSource]["prefix"] + shareId;
  1615. };
  1616.  
  1617. return obj;
  1618. });
  1619.  
  1620. // step 1 入口app
  1621. container.define("app", ["appRunner"], function (appRunner) {
  1622. return {
  1623. run: function () {
  1624. appRunner.run([{
  1625. name: "app_check_url",
  1626. matchs: ["*"]
  1627. }, {
  1628. name: "auto_fill",
  1629. matchs: [
  1630. /(pan|yun)\.baidu\.com/,
  1631. /www\.aliyundrive\.com|alywp\.net/,
  1632. /share\.weiyun\.com/,
  1633. /(?:[A-Za-z0-9.]+)?lanzou[a-z]\.com/,
  1634. /cloud\.189\.cn/,
  1635. /caiyun\.139\.com/,
  1636. /pan\.xunlei\.com/,
  1637. /pan\.quark\.cn/,
  1638. /www\.123pan\.com/,
  1639. /115\.com/,
  1640. ]
  1641. }
  1642. ]);
  1643. }
  1644. };
  1645. });
  1646.  
  1647. // lib
  1648. container.define("$", [], () => window.$);
  1649. // dom替换
  1650. container.define("findAndReplaceDOMText", [], () => typeof findAndReplaceDOMText != "undefined" ? findAndReplaceDOMText : window.findAndReplaceDOMText);
  1651. // 入口
  1652. container.use(["gm", "core", "app", "logger"], (gm, core, app, logger) => gm.ready(() => {
  1653. core.ready(app.run)
  1654. window.navigation.oncurrententrychange = () => {
  1655. // console.log("onhashchange");
  1656. app.run();
  1657. }
  1658.  
  1659. }));
  1660. })();

QingJ © 2025

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