Skip to content

Instantly share code, notes, and snippets.

@icyleaf
Created September 4, 2012 10:03
Show Gist options
  • Save icyleaf/3619416 to your computer and use it in GitHub Desktop.
Save icyleaf/3619416 to your computer and use it in GitHub Desktop.
Pure New Weibo Mod By icyleaf (Chrome Only version: http://t.cn/zWgW1nw)
// ==UserScript==
// @name Pure New Weibo Mod By icyleaf
// @description this script support both firefox and chrome, you need to install the Greasemonkey add-on for Firefox. A minor revision based on roamlog's style: http://stylebot.me/styles/669.
// @version 5.0.6 (2012.09.05)
// @include http://weibo.com/*
// @include https://weibo.com/*
// @include http://t.sina.com.cn/*
// @include https://t.sina.com.cn/*
// @include http://www.weibo.com/*
// @include https://www.weibo.com/*
// @author icyleaf
// ==/UserScript==
var pure = {
init: function()
{
var ver = pure.parse_url(window.location.href).query.wvr;
if (ver == null)
ver = document.getElementsByClassName('gn_logo')[0].getAttribute('href').match(/wvr=(\d+)/)[1];
if (ver == 3 || ver == 4)
{
pure.clearly_for_v3();
}
else if (ver == 5)
{
pure.clearly_for_v5();
pure.alawys_show_all_user_groups();
pure.change_two_columns();
}
pure.is_debug_mode();
// Debug infos (only in debug mode)
pure.debug('ua: ' + navigator.userAgent);
pure.debug('weibo version: ' + ver);
},
clearly_for_v3: function()
{
var styleEl = document.createElement('style');
styleEl.type = 'text/css';
styleEl.innerHTML = '.declist, .send_weibo .title,#pl_content_userInfo,#pl_content_commentTopNav,#pl_content_hisTags,#pl_content_favoritesTopNav,#pl_relation_recommendAttUsers,#pl_content_chainFollowers,.M_activities,#pl_content_sameFriends,#pl_content_myTags,#pl_common_thirdmodule_1003,#pl_content_hisOperationPlate,#pl_content_weibodesk,#pl_content_medal,#pl_common_noticeboard,#pl_content_userTips,#pl_content_followStatus,#pl_content_interestgroup,#ads_bottom_1, dd.settings,.tipsinvite,.level,#base_scrollToTop, #trustPagelet_recom_member, #Pl_Rightmod_Littlehelp, #pl_content_hisFans,#pl_leftNav_game,#pl_rightmod_medal, #pl_content_topic,.W_other_app, #pl_common_fun, #pl_content_pullylist, #pl_content_mood, #ads_37,#pl_content_promoteto, #pic pl_common_feedback,.footer_adv,.border, #pl_leftNav_app, #trustPagelet_member_zone, .global_footer,#trustPagelet_yunying_olympic, #trustPagelete_recom_interest,#trustPagelete_recom_allinone,#pl_rightmod_help,#pl_rightmod_noticeboard,#trustPagelete_zt_hottopic,.f_pro,.nfTagB_group,.deal_view2,#pl_content_promotetopic, #pl_content_homeInterest, #pl_relation_recommendPopularUsers, #pl_content_allInOne, #pl_content_topic, #pl_common_help, #pl_common_feedback, #pl_common_reportentry,.rightTxtList { display: none;}.W_linedot, .W_rightModule { border-bottom: none;}#pl_content_liteFacePersonInfo .W_rightModule, #pl_content_litePersonInfo .W_rightModule, #pl_content_personInfo .W_rightModule { padding-bottom: 0;}.nfTagB_sec { border-top: none; padding: 2px 0;}.left_nav .user_atten { margin: 0 0 0 17px;}.send_weibo .kind { padding: 5px 0 10px 0;}.send_weibo .kind a { margin: 0 15px 0 0; padding: 2px 0 2px 20px; }.left_nav .user_atten li { margin: 0 5px 0 0;}.B_index .feed_lists { margin-top: 10px;}.left_nav .border, .nfTagB_sec { background: none;}.border:nth-child(1), .border:nth-child(2),.W_main_narrow #Box_right { display: block;}.W_main { width: 750px;}.W_main .W_main_c{ float: none;}.W_main_c { padding: 0 30px 30px; }.W_main_bg { min-height: 1000px;}#wbim_box { right: 0;}.W_main .left_nav .border{ padding: 0;}.W_main_r .left_nav { border-bottom-color: none; border-bottom-style: none;} .W_main_r .user_atten { border-bottom-color: none; border-bottom-style: none; border-bottom: none; margin: 0; padding:0 10px 10px; }';
document.documentElement.appendChild(styleEl);
},
clearly_for_v5: function()
{
var styleElement = document.createElement('style');
styleElement.type = 'text/css';
styleElement.innerHTML = 'a.W_gotop{margin-left:415px}.WB_left_nav .lev a:hover, .WB_left_nav .lev2 a:hover, .WB_left_nav .lev2 a.lev_curr, .WB_left_nav .lev2 a.lev_curr:hover {background-image:none}.S_bg4, .WB_left_nav a.lev_curr, .WB_left_nav a.lev_curr:hover, a.W_gotop:hover{background:#EEE}.WB_left_nav .level_1_Box .lev a{margin-left:1px}div.WB_global_nav div.gn_search{margin:7px 0 0 120px}div.W_main{background-position:-150px 0px}div.W_main{width:830px}div.W_main_a{float:left;width:830px;overflow:hidden}div.profile_right_module{border:none}.WB_global_nav .gn_bg{background-image:none;} div.gn_title,div#pl_profile_modulePublicGroupRecommend,div#trustPagelet_mblog_music,div#pl_rightmod_recommblog,div.global_footer,div#pl_leftnav_app,div#trustPagelet_recom_interestv5,div#trustPagelet_zt_hottopicv5,div#trustPagelet_recom_memberv5,div#trustPagelet_recom_allinonev5,div#pl_rightmod_noticeboard,div.S_textb,div#pl_rightmod_yunying,div#pl_rightmod_ads35,div.tips_wrapper,div.prm_app_con{display:none}';
document.documentElement.appendChild(styleElement);
},
change_two_columns: function()
{
var leftElement = document.getElementsByClassName('W_main_l')[0];
var rightElement = document.getElementById('Box_right');
rightElement.innerHTML += leftElement.innerHTML;
leftElement.parentNode.removeChild(leftElement);
},
alawys_show_all_user_groups: function()
{
var groupElement = document.getElementById('pl_leftnav_group');
var groups = groupElement.getElementsByTagName('div');
for (var i = 0; i < groups.length; i++)
{
var levElement = groups[i];
if (levElement.getAttribute('node-type') == 'moreList')
{
levElement.setAttribute('style', 'display:block');
}
else if (levElement.getAttribute('class') == 'levmore')
{
levElement.setAttribute('style', 'display:none');
}
}
},
is_debug_mode: function()
{
var enable = false;
var debug = pure.parse_url(window.location.href).query.debug;
if (debug == 1) enable = true;
var aElements = document.getElementsByTagName('a');
for (var i = 0; i < aElements.length; i++)
{
var ae = aElements[i];
var href = as.getAttribute('href');
if (enable)
href += (href.match(/\?/g) ? '&' : '?') + 'debug=1';
else
href = href.replace(/debug=\d+/g, '');
ae.setAttribute('href', href);
}
},
debug: function(o)
{
var debug = pure.parse_url(window.location.href).query.debug;
if (debug == 1)
{
console.debug(o);
}
},
parse_url: function(url)
{
var parser = document.createElement('a');
parser.href = url;
var query = {};
var params = parser.search.replace('?', '').split('&');
for (var i = 0; i < params.length; i++)
{
keyValue = params[i].split('=');
query[keyValue[0]] = keyValue[1];
}
return {
'protocol': parser.protocol,
'hostname': parser.hostname,
'port': parser.port,
'path': parser.path,
'search': parser.search,
'query': query,
'hash': parser.hash,
'host': parser.host
};
}
};
// execute it!
window.addEventListener ("load", function(){
pure.init();
}, false);
@icyleaf
Copy link
Author

icyleaf commented Sep 4, 2012

更新历史

5.0.6

  1. 【移除】分组右侧的下箭头
  2. 【优化】下拉页面后右侧“回到顶部"的位置
  3. 【添加】全局的 debug 模式(开启添加 url 的 query 为 debug=1)
  4. 【移除】 Google Analytics 代码(无法进行任何数据的统计)

5.0.5

  1. 【修正】右侧导航栏链接样式问题
  2. 【移除】顶部的无用链接,只保留“搜索”功能,返回首页点击“新浪微博 Logo”
  3. 【添加】Google Analytics 代码(不知道可否统计,实验性质)

5.0.4

  1. 【支持】支持 @roamlog 童鞋的 v3 版本
  2. 【重构】重新调整代码结构
  3. 【支持】添加了 debug 模式

5.0.3

  1. 【更新】左侧导航移到右侧
  2. 【更新】调整整体宽度

5.0.2

  1. 【更新】总是显示用户分组

5.0.1

  1. 【更新】脚本规范
  2. 【移除】个人微博页面的无用元素

5.0

  1. 使脚本适用于新浪微博 v5 版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment