Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
[bilibili_injected.js] add sessionStorage for hash
Browse files Browse the repository at this point in the history
  • Loading branch information
myfreeer committed Nov 22, 2016
1 parent 7af5b29 commit 582dcc7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bilibili_injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@
s.parentNode.removeChild(s);
};
var displayUserInfobyMid = function(mid, hash) {
if (hash && (CRC32.bstr("" + i) >>> 0) === parseInt(hash, 16)) sessionStorage[hash] = mid;
if (hash && (CRC32.bstr("" + mid) >>> 0) === parseInt(hash, 16)) sessionStorage.setItem('hash/' + hash, mid);
if (!mid) return control.find('.result').text('查询失败 :(');
else if (mid === -1) return control.find('.result').text('游客弹幕');
control.find('.result').html('发送者 UID: <a href="http://space.bilibili.com/' + mid + '" target="_blank" mid="' + mid + '">' + mid + '</a>');
Expand Down Expand Up @@ -1067,7 +1067,8 @@
control.find('.result').text('游客弹幕');
return;
}
if (sessionStorage[sender] && (CRC32.bstr("" + sessionStorage[sender]) >>> 0) === parseInt(sender, 16)) return displayUserInfobyMid(sessionStorage[sender]);
var mid = sessionStorage.getItem('hash/' + sender);
if (mid && (CRC32.bstr("" + mid) >>> 0) === parseInt(sender, 16)) return displayUserInfobyMid(mid);
$.ajaxSetup({timeout: 1000});
$.get('http://biliquery.typcn.com/api/user/hash/' + sender, function(data) {
$.ajaxSetup({timeout: 0});
Expand All @@ -1076,11 +1077,11 @@
displayUserInfobyMid(uid, sender);
} else {
var uid = parseSafe(data.data[0].id);
if (uid) displayUserInfobyMid(uid);
displayUserInfobyMid(uid, sender);
}
}, 'json').fail(function() {
var uid = checkCommentHash(sender, 65E6);
displayUserInfobyMid(uid);
displayUserInfobyMid(uid, sender);
});
}
});
Expand Down

0 comments on commit 582dcc7

Please sign in to comment.