Commit b718d691 authored by Stefy Spora's avatar Stefy Spora

Fix context menu consistency and null reference errors

- Make all context menu items available in all contexts (page, image, link)
- Fix null reference error by adding proper result validation in all context menu handlers
- Update error messages to be more helpful and consistent
- Ensure consistent context menu behavior across all right-click scenarios
- Update documentation to reflect unified context menu experience
parent 97c751d3
...@@ -59,14 +59,16 @@ A Chrome browser extension that automates privacy settings on FetLife.com. When ...@@ -59,14 +59,16 @@ A Chrome browser extension that automates privacy settings on FetLife.com. When
4. Notifications will show progress and completion status 4. Notifications will show progress and completion status
### Method 5: Context Menu (Direct Privacy Setting) ### Method 5: Context Menu (Direct Privacy Setting)
1. Navigate to a FetLife page with images, videos, or links 1. Navigate to any FetLife page
2. Right-click directly over an **image** or **link** 2. Right-click anywhere on the page, or directly over an **image** or **link**
3. Choose from the privacy options: 3. Choose from the available options:
- **👥 Set to Friends Only** - Sets privacy to friends-only - **Privaxy** - Update privacy for current page (if on video/picture page)
- **🌐 Set to All Fetlifers** - Makes content visible to all FetLife users - **Run on All Media** - Process multiple pages automatically
4. A notification will confirm the privacy setting change - **👥 Set to Friends Only** - Sets privacy to friends-only (if on video/picture page)
- **🌐 Set to All Fetlifers** - Makes content visible to all FetLife users (if on video/picture page)
**Note**: The context menu items appear when right-clicking over images or links, making it easy to quickly change privacy settings for specific media items or navigate to media via links. 4. A notification will confirm the action
**Note**: All context menu options are available regardless of where you right-click on FetLife pages. Privacy options will only work when you're on a video or picture page.
## Donations ## Donations
......
...@@ -20,34 +20,33 @@ ...@@ -20,34 +20,33 @@
// Handles context menu creation and messaging // Handles context menu creation and messaging
chrome.runtime.onInstalled.addListener(() => { chrome.runtime.onInstalled.addListener(() => {
// Create context menu items // Create context menu items for all contexts on FetLife pages
chrome.contextMenus.create({ chrome.contextMenus.create({
id: 'privaxy', id: 'privaxy',
title: 'Privaxy', title: 'Privaxy',
contexts: ['page'], contexts: ['page', 'image', 'link'],
documentUrlPatterns: ['https://fetlife.com/*'] documentUrlPatterns: ['https://fetlife.com/*']
}); });
chrome.contextMenus.create({ chrome.contextMenus.create({
id: 'run-on-all-media', id: 'run-on-all-media',
title: 'Run on All Media', title: 'Run on All Media',
contexts: ['page'], contexts: ['page', 'image', 'link'],
documentUrlPatterns: ['https://fetlife.com/*'] documentUrlPatterns: ['https://fetlife.com/*']
}); });
// Create privacy-specific context menu items for images and links on FetLife pages // Create privacy-specific context menu items for all contexts on FetLife pages
// These will appear when right-clicking over images or links
chrome.contextMenus.create({ chrome.contextMenus.create({
id: 'set-friends-only', id: 'set-friends-only',
title: '👥 Set to Friends Only', title: '👥 Set to Friends Only',
contexts: ['image', 'link'], contexts: ['page', 'image', 'link'],
documentUrlPatterns: ['https://fetlife.com/*'] documentUrlPatterns: ['https://fetlife.com/*']
}); });
chrome.contextMenus.create({ chrome.contextMenus.create({
id: 'set-all-fetlifers', id: 'set-all-fetlifers',
title: '🌐 Set to All Fetlifers', title: '🌐 Set to All Fetlifers',
contexts: ['image', 'link'], contexts: ['page', 'image', 'link'],
documentUrlPatterns: ['https://fetlife.com/*'] documentUrlPatterns: ['https://fetlife.com/*']
}); });
...@@ -65,8 +64,18 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => { ...@@ -65,8 +64,18 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
args: ['friends_only'] args: ['friends_only']
}); });
const result = results[0].result; const result = results && results[0] && results[0].result ? results[0].result : null;
if (!result) {
chrome.notifications.create({
type: 'basic',
iconUrl: 'icon48.png',
title: 'FetLife Privacy Helper',
message: 'Error: Could not execute privacy update. Please try again.'
});
return;
}
// Show notification with result // Show notification with result
chrome.notifications.create({ chrome.notifications.create({
type: 'basic', type: 'basic',
...@@ -121,7 +130,7 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => { ...@@ -121,7 +130,7 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
type: 'basic', type: 'basic',
iconUrl: 'icon48.png', iconUrl: 'icon48.png',
title: 'FetLife Privacy Helper', title: 'FetLife Privacy Helper',
message: 'Please navigate to a video or picture page first.' message: 'Please navigate to a video or picture page first, or right-click directly on a video/picture.'
}); });
return; return;
} }
...@@ -133,7 +142,17 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => { ...@@ -133,7 +142,17 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
args: ['friends_only'] args: ['friends_only']
}); });
const result = results[0].result; const result = results && results[0] && results[0].result ? results[0].result : null;
if (!result) {
chrome.notifications.create({
type: 'basic',
iconUrl: 'icon48.png',
title: 'FetLife Privacy Helper',
message: 'Error: Could not execute privacy update. Please try again.'
});
return;
}
// Show notification with result // Show notification with result
chrome.notifications.create({ chrome.notifications.create({
...@@ -164,7 +183,7 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => { ...@@ -164,7 +183,7 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
type: 'basic', type: 'basic',
iconUrl: 'icon48.png', iconUrl: 'icon48.png',
title: 'FetLife Privacy Helper', title: 'FetLife Privacy Helper',
message: 'Please navigate to a video or picture page first.' message: 'Please navigate to a video or picture page first, or right-click directly on a video/picture.'
}); });
return; return;
} }
...@@ -176,7 +195,17 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => { ...@@ -176,7 +195,17 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
args: ['all_fetlifers'] args: ['all_fetlifers']
}); });
const result = results[0].result; const result = results && results[0] && results[0].result ? results[0].result : null;
if (!result) {
chrome.notifications.create({
type: 'basic',
iconUrl: 'icon48.png',
title: 'FetLife Privacy Helper',
message: 'Error: Could not execute privacy update. Please try again.'
});
return;
}
// Show notification with result // Show notification with result
chrome.notifications.create({ chrome.notifications.create({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment