-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(manifest): Upgrade to manifest v3 #387
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adds a "type" field with value "module" to the manifest file, enabling the use of the import statement for the background script.
Declares the "scripting" permission in the manifest file to enable script injection capabilities.
Improves code readability and maintainability by extracting reusable logic into dedicated helper functions.
ERosendo
force-pushed
the
feat-upgrade-to-manifest-v3
branch
from
August 7, 2024 22:01
cc55da7
to
a6195b7
Compare
ERosendo
force-pushed
the
feat-upgrade-to-manifest-v3
branch
from
August 14, 2024 20:55
f2db4ac
to
90be5f0
Compare
… interactions This commit refactors RECAP API interactions into a dedicated helper function, leveraging background workers for improved performance and reliability.
ERosendo
force-pushed
the
feat-upgrade-to-manifest-v3
branch
from
August 20, 2024 14:41
90be5f0
to
3c3f534
Compare
This commits applies style improvements to this method and replaces recap and notifier functions with equivalent background helpers.
Added a waitUntil helper function to prevent premature termination of the service worker during long-running operations like fetch requests or complex calculations.
albertisfu
approved these changes
Aug 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I reviewed the changes, and they worked correctly.
Just one suggestion to include the documentation URL for the trick to keep the worker alive.
…rom being committed
…-release-packages feat(build): Adds automated release package creation script
This was referenced Aug 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR upgrades the extension code from Manifest V2 to Manifest V3, the newest version of the Chrome Extensions platform.
Here's a list of the key changes in this PR:
Updates in the
manifest.js
file:Change the value of the "manifest_version" field from 2 to 3.
Host permissions in Manifest V3 are a separate field. This PR separates the old list into two list
permissions
andhost_permissions
Manifest V3 limits exposure by restricting which websites and extensions can access resources( images and fonts) in the extension. Instead of providing a list of files as before, We provide an array of objects, each of which maps a set of resources to a set of URLs or extension IDs.
Manifest V3 for Chrome has deprecated background pages and scripts in favor of service workers. While Firefox continues to support background pages, Safari offers compatibility with both. To ensure cross-browser functionality, this PR introduces the
service_worker
key within thebackground
object while preservingscripts
key for broader support.In the earlier versions, Actions used to be divided into
browser_action
andpage_action
. In Manifest V3, they are unified into a single field namedaction
.Due to inconsistencies in how Chrome and Firefox handle the
favicon_url
key within thesearch_provider
object, this PR temporarily removes this object from the manifest to maintain cross-browser compatibility. A dedicated PR will address thefavicon_url
issue.Migrate background script to a single service worker:
Manifest V3 introduces support for
ES modules
and theimport
keyword in service worker scripts, enabling improved code modularity and organization. This PR refactors several helper methods from the service worker into a new file,background.js
, located within theutils
folder. By isolating helper logic, the service worker is streamlined to focus exclusively on event handling, enhancing code readability and maintainability.This PR also addresses Using exportInstance and importInstance goes against convention and causes issues recap#237 by refactoring code related to CL API data fetching and browser notifications. We've also removed all instances of the old code and associated helper functions. To improve code organization and efficiency, we've introduced the following changes:
Due to the incompatibility of XMLHttpRequest() with service workers, this PR replaces all instances of XMLHttpRequest() with the fetch() API. This ensures the code functions correctly within the service worker environment.
General code Updates:
Manifest V3 introduces the scripting API, replacing the tabs API's executeScript function for script injection. To accommodate this change, this PR updates the manifest file's permissions to include 'scripting'. This is necessary as we've adopted programmatic script injection as outlined in fix(background): Tweak logic to inject script programmatically #340. This change will trigger the permission window when updating the extension.
Upgrade to Chrome Runtime API. This PR modernizes the extension codebase by replacing deprecated
chrome.extension
APIs with their supported equivalents in thechrome.runtime
API.Migrating to Promises for Asynchronous Operations. This PR significantly enhances code readability and maintainability by replacing traditional callback functions with modern promise-based asynchronous programming. By leveraging async and await keywords, we've streamlined the process of fetching CL data and triggering notifications. This refactoring aligns with the broader goal of modernizing the RECAP codebase as outlined in Modernize RECAP codebase recap#370.
Due to enhanced extension security measures in Manifest V3, injecting custom
script
tags from content scripts is no longer allowed. Previously, this technique was used to tweak form submission behavior and extract data from ACMS. To address these limitations, this PR implements a new approach.Content scripts live in an isolated environment, preventing direct access to some data on the webpage. Consequently, we've used the
scripting
API andexecuteScript()
method from the service worker to execute custom scripts within the desired context.To accommodate this change, the
storeVueDataInSession
andoverwriteFormSubmitMethod
functions have been refactored into wrappers that send messages to the service worker. The core logic has been moved to background script functions namedgetAndStoreVueData
andoverwriteSubmitMethod
, respectively. This restructuring enables the execution of custom scripts in a secure and compliant manner.Methods for handling district court, appellate, and ACMS reports have been refactored to utilize a new helper method that returns Promises.
Updates the
karma.conf.js
configuration file to align with the project's structural changes. Additionally, necessary mock data has been created to ensure test cases pass successfullyThis PR fixes code formatting by aligning Prettier's
printWidth
setting with ESLint's 80-character limit. Additionally, it enhances code readability by standardizing indentation rules for switch cases and multi-line ternary expressions.