|
8 | 8 | // @namespace https://github.com/hoothin/UserScripts/tree/master/Easy%20offline |
9 | 9 | // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js |
10 | 10 | // @require https://cdnjs.cloudflare.com/ajax/libs/Base64/0.2.0/base64.min.js |
11 | | -// @version 1.8.8 |
| 11 | +// @version 1.8.9 |
12 | 12 | // @author Hoothin |
13 | 13 | // @mail rixixi@gmail.com |
14 | 14 | // @include http*://*/* |
|
445 | 445 | return config[name]?config[name]:name; |
446 | 446 | }; |
447 | 447 |
|
448 | | - var _GM_getValue,_GM_setValue,_GM_deleteValue,_GM_registerMenuCommand; |
| 448 | + var _GM_registerMenuCommand; |
449 | 449 | var _unsafeWindow=(typeof unsafeWindow=='undefined')?window:unsafeWindow; |
450 | | - if(typeof GM_getValue!='undefined'){ |
451 | | - _GM_getValue=GM_getValue; |
452 | | - _GM_setValue=GM_setValue; |
453 | | - _GM_deleteValue=GM_deleteValue; |
| 450 | + if(typeof GM_registerMenuCommand!='undefined'){ |
454 | 451 | _GM_registerMenuCommand=GM_registerMenuCommand; |
455 | | - }else if(typeof GM!='undefined' && typeof GM.getValue!='undefined'){ |
456 | | - _GM_getValue=GM.getValue; |
457 | | - _GM_setValue=GM.setValue; |
458 | | - _GM_deleteValue=GM.deleteValue; |
| 452 | + }else if(typeof GM!='undefined' && typeof GM.registerMenuCommand!='undefined'){ |
459 | 453 | _GM_registerMenuCommand=GM.registerMenuCommand; |
460 | 454 | } |
| 455 | + |
461 | 456 | if(typeof _GM_registerMenuCommand=='undefined')_GM_registerMenuCommand=(s,f)=>{}; |
462 | 457 | var storage={ |
463 | 458 | supportGM: typeof GM_getValue=='function' && typeof GM_getValue('a','b')!='undefined', |
|
479 | 474 | this.operaUJSStorage.setItem(key,value); |
480 | 475 | }else if(this.mxAppStorage){ |
481 | 476 | this.mxAppStorage.setConfig(key,value); |
482 | | - }else if(this.supportGM || this.supportGMPromise){ |
483 | | - _GM_setValue(key,value); |
| 477 | + }else if(this.supportGM){ |
| 478 | + GM_setValue(key,value); |
| 479 | + }else if(this.supportGMPromise){ |
| 480 | + GM.setValue(key,value); |
484 | 481 | }else if(window.localStorage){ |
485 | 482 | window.localStorage.setItem(key,value); |
486 | 483 | } |
|
507 | 504 | }else if(this.mxAppStorage){ |
508 | 505 | this.mxAppStorage.setConfig(key,""); |
509 | 506 | }else if(this.supportGM){ |
510 | | - _GM_deleteValue(key); |
| 507 | + GM_deleteValue(key); |
| 508 | + }else if(this.supportGMPromise){ |
| 509 | + GM.deleteValue(key); |
511 | 510 | }else if(window.localStorage){ |
512 | 511 | window.localStorage.setItem(key,""); |
513 | 512 | } |
|
653 | 652 | var rules=siteRule.split("\n"); |
654 | 653 | rules.forEach(rule=>{ |
655 | 654 | var ruleArr=rule.replace(/\s/g,"").split("@@"); |
656 | | - if(ruleArr[1] && (ruleArr[0].indexOf("$url")!=-1 || ruleArr[0].indexOf("$hash")!=-1 || ruleArr[0].indexOf("${")!=-1)){ |
| 655 | + if(ruleArr[1] && (ruleArr[0].indexOf("$url")!=-1 || ruleArr[0].indexOf("$hash")!=-1 || ruleArr[0].indexOf("${")!=-1 || ruleArr[0].indexOf("$base64")!=-1)){ |
657 | 656 | var siteConfig={}; |
658 | 657 | siteConfig.directUrl=function(offUrl){ |
659 | 658 | if(ruleArr[0].indexOf("${")!=-1){ |
|
666 | 665 | return linkResult?ruleArr[0].replace(/\${.*?}/,linkResult):ruleArr[0]; |
667 | 666 | } |
668 | 667 | var hash=offUrl.replace("magnet:?xt=urn:btih:","").replace(/&.*/,""); |
669 | | - return ruleArr[0].replace("$url", offUrl).replace("$hash", hash); |
| 668 | + var base64Str=btoa(offUrl); |
| 669 | + return ruleArr[0].replace("$url", offUrl).replace("$hash", hash).replace("$base64", base64Str); |
670 | 670 | }; |
671 | 671 | if(ruleArr[2]) { |
672 | 672 | siteConfig.linkRegExp=new RegExp(ruleArr[2],"i"); |
|
0 commit comments