-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook-duoshuo.js
More file actions
46 lines (44 loc) · 1.27 KB
/
hook-duoshuo.js
File metadata and controls
46 lines (44 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
if (typeof DUOSHUO !== 'undefined') {
hook_duoshuo_templates();
} else {
$('#duoshuo-script')[0].onload = hook_duoshuo_templates;
}
var is_hook_duoshuo = false;
function hook_duoshuo_templates() {
if (is_hook_duoshuo) {
return;
} else {
is_hook_duoshuo = true;
}
var _D_post = DUOSHUO.templates.post;
DUOSHUO.templates.post = function(e, t) {
var rs = _D_post(e, t);
var is_admin;
if (typeof duoshuo_user_ID !== 'undefined') {
if (e.post.author.user_id && (e.post.author.user_id == duoshuo_user_ID)) {
if(duoshuo_admin_nickname){
is_admin = '<span class="this_ua admin">'+duoshuo_admin_nickname+'</span>'
}else{
is_admin = '<span class="this_ua admin">博主</span>'
}
} else {
is_admin = '';
}
} else {
is_admin = '';
}
var agent = e.post.agent;
if (agent && /^Mozilla/.test(agent)) {
rs = rs.replace(/<\/div><p>/, is_admin + show_ua(agent) + '</div><p>')
};
return rs;
}
}
function show_ua(string) {
$.ua.set(string);
var sua = $.ua;
if (sua.os.version == 'x86_64') {
sua.os.version = 'x64';
}
return '<span class="this_ua platform ' + sua.os.name + '">' + sua.os.name + ' ' + sua.os.version + '</span><span class="this_ua browser ' + sua.browser.name + '">' + sua.browser.name + ' | ' + sua.browser.version + '</span>';
}