Skip to content

Instantly share code, notes, and snippets.

@mysteriouss
Last active September 8, 2017 01:00
Show Gist options
  • Save mysteriouss/29db5320dc6e2c716538164bf6fe7535 to your computer and use it in GitHub Desktop.
Save mysteriouss/29db5320dc6e2c716538164bf6fe7535 to your computer and use it in GitHub Desktop.
function string62to10(number_code) {
number_code = String(number_code)
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
radix = chars.length,
len = number_code.length,
i = 0,
origin_number = 0
while (i < len) {
origin_number += Math.pow(radix, i++) * chars.indexOf(number_code.charAt(len - i) || 0)
}
return origin_number
}
function decode(url) {
var lastIndexOfSlash = url.lastIndexOf('/')
var number = url.substr(lastIndexOfSlash + 1, 8)
if (number.startsWith('00')) {
return string62to10(number)
} else {
return parseInt(number, 16)
}
}
//Open in Safari
//$app.openURL('https://weibo.com/u/' + decode($context.link || $clipboard.link))
//Open in Weibo
$app.openURL('sinaweibo://userinfo?uid=' + decode($context.link || $clipboard.link))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment