Skip to content

Add "Current tab only" option for selective cache clearing#19

Merged
TenSoja merged 4 commits intomasterfrom
copilot/fix-16
Sep 7, 2025
Merged

Add "Current tab only" option for selective cache clearing#19
TenSoja merged 4 commits intomasterfrom
copilot/fix-16

Conversation

Copy link
Contributor

Copilot AI commented Aug 23, 2025

This PR implements a new "Current tab only" option that allows users to clear cache and browsing data for just the current active tab instead of clearing all data globally.

Changes Made

Core Functionality

  • Added currentTabOnly setting with default value false to maintain backward compatibility
  • Modified clearCache() function to use browser.browsingData.remove({origins: [origin]}, dataTypes) when current tab mode is enabled
  • Added robust error handling for edge case URLs (about:, chrome:, file:, invalid URLs) with graceful fallback to global clearing

User Interface

  • Added new "Current tab only" checkbox in the options page under the "After clearing:" section
  • Integrated seamlessly with existing options layout and styling
  • Added proper localization entry for the new option

Technical Implementation

  • Added "tabs" permission to manifest.json to query current active tab information
  • Updated options.js to handle saving and loading the new setting
  • Enhanced notification messages to indicate when clearing is performed for current tab only

Error Handling

The implementation handles various edge cases:

  • Invalid URLs that cannot be parsed
  • Special browser URLs (about:blank, chrome://, moz-extension://, file://)
  • URLs with null origins
  • Scenarios where no active tabs are found

When any of these edge cases occur, the extension gracefully falls back to the original global clearing behavior.

Usage

Users can now enable "Current tab only" in the extension options. When enabled, clicking the extension icon or using the F9 hotkey will clear the selected data types only for the current tab's domain instead of clearing all browsing data globally.

Fixes #16.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Aug 23, 2025
Copy link
Contributor Author

Copilot AI commented Aug 23, 2025

@TenSoja 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits August 23, 2025 19:45
Co-authored-by: TenSoja <1338661+TenSoja@users.noreply.github.com>
Co-authored-by: TenSoja <1338661+TenSoja@users.noreply.github.com>
Copilot AI changed the title [WIP] Clear only for current tab Add "Current tab only" option for selective cache clearing Aug 23, 2025
Copilot AI requested a review from TenSoja August 23, 2025 19:48
@TenSoja TenSoja marked this pull request as ready for review August 23, 2025 21:00
Copilot AI review requested due to automatic review settings August 23, 2025 21:00

This comment was marked as outdated.

@TenSoja TenSoja requested a review from Copilot August 23, 2025 22:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a "Current tab only" option that allows users to clear cache and browsing data for just the current active tab's domain instead of clearing all data globally. The implementation includes proper error handling for edge cases and maintains backward compatibility with existing functionality.

Key changes:

  • Added currentTabOnly setting with UI checkbox integration and localization
  • Modified cache clearing logic to use origin-specific clearing when enabled
  • Added "tabs" permission to access current tab information

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
options/options.js Added handling for the new currentTabOnly setting in save/load operations
options/options.html Added checkbox UI element for the current tab only option
manifest.json Added "tabs" permission required for querying active tab information
background.js Implemented selective cache clearing logic with error handling and fallback
_locales/en/messages.json Added localization string for the new option

Comment on lines +9 to +11
dataTypes: ["cache"],
customKey: "F9",
currentTabOnly: false
Copy link

Copilot AI Aug 23, 2025

Choose a reason for hiding this comment

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

The customKey: \"F9\" addition appears unrelated to the current tab functionality and is not documented in the PR description. This should either be removed or explained as it seems to be an unintended change.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +22 to +24
storedSettings.dataTypes == null ||
storedSettings.customKey == null ||
storedSettings.currentTabOnly == null
Copy link

Copilot AI Aug 23, 2025

Choose a reason for hiding this comment

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

The check for storedSettings.customKey == null is inconsistent with the PR's scope and appears to be an unrelated change. This should be removed to keep the PR focused on the current tab functionality.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +100 to +102
// For special URLs (about:, chrome:, etc.), fall back to clearing all data
browser.browsingData.remove({since: 0}, dataTypes).then(onCleared, onError);
}
Copy link

Copilot AI Aug 23, 2025

Choose a reason for hiding this comment

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

Line 101 appears to be incorrectly indented and may be missing proper context. The indentation suggests this line should be part of an else block, but the structure is unclear.

Copilot uses AI. Check for mistakes.
@TenSoja TenSoja merged commit 31497fb into master Sep 7, 2025
@TenSoja TenSoja deleted the copilot/fix-16 branch September 7, 2025 15:33
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.

Clear only for current tab

3 participants