Skip to content

Instantly share code, notes, and snippets.

@duangsuse
Last active July 20, 2018 03:04
Show Gist options
  • Save duangsuse/8a5274e9ef51cb90bf11d5e66835ed7b to your computer and use it in GitHub Desktop.
Save duangsuse/8a5274e9ef51cb90bf11d5e66835ed7b to your computer and use it in GitHub Desktop.
AllDreamWall 插件:Linkify 可以让你在查询裸 JSON 时更轻易的在链接中跳转,并为你添加漂亮的注释
plugin Linkify
author duangsuse
description Linkify 可以让你在查询裸 JSON 时更轻易的在链接中跳转,并为你添加漂亮的注释
menuitem Linkify link 🔗
(function(e) {
if (e == 'initialize') {
var tmpold_emitter = emitter; emitter = function(k, v) {
old_emitter = tmpold_emitter
switch (k) {
case 'shareId':
case 'share_id':
return '<a href="' + 'https://popf.rip/all_dream.html?type=work&sid=' + v + '">查看作品</a>'
case 'userid':
case 'stuId':
case 'user_id':
case 'userId':
return '<a href="' + 'https://popf.rip/all_dream.html?type=user&uid=' + v + '">查看用户</a>'
case 'ratio':
return '超过 ' + v + ' 的用户'
case 'file_url':
case 'fileUrl':
case 'cover_url':
case 'imageUrl':
case 'coverUrl':
case 'postUrl':
return '<a href="' + 'https://all-dream.com/' + v + '">查看文档链接</a>'
case 'inventory':
tmp_pase = JSON.parse(v); return typeof tmp_pase['level'] == 'undefined' ? '': '级别:' + tmp_pase['level']
case 'sex':
if (v == '0') return '性别:女'
if (v == '1') return '性别:男'
break
case 'type':
case 'user_type':
case 'shareType':
case 'share_type':
case 'userType':
if (v == 'student') return '类型:学生'
if (v == 'teacher') return '类型:老师'
return '作品类型:' + getSidLogo(v)
case 'total':
return '总共有 ' + v + ' 条项目'
case 'visit':
return '访问量:' + v
case 'star':
return 'Likes:' + v
case 'promote':
return v == 1 ? '被钦定的': ''
case 'lastPage':
case 'pages':
case 'nextPage':
case 'firstPage':
return '<a onclick="pageNum=' + v + '"><em>去往</em></a>'
case 'rank':
return '排名:' + v
case 'totalShare':
return '总共有 ' + v + ' 个分享'
case 'courseTypeName':
return '课程类型:' + v
case 'pageSize':
return '页面大小:' + v
case 'shareTitle':
case 'share_title':
return '分享标题:' + v
case 'grade':
return '年级:' + v
case 'totalShareStar':
return '获得点赞总数:' + v
case 'gold':
return '积分数目:' + v
case 'studentName':
case 'name':
return '用户名:' + v
case 'score':
return '分数:' + v
case 'price':
return '价格:' + v + ' 积分'
case 'remain':
return '剩余数目'
case 'countCourse':
return '课程数:' + v
case 'countCall':
return '上课数:' + v
case 'area':
var tmp_pse = JSON.parse(v)
if (tmp_pse == null)
return '未知地区'
return tmp_pse['province'] + ' 省 ' + tmp_pse['city'] + ' 市 ' + tmp_pse['area'] + ' 区'
default:
if (old_emitter != null) return old_emitter(k, v);
}
}
plugin_emitters['linkify'] = emitter
} else if (e == 'on_menu') mdui.snackbar("Emitter 已经启用", {
tiemout: 1000
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment