Skip to content

feat show badge count based on headers applied to current page When U…#109

Open
Kirrrusha wants to merge 1 commit into
mainfrom
feat/hide-indication
Open

feat show badge count based on headers applied to current page When U…#109
Kirrrusha wants to merge 1 commit into
mainfrom
feat/hide-indication

Conversation

@Kirrrusha
Copy link
Copy Markdown
Collaborator

@Kirrrusha Kirrrusha commented Apr 2, 2026

feat: бейдж показывает число заголовков, применимых к текущей вкладке

Описание

Иконка расширения отражает не общее число активных заголовков в профиле, а сколько из них реально применяется к URL активной вкладки, если заданы URL-фильтры.

Ситуация Поведение бейджа
Заданы URL-фильтры и текущий URL не подходит ни под один пусто (activeRulesCount === 0)
Фильтров нет или URL неизвестен (chrome://, about:blank, гонки) все активные заголовки профиля (fallback)
URL совпадает с хотя бы одним фильтром число активных заголовков

Изменения

  • countActiveHeadersForUrl, doesUrlMatchFilter — подсчёт с учётом фильтров; семантика как у DNR: паттерны с *:// через convertToRegexFilter, остальное — как urlFilter (подстрока / *, без учёта регистра).
  • setBrowserHeaders(result, currentTabUrl?) — второй аргумент для расчёта activeRulesCount перед setIconBadge.
  • background.ts: getCurrentTabUrl(), передача URL во все вызовы setBrowserHeaders; tabs.onActivated — URL из tabs.get; tabs.onUpdated (status === complete, только активная вкладка).
  • Манифесты: разрешение tabs.
  • Unit-тесты: src/shared/utils/__tests__/countActiveHeadersForUrl.spec.ts (Vitest).
  • E2E: tests/e2e/badge-url-filters.spec.ts — два заголовка и фильтр https://example.com/*: на example.com бейдж 2, после перехода на example.orgпустой (через chrome.action.getBadgeText в service worker).

Чеклист

  • Ручная проверка: профиль с URL-фильтрами — вкладка вне/внутри фильтра, смена вкладки, навигация.
  • pnpm test:unit (в т.ч. countActiveHeadersForUrl).
  • pnpm build:chromium && pnpm exec playwright test tests/e2e/badge-url-filters.spec.ts --project=chrome-extension (нужен сеть и playwright install).

Заметки для ревью

  • Новое permission tabs — для tabs.query / tabs.get / onUpdated; стоит упомянуть в release notes для магазинов.

github-actions Bot added a commit that referenced this pull request Apr 2, 2026
github-actions Bot added a commit that referenced this pull request Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

github-actions Bot added a commit that referenced this pull request Apr 2, 2026
…RL filters are configured the extension icon badge now shows 0 empty if the current page doesn't match any filter and the actual header count only when headers are actively being injected - Add countActiveHeadersForUrl utility with doesUrlMatchFilter - Update setBrowserHeaders to pass current tab URL to badge logic - Add tabsonUpdated listener to refresh badge on navigation - Add 'tabs' permission to all manifests
@Kirrrusha Kirrrusha force-pushed the feat/hide-indication branch from af42196 to cee7b51 Compare May 4, 2026 05:38
github-actions Bot added a commit that referenced this pull request May 4, 2026
github-actions Bot added a commit that referenced this pull request May 4, 2026
github-actions Bot added a commit that referenced this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant