Skip to content

Commit b544b03

Browse files
committed
fix
1 parent 5787cc9 commit b544b03

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

Easy offline/Easy offline.user.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// @namespace http://tampermonkey.net/
99
// @require https://cdn.jsdelivr.net/jquery/1.7.2/jquery.min.js
1010
// @require https://cdn.jsdelivr.net/hi-base64/0.2.0/base64.min.js
11-
// @version 1.3.1
11+
// @version 1.3.2
1212
// @author Hoothin
1313
// @mail rixixi@gmail.com
1414
// @include http*://*/*
@@ -351,7 +351,7 @@
351351
if(/^magnet/.test(url)){
352352
newUrl=newUrl.split("&")[0].substring(20);
353353
if(newUrl.length==32){
354-
newUrl="magnet:?xt=urn:btih:" + base32ToHex(newUrl);
354+
newUrl="magnet:?xt=urn:btih:" + base32To16(newUrl);
355355
}else{
356356
newUrl=url;
357357
}
@@ -361,19 +361,22 @@
361361
return newUrl;
362362
}
363363

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)){
368366
return str;
369367
}
370-
str = str.toLowerCase();
368+
str = str.toUpperCase();
371369
var bin = "", returnStr = "", i;
372370
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;
374377
}
375378
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);
377380
}
378381
return returnStr;
379382
}
@@ -574,10 +577,10 @@
574577
if (document.readyState == 'complete') {
575578
clearInterval(rsc);
576579
setTimeout(function() {
577-
Core['OFFL5Plug'].OpenLink();
580+
unsafeWindow.Core.OFFL5Plug.OpenLink();
578581
setTimeout(function() {
579582
$('#js_offline_new_add').val(curlink);
580-
}, 300);
583+
}, 1);
581584
}, 1000);
582585
}
583586
}, 300);

0 commit comments

Comments
 (0)