├── LICENSE ├── README.md └── weibo_tl.user.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kind Jeff 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # weibo_tl 2 | **这是一个油猴脚本。** 3 | 4 | 功能:让PC微博首页时间线按照时间排序。 5 | 6 | 点击链接安装: 7 | https://github.com/sljeff/weibo_tl/raw/master/weibo_tl.user.js 8 | 9 | greasyfork地址: 10 | https://greasyfork.org/zh-CN/scripts/26247 11 | -------------------------------------------------------------------------------- /weibo_tl.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name PC微博首页时间线正确排布 3 | // @description 让微博时间线正确排布 4 | // @namespace https://www.kindjeff.com/ 5 | // @version 2017.2.14 6 | // @author kindJeff 7 | // @match https://weibo.com/* 8 | // @match https://www.weibo.com/* 9 | // @match http://weibo.com/* 10 | // @match http://www.weibo.com/* 11 | // @start-at document-start 12 | // @grant none 13 | // ==/UserScript== 14 | 15 | (function() { 16 | 'use strict'; 17 | 18 | function main(){ 19 | var is_home = window.location.pathname.split('/')[2]=='home'; 20 | var is_sorted = window.location.search.indexOf('is_search')!=-1; 21 | 22 | var right_search = 'is_ori=1&is_forward=1&is_text=1&is_pic=1&is_video=1&is_music=1&is_article=1&is_search=1'; 23 | var sorted_url = '/home?' + right_search; 24 | 25 | 26 | if(is_home && !is_sorted){ 27 | window.location = sorted_url; 28 | }else{ 29 | document.addEventListener('click', function(e){ 30 | var is_target_a = e.target.href!==undefined; 31 | 32 | var the_target = e.target; 33 | if(!is_target_a) 34 | {the_target = e.target.parentNode;} 35 | 36 | if(the_target.href!==undefined){ 37 | if(the_target.href.slice(-12)==='is_search=1#'){ 38 | return; 39 | } 40 | var slash_path = 2; 41 | if(the_target.href.indexOf('://') != -1){ 42 | slash_path = 4; 43 | } 44 | if(the_target.href.split('/')[slash_path].indexOf('home') === 0){ 45 | e.preventDefault(); 46 | 47 | if(the_target.href.indexOf('page=') != -1){ 48 | e.preventDefault(); 49 | var new_href = the_target.href.replace(/pids=Pl_Content_HomeFeed/, ''); 50 | window.location = new_href; 51 | }else{ 52 | window.location = sorted_url; 53 | } 54 | } 55 | } 56 | },true); 57 | } 58 | 59 | } 60 | 61 | main(); 62 | 63 | })(); 64 | --------------------------------------------------------------------------------