-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add clean-conversation-headers feature
#3408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fregante
merged 17 commits into
refined-github:master
from
kidonng:clean-conversation-headers
Aug 13, 2020
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
77b359e
Add clean-conversation-headers feature
kidonng 11da68a
Fix pending PR and other possible additional meta
kidonng e4a24d1
Finish
kidonng 182c21c
Rewrite initIssue
kidonng 8b965a0
Rewrite initPR
kidonng b90de88
Lint
kidonng c14aa95
Merge branch 'master' into clean-conversation-headers
kidonng 4b03605
Use selector-observer cause why not
kidonng dfd8463
meta
kidonng 621c78f
Prepend
kidonng c34c8ac
Merge branch 'master' into clean-conversation-headers
kidonng 0654416
Hide instead of remove base branch
kidonng f3a639e
Fix selector and add comments
kidonng 772e264
Add screenshot
kidonng e2ac95f
👀
kidonng 50273ac
Merge branch 'master' into clean-conversation-headers
fregante 5aa8a81
Add `waitForDomReady: false` and rename variables
fregante File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import select from 'select-dom'; | ||
| import onetime from 'onetime'; | ||
| import {observe} from 'selector-observer'; | ||
| import * as pageDetect from 'github-url-detection'; | ||
|
|
||
| import features from '.'; | ||
|
|
||
| function initIssue(): void { | ||
| observe('.gh-header-meta .flex-auto', { | ||
| add({childNodes: bylineNodes}) { | ||
| // Removes: octocat opened this issue on 1 Jan [·] 1 comments | ||
| bylineNodes[4].textContent = bylineNodes[4].textContent!.replace('·', ''); | ||
|
|
||
| // Removes: [octocat opened this issue on 1 Jan] · 1 comments | ||
| for (const node of [...bylineNodes].slice(0, 4)) { | ||
| node.remove(); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| function initPR(): void { | ||
| observe('.gh-header-meta .flex-auto', { | ||
| add(byline) { | ||
| const isMerged = select.exists('#partial-discussion-header [title="Status: Merged"]'); | ||
| const isSameAuthor = select('.js-discussion > .TimelineItem:first-child .author')?.textContent === select('.author', byline)!.textContent; | ||
| const baseBranch = select('.commit-ref:not(.head-ref)', byline)!; | ||
| const isDefaultBranch = (baseBranch.firstElementChild as HTMLAnchorElement).pathname.split('/').length === 3; | ||
|
|
||
| // Removes: [octocat wants to merge 1 commit into] github:master from octocat:feature | ||
| // Removes: [octocat merged 1 commit into] master from feature | ||
| // Removes: octocat [merged 1 commit into] github:master from lovelycat:feature | ||
| for (const node of [...byline.childNodes].slice(isSameAuthor ? 0 : 2, isMerged ? 3 : 5)) { | ||
| node.remove(); | ||
| } | ||
|
|
||
| if (!isSameAuthor) { | ||
| byline.prepend('by '); | ||
| } | ||
|
|
||
| if (isDefaultBranch) { | ||
| // Removes: octocat wants to merge 1 commit into [github:dev] from octocat:feature | ||
| baseBranch.hidden = true; | ||
| } else { | ||
| // Add back "into" if the PR base branch is not the default branch | ||
| baseBranch.before('into '); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| void features.add({ | ||
| id: __filebasename, | ||
| description: 'Remove duplicate information in conversation headers.', | ||
| screenshot: 'https://user-images.githubusercontent.com/44045911/89736767-686ec800-da9e-11ea-81c3-252e9813140b.png' | ||
| }, { | ||
| include: [ | ||
| pageDetect.isIssue | ||
| ], | ||
| waitForDomReady: false, | ||
| init: onetime(initIssue) | ||
| }, { | ||
| include: [ | ||
| pageDetect.isPR | ||
| ], | ||
| waitForDomReady: false, | ||
| init: onetime(initPR) | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best to also hide this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a text node