|
8 | 8 | // @namespace http://tampermonkey.net/ |
9 | 9 | // @require https://cdn.jsdelivr.net/jquery/1.7.2/jquery.min.js |
10 | 10 | // @require https://cdn.jsdelivr.net/hi-base64/0.2.0/base64.min.js |
11 | | -// @version 1.3.1 |
| 11 | +// @version 1.3.2 |
12 | 12 | // @author Hoothin |
13 | 13 | // @mail rixixi@gmail.com |
14 | 14 | // @include http*://*/* |
|
351 | 351 | if(/^magnet/.test(url)){ |
352 | 352 | newUrl=newUrl.split("&")[0].substring(20); |
353 | 353 | if(newUrl.length==32){ |
354 | | - newUrl="magnet:?xt=urn:btih:" + base32ToHex(newUrl); |
| 354 | + newUrl="magnet:?xt=urn:btih:" + base32To16(newUrl); |
355 | 355 | }else{ |
356 | 356 | newUrl=url; |
357 | 357 | } |
|
361 | 361 | return newUrl; |
362 | 362 | } |
363 | 363 |
|
364 | | - var b32 = {'a':'00000','b':'00001','c':'00010','d':'00011','e':'00100','f':'00101','g':'00110','h':'00111','i':'01000','j':'01001','k':'01010','l':'01011','m':'01100','n':'01101','o':'01110','p':'01111','q':'10000','r':'10001','s':'10010','t':'10011','u':'10100','v':'10101','w':'10110','x':'10111','y':'11000','z':'11001','2':'11010','3':'11011','4':'11100','5':'11101','6':'11110','7':'11111'}; |
365 | | - var b16 = {'0000':'0','0001':'1','0010':'2','0011':'3','0100':'4','0101':'5','0110':'6','0111':'7','1000':'8','1001':'9','1010':'a','1011':'b','1100':'c','1101':'d','1110':'e','1111':'f'}; |
366 | | - function base32ToHex(str){ |
367 | | - if(str.length % 8 !== 0 || /[0189].test(str)/){ |
| 364 | + function base32To16(str){ |
| 365 | + if(str.length % 8 !== 0 || /[0189]/.test(str)){ |
368 | 366 | return str; |
369 | 367 | } |
370 | | - str = str.toLowerCase(); |
| 368 | + str = str.toUpperCase(); |
371 | 369 | var bin = "", returnStr = "", i; |
372 | 370 | for(i = 0;i < str.length;i++){ |
373 | | - bin += b32[str.substring(i,i+1)]; |
| 371 | + var charCode=str.charCodeAt(i); |
| 372 | + if(charCode<65)charCode-=24; |
| 373 | + else charCode-=65; |
| 374 | + charCode='0000'+charCode.toString(2); |
| 375 | + charCode=charCode.substr(charCode.length-5); |
| 376 | + bin+=charCode; |
374 | 377 | } |
375 | 378 | for(i = 0;i < bin.length;i+=4){ |
376 | | - returnStr += b16[bin.substring(i,i+4)]; |
| 379 | + returnStr += parseInt(bin.substring(i,i+4),2).toString(16); |
377 | 380 | } |
378 | 381 | return returnStr; |
379 | 382 | } |
|
574 | 577 | if (document.readyState == 'complete') { |
575 | 578 | clearInterval(rsc); |
576 | 579 | setTimeout(function() { |
577 | | - Core['OFFL5Plug'].OpenLink(); |
| 580 | + unsafeWindow.Core.OFFL5Plug.OpenLink(); |
578 | 581 | setTimeout(function() { |
579 | 582 | $('#js_offline_new_add').val(curlink); |
580 | | - }, 300); |
| 583 | + }, 1); |
581 | 584 | }, 1000); |
582 | 585 | } |
583 | 586 | }, 300); |
|
0 commit comments