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
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@
'error',
{
selector:
':matches([callee.name=delegate], [callee.name=$], [callee.name=$$], [callee.name=$optional], [callee.name=$closest], [callee.name=$closestOptional], [callee.name=observe], [callee.property.name=querySelector], [callee.property.name=querySelectorAll])[arguments.0.value=/,/][arguments.0.value.length>=20]:not([arguments.0.value=/:has|:is/])',
':matches([callee.name=delegate], [callee.name=$], [callee.name=$$], [callee.name=$optional], [callee.name=$closest], [callee.name=$closestOptional], [callee.name=observe], [callee.property.name=querySelector], [callee.property.name=querySelectorAll])[arguments.0.value=/,/][arguments.0.value.length>=20]:not([arguments.0.value=/:has|:is|:not/])',

Check warning on line 94 in eslint.config.js

View workflow job for this annotation

GitHub Actions / Lint

This line has a length of 379. Maximum allowed is 200
message: 'Instead of a single string, pass an array of selectors and add comments to each selector',
},
{
selector:
':matches([callee.name=delegate], [callee.name=$], [callee.name=$$], [callee.name=$optional], [callee.name=$closest], [callee.name=$closestOptional], [callee.name=observe], [callee.property.name=querySelector], [callee.property.name=querySelectorAll])[arguments.0.type=ArrayExpression][arguments.0.elements.length=1]:not([arguments.0.value=/:has|:is/])',

Check warning on line 99 in eslint.config.js

View workflow job for this annotation

GitHub Actions / Lint

This line has a length of 386. Maximum allowed is 200
message: 'If it\'s a single selector, use a single string instead of an array',
},
{
Expand Down Expand Up @@ -302,7 +302,7 @@
},
},

// TODO: Use global `/flat` config. Currently limited to svelte files because dprint is applied to their JS

Check warning on line 305 in eslint.config.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected 'todo' comment: 'TODO: Use global `/flat` config....'
rules: eslintConfigPrettier.rules,
},
{
Expand Down
4 changes: 2 additions & 2 deletions source/features/closing-remarks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'dom-chef';
import {$, $$} from 'select-dom';
import {$, $$optional} from 'select-dom';
import {CachedFunction} from 'webext-storage-cache';

import * as pageDetect from 'github-url-detection';
Expand Down Expand Up @@ -30,7 +30,7 @@ function ExplanationLink(): JSX.Element {
const firstTag = new CachedFunction('first-tag', {
async updater(commit: string): Promise<string | false> {
const tagsAndBranches = await fetchDom(buildRepoUrl('branch_commits', commit));
const tags = $$('ul.branches-tag-list a', tagsAndBranches);
const tags = $$optional('ul.branches-tag-list a', tagsAndBranches);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #9401

// eslint-disable-next-line unicorn/no-array-callback-reference -- Just this once, I swear
return tags.findLast(excludeNightliesAndJunk)?.textContent ?? false;
},
Expand Down
4 changes: 2 additions & 2 deletions source/features/conversation-activity-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const minorFixesIssuePages = [
const states = {
showAll: 'Show all activities',
hideEvents: 'Hide events',
hideEventsAndCollapsedComments: 'Hide events, bots, collapsed comments',
hideEventsBotsCollapsedComments: 'Hide events, bots, collapsed comments',
} as const;

type State = keyof typeof states;
Expand Down Expand Up @@ -290,7 +290,7 @@ function switchToNextFilter(): void {
async function init(signal: AbortSignal): Promise<void> {
currentState = SessionPageSetting.get()
?? (minorFixesIssuePages.some(url => location.href.startsWith(url))
? 'hideEventsAndCollapsedComments' // Automatically hide resolved comments on "Minor codebase updates and fixes" issue pages
? 'hideEventsBotsCollapsedComments' // Automatically hide resolved comments on "Minor codebase updates and fixes" issue pages
: 'showAll');

const initialSetupOnce = onetime(() => {
Expand Down
4 changes: 2 additions & 2 deletions source/features/hide-inactive-deployments.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as pageDetect from 'github-url-detection';
import {elementExists, $$} from 'select-dom';
import {elementExists, $$optional} from 'select-dom';

import features from '../feature-manager.js';

// This feature doesn't need an active observer
function init(): void {
// Selects all the deployments first so that we can leave the last one on the page
const deployments = $$('.js-socket-channel[data-gid^="PR"]:has(.octicon-rocket)');
const deployments = $$optional('.js-socket-channel[data-gid^="PR"]:has(.octicon-rocket)');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#9256 broke it

deployments.pop(); // Don't hide the last deployment, even if it is inactive

for (const deployment of deployments) {
Expand Down
2 changes: 1 addition & 1 deletion source/features/linkify-line-numbers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function linkify(lineNumberCell: HTMLTableCellElement): void {
}

function init(signal: AbortSignal): void {
observe('.blob-num:empty:not(.blob-num-hunk)', linkify, {signal});
observe('.blob-num:not(.blob-num-hunk, .empty-cell)', linkify, {signal});
}

void features.add(import.meta.url, {
Expand Down
18 changes: 11 additions & 7 deletions source/features/reactions-avatars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './reactions-avatars.css';
import React from 'dom-chef';
import {flatZip} from 'flat-zip';
import * as pageDetect from 'github-url-detection';
import {$$} from 'select-dom';
import {$$optional} from 'select-dom';

import {onAbort} from 'abort-utils';

Expand Down Expand Up @@ -73,12 +73,16 @@ const viewportObserver = new IntersectionObserver(changes => {
rootMargin: '500px',
});

function showAvatarsOn(commentReactions: Element): void {
const reactions = $$([
'button[aria-pressed]', // Discussions, releases, PRs, old issues
'button[aria-checked]', // React issues
], commentReactions)
function showAvatarsOn(reactionsContainer: Element): void {
const reactions = $$optional([
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#9256 broke it

'button[aria-pressed]', // Discussions, releases, PRs
'button[aria-checked]', // Issues
], reactionsContainer)
.map(button => getParticipants(button)); // Get all participants for each reaction
if (reactions.length === 0) {
return;
}

const avatarLimit = arbitraryAvatarLimit - (reactions.length * approximateHeaderLength);
const flatParticipants = flatZip(reactions, avatarLimit);

Expand Down Expand Up @@ -107,7 +111,7 @@ function init(signal: AbortSignal): void {
[
// `batch-deferred-content` means the participant list hasn't loaded yet
'.has-reactions .js-comment-reactions-options:not(batch-deferred-content .js-comment-reactions-options)',
'[aria-label="Reactions"]',
'div[aria-label="Reactions"]',
],
observeCommentReactions,
{signal},
Expand Down
6 changes: 1 addition & 5 deletions source/github-helpers/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export const branchSelector_ = [
export const branchSelectorParent = 'details#branch-select-menu';
export const branchSelectorParent_ = branchSelector_;

export const directoryListingFileIcon = [
// .color-fg-muted selects only files; some icon extensions use `img` tags
'.react-directory-filename-column > :is(svg, img).color-fg-muted',
'.js-navigation-container .octicon-file',
];
export const directoryListingFileIcon = '.react-directory-filename-column > .octicon-file';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted from #9110

Copy link
Copy Markdown
Member Author

@SunsetTechuila SunsetTechuila May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with "Catppuccin" and "Material Icons" extensions

export const directoryListingFileIcon_ = [
[18, 'https://github.com/refined-github/refined-github'],
[3, 'https://github.com/refined-github/refined-github/tree/main/.github'],
Expand Down
11 changes: 8 additions & 3 deletions source/helpers/on-altered-click.ts
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't fix anything

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type {ParseSelector} from 'typed-query-selector/parser.d.js';
import delegate, {type DelegateEventHandler, type DelegateOptions} from 'delegate-it';
import {isAlteredClick} from 'filter-altered-clicks';

function isMiddleClick(event: MouseEvent): boolean {
return event.button === 1;
}

export default function onAlteredClick<Selector extends string>(
selector: Selector | readonly Selector[],
callback: DelegateEventHandler<PointerEvent, ParseSelector<Selector>>,
Expand All @@ -14,14 +18,15 @@ export default function onAlteredClick<Selector extends string>(
};

const auxClickListener: typeof callback = event => {
// Is middle click
if (event.button === 1) {
if (isMiddleClick(event)) {
callback(event);
}
};

const preventAutoScrolling = (event: MouseEvent): void => {
event.preventDefault();
if (isMiddleClick(event)) {
event.preventDefault();
}
};

delegate(selector, 'click', clickListener, {capture: true, ...options});
Expand Down
Loading