|
8 | 8 | // @downloadURL https://github.com/jerone/UserScripts/raw/master/Github_News_Feed_Filter/Github_News_Feed_Filter.user.js |
9 | 9 | // @updateURL https://github.com/jerone/UserScripts/raw/master/Github_News_Feed_Filter/Github_News_Feed_Filter.user.js |
10 | 10 | // @include https://github.com/ |
11 | | -// @version 2.0 |
| 11 | +// @version 3.0 |
12 | 12 | // @grant none |
13 | 13 | // ==/UserScript== |
14 | 14 |
|
|
26 | 26 | } |
27 | 27 |
|
28 | 28 | function addFilters() { |
29 | | - var container; |
30 | | - if (!(container = document.querySelector(".news"))) return; |
| 29 | + var container = document.querySelector(".news"); |
| 30 | + if (!container) return; |
31 | 31 |
|
32 | 32 | var ul = document.createElement("ul"); |
33 | 33 | ul.classList.add("dashboard-tabs"); |
| 34 | + container.insertBefore(ul, container.firstChild); |
34 | 35 | [{ text: "", icon: "octicon-comment-discussion", filter: ["*"] }, |
35 | | - { text: "Comments", icon: "octicon-comment", filter: ["issues_comment"] }, |
36 | 36 | { text: "Commits", icon: "octicon-git-commit", filter: ["push"] }, |
37 | 37 | { text: "Pull Requests", icon: "octicon-git-pull-request", filter: ["pull_request"] }, |
38 | | - { text: "Issues", icon: "octicon-issue-opened", filter: ["issues_opened", "issues_closed"] } |
| 38 | + { text: "Issues", icon: "octicon-issue-opened", filter: ["issues_opened", "issues_comment", "issues_closed", "issues_reopened"] }, |
| 39 | + { text: "Stars", icon: "octicon-star", filter: ["watch_started"] }, |
| 40 | + { text: "Repo", icon: "octicon-repo", filter: ["create"] }, |
| 41 | + { text: "Wiki", icon: "octicon-book", filter: ["gollum"] } |
39 | 42 | ].forEach(function(item) { |
40 | 43 | var li = document.createElement("li"); |
41 | 44 | var a = document.createElement("a"); |
42 | 45 | a.classList.add("js-selected-navigation-item"); |
43 | 46 | a.setAttribute("href", "/"); |
44 | 47 | a.setAttribute("title", item.filter.join(" & ")); |
| 48 | + a.style.lineHeight = "28px"; |
45 | 49 | var s = document.createElement("span"); |
46 | 50 | s.classList.add("octicon", item.icon); |
47 | 51 | if (item.filter == "*") { |
48 | 52 | li.style.cssFloat = "left"; |
49 | | - li.style.width = "41px"; |
| 53 | + li.style.width = "34px"; |
50 | 54 | a.classList.add("selected"); |
51 | 55 | } else { |
52 | 56 | s.style.marginRight = "6px"; |
|
58 | 62 | var alerts = container.querySelectorAll(".alert"); |
59 | 63 | Array.forEach(alerts, function(alert) { |
60 | 64 | if (alert.getElementsByClassName("octicon-git-pull-request").length > 0) { |
61 | | - alert.classList.remove("issues_opened"); |
62 | | - alert.classList.remove("issues_closed"); |
| 65 | + alert.classList.remove("issues_opened", "issues_closed"); |
63 | 66 | alert.classList.add("pull_request"); |
64 | 67 | } |
65 | 68 | }); |
|
78 | 81 | ul.appendChild(li); |
79 | 82 | }); |
80 | 83 |
|
81 | | - container.insertBefore(ul, container.firstChild); |
82 | | - |
83 | 84 | // update on clicking "More"-button; |
84 | | - var event = new Event("click"); |
85 | 85 | $.pageUpdate(function() { |
86 | 86 | window.setTimeout(function() { |
87 | | - container.querySelector(".selected").dispatchEvent(event); |
| 87 | + container.querySelector(".selected").dispatchEvent(new Event("click")); |
88 | 88 | }, 1); |
89 | 89 | }); |
90 | 90 | } |
|
0 commit comments