Add "Current tab only" option for selective cache clearing#19
Add "Current tab only" option for selective cache clearing#19
Conversation
|
@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. |
Co-authored-by: TenSoja <1338661+TenSoja@users.noreply.github.com>
Co-authored-by: TenSoja <1338661+TenSoja@users.noreply.github.com>
There was a problem hiding this comment.
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
currentTabOnlysetting 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 |
| dataTypes: ["cache"], | ||
| customKey: "F9", | ||
| currentTabOnly: false |
There was a problem hiding this comment.
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.
| storedSettings.dataTypes == null || | ||
| storedSettings.customKey == null || | ||
| storedSettings.currentTabOnly == null |
There was a problem hiding this comment.
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.
| // For special URLs (about:, chrome:, etc.), fall back to clearing all data | ||
| browser.browsingData.remove({since: 0}, dataTypes).then(onCleared, onError); | ||
| } |
There was a problem hiding this comment.
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.
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
currentTabOnlysetting with default valuefalseto maintain backward compatibilityclearCache()function to usebrowser.browsingData.remove({origins: [origin]}, dataTypes)when current tab mode is enabledUser Interface
Technical Implementation
Error Handling
The implementation handles various edge cases:
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.