Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Thanks for contributing! 🦋🙌
- [](# "bugs-tab") [Adds a "Bugs" tab to repos, if there are any open issues with the "bug" label.](https://user-images.githubusercontent.com/1402241/73720910-a688d900-4755-11ea-9c8d-70e5ddb3bfe5.png)
- [](# "pinned-issue-update-time") [Adds the updated time to pinned issues.](https://user-images.githubusercontent.com/1402241/75525936-bb524700-5a4b-11ea-9225-466bda58b7de.png)
- [](# "clean-pinned-issues") [Changes the layout of pinned issues from side-by-side to a standard list.](https://user-images.githubusercontent.com/1402241/84509958-c82a3c00-acc4-11ea-8399-eaf06a59e9e4.png)
- [](# "clean-conversation-headers") [Remove duplicate information in conversation headers.](https://user-images.githubusercontent.com/44045911/89736767-686ec800-da9e-11ea-81c3-252e9813140b.png)

<!-- Refer to style guide above. Keep this message between sections. -->

Expand Down
68 changes: 68 additions & 0 deletions source/features/clean-conversation-headers.tsx
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();
Copy link
Member

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

Suggested change
node.remove();
node.hidden = true;

Copy link
Member Author

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

image

}
}
});
}

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)
});
1 change: 1 addition & 0 deletions source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ import './features/use-first-commit-message-for-new-prs';
import './features/linkify-user-edit-history-popup';
import './features/cleanup-repo-filelist-actions';
import './features/prevent-duplicate-pr-submission';
import './features/clean-conversation-headers';

// Add global for easier debugging
(window as any).select = select;