Merge branch 'main' into native-update

This commit is contained in:
rebloor
2024-10-19 05:48:50 +13:00
committed by GitHub
5 changed files with 617 additions and 650 deletions

View File

@@ -39,7 +39,7 @@ browser.browserAction.onClicked.addListener(toggleBookmark);
/*
* Switches currentTab and currentBookmark to reflect the currently active tab
*/
function updateActiveTab(tabs) {
function updateAddonStateForActiveTab(tabs) {
function isSupportedProtocol(urlString) {
let supportedProtocols = ["https:", "http:", "ftp:", "file:"];
@@ -68,19 +68,19 @@ function updateActiveTab(tabs) {
}
// listen for bookmarks being created
browser.bookmarks.onCreated.addListener(updateActiveTab);
browser.bookmarks.onCreated.addListener(updateAddonStateForActiveTab);
// listen for bookmarks being removed
browser.bookmarks.onRemoved.addListener(updateActiveTab);
browser.bookmarks.onRemoved.addListener(updateAddonStateForActiveTab);
// listen to tab URL changes
browser.tabs.onUpdated.addListener(updateActiveTab);
browser.tabs.onUpdated.addListener(updateAddonStateForActiveTab);
// listen to tab switching
browser.tabs.onActivated.addListener(updateActiveTab);
browser.tabs.onActivated.addListener(updateAddonStateForActiveTab);
// listen for window switching
browser.windows.onFocusChanged.addListener(updateActiveTab);
browser.windows.onFocusChanged.addListener(updateAddonStateForActiveTab);
// update when the extension loads initially
updateActiveTab();
updateAddonStateForActiveTab();

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,15 @@
# Favourite Colour
Shows and stores your favourite colour, in storage.sync in the about:addons page for the add-on.
Shows and stores your favourite colour, in storage.sync in the extension's about:addons page.
Demonstrates:
* storing data with storage.sync
* reading data from storage.managed
* creating an options page and opening it with `runtime.openOptionsPage()`
* best practice for supporting automatic theme switching (dark theme) in the options page
* reading data from storage.managed,
* creating an options page and opening it with `runtime.openOptionsPage()`.
To have Firefox read data from storage.managed, create a file with the following contents:
To have Firefox read data from storage.managed, create a file with this content:
{
"name": "favourite-colour-examples@mozilla.org",

View File

@@ -3,6 +3,7 @@
<html>
<head>
<meta charset="utf-8">
<meta name="color-scheme" content="dark light">
</head>
<body>

View File

@@ -16,21 +16,15 @@ key_path = 'Software\\Mozilla\\NativeMessagingHosts\\ping_pong'
# Assuming current user overrides local machine.
key_roots = ['HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE']
found_key = False
for root in key_roots:
key = winreg.OpenKey(getattr(winreg, root), key_path)
for key_root in key_roots:
try:
print('Checking:', root, key_path)
print('Checking:', key_root, key_path)
key = winreg.OpenKey(getattr(winreg, key_root), key_path)
res = winreg.QueryValueEx(key, '')
break
except FileNotFoundError:
print('...error finding key')
continue
found_key = True
break
if not found_key:
print('... error finding key')
else:
raise ValueError('Could not find a registry entry, aborting.')
json_path = res[0]