MCPcopy Index your code
hub / github.com/hoothin/UserScripts / getRightUrl

Function getRightUrl

Easy offline/Easy offline.user.js:1135–1148  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

1133 }
1134
1135 function getRightUrl(url){
1136 var newUrl = url;
1137 if(/^magnet/.test(url)){
1138 newUrl=newUrl.split("&")[0].substring(20);
1139 if(newUrl.length==32){
1140 newUrl="magnet:?xt=urn:btih:" + base32To16(newUrl);
1141 }else{
1142 newUrl=url;
1143 }
1144 }else if(/^\/\//.test(url)){
1145 newUrl=location.protocol+url;
1146 }
1147 return newUrl;
1148 }
1149
1150 function base32To16(str){
1151 if(str.length % 8 !== 0 || /[0189]/.test(str)){

Callers 1

pageRunFunction · 0.85

Calls 1

base32To16Function · 0.85

Tested by

no test coverage detected