本文已更新匹配2015年新版embed.js!
修改前请确保您的多说核心脚本embed.js已经本地化
远程文件地址:http://static.duoshuo.com/embed.js
检查方法:在有多说回复框的页面点击鼠标右键查看源代码,搜索embed.js,如果找到:http://static.duoshuo.com/embed.js这条网址,说明您的多说没有做过本地化, 请查看:多说社会化评论框核心脚本embed.js本地化方法
注意:回复本文就可以查看到效果了,由于是手工收集整理添加的,可能会出现浏览器及操作系统信息不准确的现象,如果您回复后看到显示的浏览器及操作系统信息不正确,请点击下方报错地址,将您的Useragent信息告诉我,我会及时修改并更新本文!
1.必须完成多说本地化,才能实现.
2.打开本地embed.js在头部插入以下代码:
- //管理员判断开始
- function sskadmin(e) {
- var ssk = '';
- if(e=='你的多说ID'){
- ssk = '<span class="user_admin">管理员</span> '
- }
- return ssk;
- }
- //显UA开始
- function ua(e) {
- var r = new Array;
- var outputer = '';
- if (r = e.match(/MSIE\s([^\s|;]+)/gi)) {
- outputer = '<span class="ua_ie">Internet Explorer' + '|' + r[0]/*.replace('MSIE', '').split('.')[0]*/
- } else if (r = e.match(/FireFox\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_firefox">Mozilla FireFox' + '|' + r1[1]
- } else if (r = e.match(/Maxthon([\d]*)\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_maxthon">Maxthon'
- } else if (r = e.match(/UBrowser([\d]*)\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_ucweb">UCBrowser' + '|' + r1[1]
- } else if (r = e.match(/MetaSr/ig)) {
- outputer = '<span class="ua_sogou">搜狗浏览器'
- } else if (r = e.match(/2345Explorer/ig)) {
- outputer = '<span class="ua_2345explorer">2345王牌浏览器</a>'
- } else if (r = e.match(/2345chrome/ig)) {
- outputer = '<span class="ua_2345chrome">2345加速浏览器</a>'
- } else if (r = e.match(/LBBROWSER/ig)) {
- outputer = '<span class="ua_lbbrowser">猎豹安全浏览器'
- } else if (r = e.match(/MicroMessenger\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_qq">微信' + '|' + r1[1]/*.split('/')[0]*/
- } else if (r = e.match(/QQBrowser\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_qq">QQ浏览器' + '|' + r1[1]/*.split('/')[0]*/
- } else if (r = e.match(/QQ\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_qq">QQ浏览器' + '|' + r1[1]/*.split('/')[0]*/
- } else if (r = e.match(/MiuiBrowser\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_mi">Miui浏览器' + '|' + r1[1]/*.split('/')[0]*/
- } else if (r = e.match(/Chrome([\d]*)\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_chrome">Chrome' + '|' + r1[1]/*.split('.')[0]*/
- } else if (r = e.match(/safari\/([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_apple">Apple Safari' + '|' + r1[1]
- } else if (r = e.match(/Opera[\s|\/]([^\s]+)/ig)) {
- var r1 = r[0].split("/");
- outputer = '<span class="ua_opera">Opera' + '|' + r[1]
- } else if (r = e.match(/Trident\/7.0/gi)) {
- outputer = '<span class="ua_ie">Internet Explorer 11'
- } else {
- outputer = '<span class="ua_other">其它浏览器'
- }
- return outputer+"</span> ";
- }
- function os(e) {
- var os = '';
- if (e.match(/win/ig)) {
- if (e.match(/nt 5.1/ig)) {
- os = '<span class="os_xp">Windows XP'
- } else if (e.match(/nt 6.1/ig)) {
- os = '<span class="os_7">Windows 7'
- } else if (e.match(/nt 6.2/ig)) {
- os = '<span class="os_8">Windows 8'
- } else if (e.match(/nt 6.3/ig)) {
- os = '<span class="os_8_1">Windows 8.1'
- } else if (e.match(/nt 10.0/ig)) {
- os = '<span class="os_8_1">Windows 10'
- } else if (e.match(/nt 6.0/ig)) {
- os = '<span class="os_vista">Windows Vista'
- } else if (e.match(/nt 5/ig)) {
- os = '<span class="os_2000">Windows 2000'
- } else {
- os = '<span class="os_windows">Windows'
- }
- } else if (e.match(/android/ig)) {
- os = '<span class="os_android">Android'
- } else if (e.match(/ubuntu/ig)) {
- os = '<span class="os_ubuntu">Ubuntu'
- } else if (e.match(/linux/ig)) {
- os = '<span class="os_linux">Linux'
- } else if (e.match(/mac/ig)) {
- os = '<span class="os_mac">Mac OS X'
- } else if (e.match(/unix/ig)) {
- os = '<span class="os_unix">Unix'
- } else if (e.match(/symbian/ig)) {
- os = '<span class="os_nokia">Nokia SymbianOS'
- } else {
- os = '<span class="os_other">其它操作系统'
- }
- return os+"</span>" ;
- }
- //显UA结束
3.在embed.js中执行替换操作:
搜索:
- +u(r.name)+"</span>"),t+="</div>"
替换为:
- +u(r.name)+"</span>"),t+= sskadmin(r.user_id) + "<span class=\"ua\">" + ua(s.agent) + "</span><span class=\"ua\">"+ os(s.agent) + "</span>" + "</div>"
4.添加样式文件:
- /*多说UA开始*/
- .user_admin {
- background-color: #F69EE5!important;
- border-color: #357ebd!important;
- color: #FFFFFF!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- span.ua{
- margin: 0 1px!important;
- color:#FFFFFF!important;
- /*text-transform: Capitalize!important;
- float: right!important;
- line-height: 18px!important;*/
- }
- .ua_other.os_other{
- background-color: #ccc!important;
- color: #fff;
- border: 1px solid #BBB!important;
- border-radius: 4px;
- }
- .ua_ie{
- background-color: #428bca!important;
- border-color: #357ebd!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_firefox{
- background-color: #f0ad4e!important;
- border-color: #eea236!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_maxthon{
- background-color: #7373B9!important;
- border-color: #7373B9!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_ucweb{
- background-color: #FF740F!important;
- border-color: #d43f3a!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_sogou{
- background-color: #78ACE9!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_2345explorer{
- background-color: #2478B8!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_2345chrome{
- background-color: #F9D024!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_mi{
- background-color: #FF4A00!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_lbbrowser{
- background-color: #FC9D2E!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_chrome{
- background-color: #EE6252!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_qq{
- background-color: #3D88A8!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_apple{
- background-color: #E95620!important;
- border-color: #4cae4c!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .ua_opera{
- background-color: #d9534f!important;
- border-color: #d43f3a!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .os_vista,.os_2000,.os_windows,.os_xp,.os_7,.os_8,.os_8_1 {
- background-color: #39b3d7!important;
- border-color: #46b8da!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .os_android {
- background-color: #98C13D!important;
- border-color: #01B171!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .os_ubuntu{
- background-color: #DD4814!important;
- border-color: #01B171!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .os_linux {
- background-color: #3A3A3A!important;
- border-color: #1F1F1F!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .os_mac{
- background-color: #666666!important;
- border-color: #1F1F1F!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .os_unix{
- background-color: #006600!important;
- border-color: #1F1F1F!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- .os_nokia{
- background-color: #014485!important;
- border-color: #1F1F1F!important;
- border-radius: 4px;
- padding: 0 5px!important;
- }
- /*多说UA结束*/
5.完成之后刷新评论页看看是否成功。
继续阅读
2015年9月9日 下午9:10 1F
浏览器覆盖的不是很全面
2015年9月13日 上午12:03 B1
@ 飞絮落叶雪 的确··