1 .follow_them_box{ 2 position: fixed; 3 right: 200px; 4 top: 200px; 5 background-color: #fff; 6 width: 80px; 7 height: 30px; 8 line-height: 30px; 9 text-align: center;10 cursor: pointer;11 background: #8ab923;12 background-color: #9dcc4a;13 background-image: linear-gradient(top,#adda4d,#86b846);14 background-repeat: repeat-x;15 filter: PRogid:DXImageTransform.Microsoft.gradient(startColorstr='#adda4d', endColorstr='#86b846', GradientType=0);16 text-shadow: 0 1px 0 rgba(255,255,255,.3);17 border: 1px solid #6d8f29;18 color: #3e5e00!important;19 border-radius: 5px;20 box-shadow: 0 1px 0 rgba(255,255,255,.5) inset,0 1px 0 rgba(0,0,0,.2);21 }22 .remove_box{23 top: 260px;24 }
1 { 2 "background": { 3 "persistent": false, 4 "scripts": [ "background.js" ] 5 }, 6 "content_scripts": [ { 7 "CSS": [ "show_follow.css" ], 8 "exclude_matches": [ "http://www.zhihu.com/read" ], 9 "js": [ "jquery-2.1.1.min.js","show_follow.js"],10 "matches": [ "http://www.zhihu.com/*" ]11 } ],12 "description": "批量收听指定用户的好友",13 "icons": {14 "128": "128.png",15 "16": "16.png",16 "48": "48.png"17 },18 "manifest_version": 2,19 "name": "「批量+」",20 "permissions": [ "storage" ],21 "short_name": "批量+",22 "update_url": "https://clients2.google.com/service/update2/crx",23 "version": "1.0"24 }
jQuery(document).ready(function($) { var z_url = "www.zhihu.com"; var follow = { uchk_obj : $('.zm-profile-header-info-title'), flink : $('.zm-profile-side-following>a').attr('href'), fl_btn_obj : $('.zg-btn-follow'), fl_them_div : '<div class="follow_them_box" id="follow_them_box" title="本按钮只在用户好友页有效,收听当前所有新人">follow them</div>', remove_div : '<div class="follow_them_box remove_box" id="remove_box" title="清除页面中已经收听过的人">remove</div>', hash_array : new Array(), uchk : function(){ if (follow.uchk_obj.html() == '获得'){ return true; }else{ console.info('uchk'); return false; } }, show_fl_btn : function(){ $('body').append(follow.fl_them_div); $('body').append(follow.remove_div); }, follow_user : function(uid,xsrf){ $.Ajax({ url: '/node/MemberFollowBaseV2', data: {method:'follow_member', params:'{"hash_id":"'+uid+'"}', _xsrf:xsrf }, dataType: "text", type: "POST", success: function(response) { } }); }, //删除已收听过的人 remove_followed : function(){ $('#remove_box').on("click", function(){ var temp = ''; var uid = '' ; //清空已收听 $('.zg-btn-unfollow').each(function(index, el) { temp = $(this).html(); switch(temp){ case '取消关注': $(this).parents('.zm-profile-section-item').css('display', 'none'); break; default: break; } }); }); }, follow_them : function(){ $('#follow_them_box').on("click", function(){ var xsrf = $("input[name='_xsrf']").val(); $('.zg-btn-follow').each(function(index, el) { uid = $(this).attr('data-id'); $(this).parents('.zm-profile-section-item').css('display', 'none'); follow.hash_array.push(uid); }); var times = 0; var max_num = 0; if (follow.hash_array.length < 50){ max_num = follow.hash_array.length; }else{ max_num = 50; } var int=self.setInterval(function(){ follow.follow_user(follow.hash_array[times],xsrf); times++; if (times == max_num){ follow.hash_array = []; int=window.clearInterval(int); } },1000); }); } }; if ( follow.uchk() ){ follow.show_fl_btn(); follow.remove_followed(); follow.follow_them(); }});
收听完毕。
源文件 下载地址: https://github.com/Martin-Tan/zhi-follow
新闻热点
疑难解答