Skip to content

Instantly share code, notes, and snippets.

@loethen
Forked from mysteriouss/sinaimg.js
Created September 5, 2017 03:00
Show Gist options
  • Save loethen/7b862a7b54e2a2f3a15dfad2115cd2f1 to your computer and use it in GitHub Desktop.
Save loethen/7b862a7b54e2a2f3a15dfad2115cd2f1 to your computer and use it in GitHub Desktop.
// ==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);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment