sindresorhus/refined-github

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Handle deduplication in feature manager #4830

cheap-glitch posted onGitHub

Description

It'd be great to create a map of "page:deduplicate-selector" so that this can be handled by the feature manager instead of having to manually specify it in every feature, but this might take a little effort.

Anyway this is what I mean:

const deduplicateMap = {
  isPR: '.has-rgh-inner',
  isDashboard: '.has-rgh',
}

Originally posted by @fregante in https://github.com/sindresorhus/refined-github/issues/4695#issuecomment-910508914


<details> <summary>Deduplication table (collected in <code>features.add</code>)</summary> <table> <tr><td><code>*</code></td><td><code>.rgh-view-markdown-source</code>, <code>has-rgh-inner</code>, <code>has-rgh</code>, <code>.rgh-feature-description</code></td></tr> <tr><td><code>hasCode</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code>, <code>.rgh-observing-whitespace</code></td></tr> <tr><td><code>hasComments</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code></td></tr> <tr><td><code>hasFrontMatter</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>hasNotificationBar</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>hasRichTextEditor</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code></td></tr> <tr><td><code>is404</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isActionRun</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isBlame</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isBranches</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isCommit</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isCommitList</code></td><td><code>has-rgh</code>, <code>has-rgh-inner</code></td></tr> <tr><td><code>isCompare</code></td><td><code>has-rgh</code>, <code>has-rgh-inner</code></td></tr> <tr><td><code>isConversation</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isConversationList</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isDashboard</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isDiscussion</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code></td></tr> <tr><td><code>isEditingFile</code></td><td><code>has-rgh</code>, <code>has-rgh-inner</code>, <code>.rgh-list-prs-for-file</code></td></tr> <tr><td><code>isEditingRelease</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isEditingWikiPage</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isForkedRepo</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isGist</code></td><td><code>has-rgh-inner</code>, <code>.rgh-copy-file</code>, <code>has-rgh</code></td></tr> <tr><td><code>isGlobalConversationList</code></td><td><code>has-rgh</code>, <code>has-rgh-inner</code></td></tr> <tr><td><code>isGlobalSearchResults</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isIssue</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isMarketplaceAction</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isMilestone</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isNewFile</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code></td></tr> <tr><td><code>isNewIssue</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isNewRelease</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isNewRepo</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isNewRepoTemplate</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isNewWikiPage</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isNotifications</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isOrganizationProfile</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isOwnUserProfile</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isPR</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code></td></tr> <tr><td><code>isPRCommit404</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isPRCommit</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code></td></tr> <tr><td><code>isPRConflicts</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isPRConversation</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isPRFiles</code></td><td><code>has-rgh-inner</code>, <code>has-rgh</code></td></tr> <tr><td><code>isPRList</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isQuickPR</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isReleasesOrTags</code></td><td><code>has-rgh</code>, <code>has-rgh-inner</code></td></tr> <tr><td><code>isRepo</code></td><td><code>has-rgh</code>, <code>has-rgh-inner</code></td></tr> <tr><td><code>isRepoCommitList</code></td><td><code>has-rgh</code>, <code>.rgh-default-branch-button</code></td></tr> <tr><td><code>isRepoConversationList</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isRepoForksList</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isRepoHome</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isRepoIssueList</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isRepoMainSettings</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isRepoNetworkGraph</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isRepoRoot</code></td><td><code>has-rgh-inner</code></td></tr> <tr><td><code>isRepoSearch</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isRepoTree</code></td><td><code>has-rgh</code>, <code>.rgh-download-folder</code>, <code>.rgh-latest-tag-button</code>, <code>.rgh-default-branch-button</code>, <code>.rgh-quick-file-edit</code>, <code>has-rgh-inner</code></td></tr> <tr><td><code>isRepositoryActions</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isSingleCommit</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isSingleFile</code></td><td><code>has-rgh</code>, <code>.rgh-copy-file</code>, <code>.rgh-latest-tag-button</code>, <code>.rgh-default-branch-button</code>, <code>.rgh-list-prs-for-file</code>, <code>has-rgh-inner</code></td></tr> <tr><td><code>isSingleGist</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isSingleHTMLFile</code></td><td><code>.rgh-html-preview-link</code></td></tr> <tr><td><code>isSingleTag</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isUserProfile</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isUserProfileMainTab</code></td><td><code>has-rgh</code></td></tr> <tr><td><code>isUserProfileRepoTab</code></td><td><code>has-rgh</code></td></tr> </table> </details>

Given that many features have several page detections, the logic should probably be:

  • Use has-rgh-inner if at least one detection requires it
  • Else, use has-rgh

Ofc feature-specific deduplication markers (e.g. .rgh-copy-file) would still need to be specified "by hand".

Screenshot

No response

Example URL

n/a


Unfortunately that selector depends on where the element is, not just what page it is. For example a feature in the title of a PR might need has-rgh but if the feature is in the file list the container might be different.

Maybe we can still use this as a smart default instead of using only has-rgh, and occasionally we can still override it.

Regarding the logic itself, it's not about whether the includes contain isPR, but whether the current page is a PR. This is because hasCode would otherwise never match it.

posted by fregante over 3 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests