-
-
Save RobertYim/30d4f5a4c8b77a02e8c21e175c2970d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name sinaimg | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match *://*.sinaimg.cn/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function string62to10(number_code) { | |
number_code = String(number_code); | |
var chars = '0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ', | |
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); | |
} | |
} | |
// window.location = 'https://weibo.com/u/' + decode(window.location.href); | |
window.location = 'https://m.weibo.cn/u/' + decode(window.location.href); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment