Skip to content
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

Gesturefy v4 (Port to manifest v3) #715

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e8fef6a
Remove entire exclusion functionality
Robbendebiene Jun 5, 2022
eccea39
Minor code adjustments
Robbendebiene Jun 5, 2022
e8ccf64
Convert JSON config files to JS modules
Robbendebiene Jun 22, 2022
470452e
Allow comma values for command font size
Robbendebiene Aug 27, 2022
82cbf78
Replace png icons with svg icon
Robbendebiene Aug 27, 2022
5009927
Redesign gesture search
Robbendebiene Jan 1, 2023
aba3162
Migrate manifest to version 3
Robbendebiene Jun 5, 2023
e0d7d40
Add deactivated icon
Robbendebiene Jun 5, 2023
9ce0764
Migrate commands to new scripting API
Robbendebiene Jun 5, 2023
31f3d81
Move data management actions to "extras" page
Robbendebiene Jun 19, 2023
f42af65
Make use of new background scripts module support
Robbendebiene Sep 2, 2023
31ad7e4
Create separate data tab in options page
Robbendebiene Oct 5, 2023
039ab36
Add initial browser action popup implementation
Robbendebiene May 23, 2024
9d00bce
Add separate exclusion service
Robbendebiene Jun 4, 2024
b061df4
Move config manager to service directory
Robbendebiene Jun 4, 2024
19300a7
Add host permission service and introduce base event listener service
Robbendebiene Jul 3, 2024
c1374b8
Display permission state in the browser action icon
Robbendebiene Jul 3, 2024
7b55b05
Update exclusion service
Robbendebiene Jul 5, 2024
27c9cfc
Improve host permission test function
Robbendebiene Jul 5, 2024
ac06d0c
Bring back exclusion functionality to content scripts
Robbendebiene Jul 5, 2024
78b2d64
Fix restricted page warning
Robbendebiene Jul 5, 2024
88194dc
Merge branch 'master' into port-to-manifest-v3
Robbendebiene Aug 4, 2024
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[<img align="right" src="https://img.shields.io/github/license/robbendebiene/gesturefy.svg">](https://github.com/Robbendebiene/Gesturefy/blob/master/LICENSE)


# <sub><img src="https://github.com/Robbendebiene/Gesturefy/blob/master/src/resources/img/iconx48.png" height="38" width="38"></sub>esturefy
# <sub><img src="https://github.com/Robbendebiene/Gesturefy/blob/master/src/resources/img/icon.svg" height="38" width="38"></sub>esturefy

#### [<img height="60" align="right" src="https://blog.mozilla.org/addons/files/2020/04/get-the-addon-fx-apr-2020.svg">](https://addons.mozilla.org/firefox/addon/gesturefy/) Navigate, operate, and browse faster with mouse gestures! A customizable Firefox mouse gesture add-on with a variety of different commands.

Expand Down
180 changes: 134 additions & 46 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"message": "Extras",
"description": "Extras"
},
"navigationExclusions": {
"message": "Exclusions",
"description": "Exclusions"
"navigationData": {
"message": "Data",
"description": "Data"
},
"navigationAbout": {
"message": "About",
Expand Down Expand Up @@ -289,44 +289,106 @@
"description": "The minimal amount the mouse wheel must be scrolled until the gesture is triggered."
},

"exclusionsLabelInformation": {
"message": "Information:",
"description": "Information:"
"dataLabelFileBackup": {
"message": "Backup to file",
"description": "Backup to file"
},
"exclusionsTextInformation": {
"message": "Add URL match patterns to disable Gesturefy for certain websites. The match pattern allows \"*\" wildcards and must be in the form of <scheme>://<host><path>.",
"description": "Add URL match patterns to disable Gesturefy for certain websites. The match pattern allows \"*\" wildcards and must be in the form of <scheme>://<host><path>."
"dataLabelFileRestore": {
"message": "Restore from file",
"description": "Restore from file"
},
"exclusionsPlaceholderURL": {
"message": "Enter URL match pattern",
"description": "Enter URL match pattern"
"dataLabelCloudBackup": {
"message": "Backup to cloud",
"description": "Backup to cloud"
},
"exclusionsAddButton": {
"message": "Add",
"description": "Add"
"dataLabelCloudRestore": {
"message": "Restore from cloud",
"description": "Restore from cloud"
},
"dataLabelResetConfig": {
"message": "Reset configuration",
"description": "Reset configuration"
},

"dataDescriptionFileBackup": {
"message": "Stores the settings and gestures in a config file.",
"description": "Stores the settings and gestures in a config file."
},
"dataDescriptionFileRestore": {
"message": "Loads a previously stored config file.",
"description": "Loads a previously stored config file."
},
"dataDescriptionCloudBackup": {
"message": "Stores the settings and gestures in the cloud of the browser account.",
"description": "Stores the settings and gestures in the cloud of the browser account."
},
"exclusionsNotificationAlreadyExists": {
"message": "URL pattern already exists.",
"description": "URL pattern already exists."
"dataDescriptionCloudRestore": {
"message": "Loads previously uploaded settings and gestures from the cloud of the browser account.",
"description": "Loads previously uploaded settings and gestures from the cloud of the browser account."
},
"exclusionsHintNoEntries": {
"message": "No entries available",
"description": "No entries available"
"dataDescriptionResetConfig": {
"message": "Resets all settings and gestures to their defaults.",
"description": "Resets all settings and gestures to their defaults."
},

"aboutBackup": {
"dataBackup": {
"message": "Backup",
"description": "Backup"
},
"aboutRestore": {
"dataRestore": {
"message": "Restore",
"description": "Restore"
},
"aboutReset": {
"dataCloudUpload": {
"message": "Upload",
"description": "Upload"
},
"dataCloudDownload": {
"message": "Download",
"description": "Download"
},
"dataReset": {
"message": "Reset",
"description": "Reset"
},

"dataRestoreNotificationNoConfigFile": {
"message": "The selected file is not a valid Gesturefy config file.",
"description": "The selected file is not a valid Gesturefy config file."
},
"dataRestoreNotificationWrongFile": {
"message": "The selected file does not match the required file type.",
"description": "The selected file does not match the required file type."
},
"dataRestoreNotificationConfirm": {
"message": "All settings and gestures will be replaced by the selected config file.",
"description": "All settings and gestures will be replaced by the selected config file."
},
"dataRestoreNotificationSuccess": {
"message": "The selected configuration has been successfully restored.",
"description": "The selected configuration has been successfully restored."
},
"dataUploadNotificationConfirm": {
"message": "Your existing configuration in the cloud will be overridden by the current configuration.",
"description": "Your existing configuration in the cloud will be overridden by the current configuration."
},
"dataUploadNotificationSuccess": {
"message": "The current configuration has been successfully saved to the cloud storage. It will be available to other devices once the data is synced by the browser.",
"description": "The current configuration has been successfully saved to the cloud storage. It will be available to other devices once the data is synced by the browser."
},
"dataDownloadNotificationConfirm": {
"message": "All settings and gestures will be replaced with the configuration from the cloud.",
"description": "All settings and gestures will be replaced with the configuration from the cloud."
},
"dataDownloadNotificationSuccess": {
"message": "The configuration from the cloud has been successfully restored.",
"description": "The configuration from the cloud has been successfully restored."
},
"dataResetNotificationConfirm": {
"message": "All settings and gestures will be reset. This cannot be undone!",
"description": "All settings and gestures will be reset. This cannot be undone!"
},

"aboutLicense": {
"message": "License:",
"description": "License:"
Expand All @@ -348,27 +410,6 @@
"description": "Add-on page"
},

"aboutRestoreNotificationNoConfigFile": {
"message": "The selected file is not a valid Gesturefy config file.",
"description": "The selected file is not a valid Gesturefy config file."
},
"aboutRestoreNotificationWrongFile": {
"message": "The selected file does not match the required file type.",
"description": "The selected file does not match the required file type."
},
"aboutRestoreNotificationConfirm": {
"message": "All settings including gestures will be replaced by the selected config file.",
"description": "All settings including gestures will be replaced by the selected config file."
},
"aboutRestoreNotificationSuccess": {
"message": "The selected config has been successfully restored.",
"description": "The selected config has been successfully restored."
},
"aboutResetNotificationConfirm": {
"message": "All settings including gestures will be reset. This cannot be undone!",
"description": "All settings including gestures will be reset. This cannot be undone!"
},

"commandLabelToggleBookmark": {
"message": "Toggle bookmark",
"description": "Toggle bookmark"
Expand Down Expand Up @@ -1699,5 +1740,52 @@
"welcomePageLowerSectionLearnMoreLink": {
"message": "Learn More",
"description": "Learn More"
},

"popupProhibitedPageWarning": {
"message": "Add-ons are prohibited on this page",
"description": "Add-ons are prohibited on this page"
},
"popupMissingPermissionButton": {
"message": "Gesturefy requires additional permissions",
"description": "Gesturefy requires additional permissions"
},
"popupMissingPermissionButtonTooltip": {
"message": "Click to request necessary permissions and enable Gesturefy.",
"description": "Click to request necessary permissions and enable Gesturefy."
},
"popupExclusionsToggleButton": {
"message": "Allow gestures on $DOMAIN$",
"description": "Allow gestures on $DOMAIN$",
"placeholders": {
"domain" : {
"content" : "$1",
"example" : "www.example.com"
}
}
},
"popupExclusionsToggleButtonOffTooltip": {
"message": "Click to enable Gesturefy on $DOMAIN$",
"description": "Click to enable Gesturefy on $DOMAIN$",
"placeholders": {
"domain" : {
"content" : "$1",
"example" : "www.example.com"
}
}
},
"popupExclusionsToggleButtonOnTooltip": {
"message": "Click to disable Gesturefy on $DOMAIN$",
"description": "Click to disable Gesturefy on $DOMAIN$",
"placeholders": {
"domain" : {
"content" : "$1",
"example" : "www.example.com"
}
}
},
"popupOpenSettingsButton": {
"message": "Open settings",
"description": "Open settings"
}
}
}
57 changes: 45 additions & 12 deletions src/core/background.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import { displayNotification } from "/core/utils/commons.mjs";
import { displayNotification, getActiveTab } from "/core/utils/commons.mjs";

import ConfigManager from "/core/helpers/config-manager.mjs";
import ConfigManager from "/core/services/config-manager.mjs";

import Gesture from "/core/models/gesture.mjs";

import Command from "/core/models/command.mjs";

import DefaultConfig from "/resources/configs/defaults.mjs";

import ExclusionService from "/core/services/exclusion-service.mjs";

import HostPermissionService from "/core/services/host-permission-service.mjs";

import { getClosestGestureByPattern } from "/core/utils/matching-algorithms.mjs";

import "/core/helpers/message-router.mjs";

// temporary data migration
import "/core/migration.mjs";

const Config = new ConfigManager("local", browser.runtime.getURL("resources/json/defaults.json"));
Config.autoUpdate = true;
Config.loaded.then(updateVariablesOnConfigChange);
Config.addEventListener("change", updateVariablesOnConfigChange);
const Config = new ConfigManager({
defaults: DefaultConfig,
autoUpdate: true
});
Config.loaded.then(updateVariablesOnConfigChange);
Config.addEventListener("change", updateVariablesOnConfigChange);

const Exclusions = new ExclusionService();
const HostPermissions = new HostPermissionService();

const MouseGestures = new Set();

Expand All @@ -36,7 +47,7 @@ function updateVariablesOnConfigChange () {
RockerGestureRight = new Command(Config.get("Settings.Rocker.rightMouseClick"));
WheelGestureUp = new Command(Config.get("Settings.Wheel.wheelUp"));
WheelGestureDown = new Command(Config.get("Settings.Wheel.wheelDown"));
}
}


/**
Expand Down Expand Up @@ -147,12 +158,34 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {


/**
* Handle browser action click
* Open Gesturefy options page
* Listen for tab, permission and exclusion changes
* Set the browser action icon to enabled or disabled state
**/
browser.browserAction.onClicked.addListener(() => {
browser.runtime.openOptionsPage();
});
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (tab.active) {
handleBrowserActionIcon();
}
}, { properties: ["url", "status"] });
browser.tabs.onActivated.addListener(handleBrowserActionIcon);
HostPermissions.addEventListener("change", handleBrowserActionIcon);
Exclusions.loaded.then(handleBrowserActionIcon);
Exclusions.addEventListener("change", handleBrowserActionIcon);
// on initial run
handleBrowserActionIcon();

async function handleBrowserActionIcon() {
const activeTab = await getActiveTab();
const hasPermission =
activeTab.url != null &&
Exclusions.isEnabledFor(activeTab.url) &&
(await HostPermissions.hasTabPermission(activeTab));

browser.action.setIcon({
path: hasPermission
? "/resources/img/icon.svg"
: "/resources/img/icon_deactivated.svg"
});
}


/**
Expand Down
10 changes: 0 additions & 10 deletions src/core/bundle/background.html

This file was deleted.

Loading