Skip to content

Commit a563c2d

Browse files
committed
v1.1.1 fixes for Chrome
1 parent 764a586 commit a563c2d

File tree

5 files changed

+54
-112
lines changed

5 files changed

+54
-112
lines changed

Chrome/manifest.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,10 @@
1212
"96": "images/icon-96.png",
1313
"128": "images/icon-128.png"
1414
},
15-
"web_accessible_resources": [
16-
{
17-
"resources": ["whats_new.json"],
18-
"matches": ["<all_urls>"]
19-
}
20-
],
2115
"permissions": [
2216
"activeTab",
2317
"storage",
24-
"scripting",
25-
"offscreen"
18+
"scripting"
2619
],
2720
"background": {
2821
"service_worker": "service_worker.js"

Chrome/offscreen.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

Chrome/offscreen.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

Chrome/releases/description.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
1-
Send the current page by your system’s email app (mailto:), Gmail® or Outlook®—with the page title, selected text, and URL—easily.
1+
Send the current page by your system’s email app (mailto), Gmail® or Outlook®—with the page title, selected text, and URL—easily.
22

33
OVERVIEW
44
Page Mail is a simple yet powerful extension that lets you quickly compose an email message containing:
55
- The current page’s title
66
- Any text you’ve selected
77
- The page URL
88

9-
Perfect for sharing articles, research, or anything you find online—right from your browser! Supports Email link handler (mailto:), Gmail® and Outlook®.
9+
Perfect for sharing articles, research, or anything you find online—right from your browser! Supports Email link handler (mailto), Gmail® and Outlook®.
10+
11+
WHAT'S NEW
12+
- 1.1.1: Fix zombie window issue with Thunderbird
13+
- 1.1.0: Fix blank popup issue.
1014

1115
FEATURES
12-
- One-click sharing: Click the extension button to open your system’s Email link handler (mailto:), Gmail® or Outlook® with the page details pre-filled.
16+
- One-click sharing: Click the extension button to open your system’s Email link handler (mailto), Gmail® or Outlook® with the page details pre-filled.
1317
- Keyboard shortcut: Use Ctrl+Alt+P (customizable) to open the extension popup.
1418
- Selected text support: Highlight text on a page to include it in your email.
1519
- Custom subject prefix: Personalize your email subject line via the options page.
1620
- Syncs across devices: Your subject prefix and service choice can be saved with your browser account.
1721

1822
USAGE
19-
1. Choose your email provider (Email link handler [mailto:], Gmail® or Outlook®) in Options.
23+
1. Choose your email provider (Email link handler [mailto], Gmail® or Outlook®) in Options.
2024
2. (Optional) Highlight text on the page to include it in your email.
2125
3. Open the popup by clicking the extension icon or using Ctrl+Alt+P (customizable in browser's extension manager).
2226
4. You must initiate sending from the new message popup.
2327

2428
OPTIONS
2529
- Access the options page via the onboarding page, the extension’s context menu, or browser add-on manager.
2630
- Set a subject prefix (e.g., “FYI: ”) to be added to every email subject.
27-
- Choose Email link handler (mailto:), Gmail® or Outlook® as your preferred provider.
31+
- Choose Email link handler (mailto), Gmail® or Outlook® as your preferred provider.
2832
- Settings can sync with your browser account.
2933

30-
CONFIGURING mailto:
31-
When you select Email link handler (mailto:) in Page Mail’s options, the extension uses browser’s configured handler for `mailto:` links. This can be your operating system’s default email app or a webmail service (like Gmail or Outlook.com).
34+
CONFIGURING mailto
35+
When you select Email link handler (mailto) in Page Mail’s options, the extension uses browser’s configured handler for `mailto` links. This can be your operating system’s default email app or a webmail service (like Gmail or Outlook.com).
3236

33-
To change your mailto: handler in browser, see:
34-
[How do I change my web browser's default email client for mailto links?](https://support.procore.com/faq/how-do-i-change-my-web-browsers-default-email-client-for-mailto-links)
37+
To change your mailto handler in browser, see: https://support.procore.com/faq/how-do-i-change-my-web-browsers-default-email-client-for-mailto-links
3538

3639
PRIVACY & PERMISSIONS
3740
- Page Mail does not collect or transmit any personal data.
@@ -45,15 +48,15 @@ COMPATIBILITY
4548

4649
KNOWN ISSUES & LIMITATIONS
4750
- The extension cannot access special pages (e.g., about:, chrome:, edge:).
48-
- You must be logged in to your selected email service (Email link handler [mailto:], Gmail® or Outlook®) in the browser for Page Mail to work properly.
51+
- You must be logged in to your selected email service (Email link handler [mailto], Gmail® or Outlook®) in the browser for Page Mail to work properly.
4952
- The amount of selected text you can include is limited by the maximum URL length supported by browsers and email providers. Large selections may be truncated or fail to open in the email composer.
5053

5154
FAQ
5255
Q: Can I change the keyboard shortcut?
5356
A: Yes! Use the browser's extension manager.
5457

5558
Q: Does this work with other email providers?
56-
A: It supports Email link handler (mailto:) in addition to Gmail® and Outlook®.
59+
A: It supports Email link handler (mailto) in addition to Gmail® and Outlook®.
5760

5861
Q: Is my browsing data sent anywhere?
5962
A: No. The extension only opens your chosen email service with data you see; nothing is sent to third parties.

Chrome/service_worker.js

Lines changed: 39 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,22 @@
44
Handles background actions, including opening compose windows with user options.
55
*/
66

7-
const ext = typeof browser !== "undefined" ? browser : chrome;
8-
const OFFSCREEN_DOCUMENT_PATH = '/offscreen.html';
9-
10-
// A helper function to find if an offscreen document is already open
11-
async function hasOffscreenDocument() {
12-
const contexts = await ext.runtime.getContexts({
13-
contextTypes: ['OFFSCREEN_DOCUMENT'],
14-
documentUrls: [ext.runtime.getURL(OFFSCREEN_DOCUMENT_PATH)]
15-
});
16-
return contexts.length > 0;
17-
}
7+
console.log("Page Mail Service Worker starting up...");
188

19-
// A helper function to create and use the offscreen document for mailto: links
20-
async function openMailtoInOffscreen(mailtoUrl) {
21-
if (await hasOffscreenDocument()) {
22-
await ext.offscreen.closeDocument();
23-
}
24-
25-
// Uses the CLIPBOARD reason as it is the most appropriate for triggering external actions
26-
await ext.offscreen.createDocument({
27-
url: OFFSCREEN_DOCUMENT_PATH + '#' + encodeURIComponent(mailtoUrl),
28-
reasons: ['CLIPBOARD'],
29-
justification: 'To reliably open mailto: links from a service worker without leaving a blank window.',
30-
});
31-
}
9+
const ext = typeof browser !== "undefined" ? browser : chrome;
3210

33-
// Core function to open the selected email service's compose window
11+
/**
12+
* Core function to open the selected email service's compose window.
13+
* Uses script injection for mailto: to ensure compatibility with Windows 11.
14+
*/
3415
async function openComposeWindow() {
16+
console.log("Toolbar button clicked - initializing Page Mail...");
3517
try {
3618
const [tab] = await ext.tabs.query({ active: true, currentWindow: true });
37-
if (!tab) throw new Error("No active tab found.");
19+
if (!tab) {
20+
console.error("No active tab found.");
21+
return;
22+
}
3823

3924
let selectedText = "";
4025
try {
@@ -46,38 +31,24 @@ async function openComposeWindow() {
4631
if (results && results[0] && results[0].result) {
4732
selectedText = results[0].result;
4833
}
49-
} catch {
50-
// If the script fails (e.g., on restricted chrome:// pages),
51-
// open the error page in a full tab for better reliability on Windows 11.
52-
await ext.tabs.create({
53-
url: ext.runtime.getURL("error.html")
54-
});
34+
} catch (e) {
35+
// If the script fails (e.g., on restricted pages), show the error page
36+
console.warn("Scripting blocked on this page. Opening error page.", e);
37+
await ext.tabs.create({ url: ext.runtime.getURL("error.html") });
5538
return;
5639
}
5740

5841
// Retrieve user preferences from storage
59-
const data = await new Promise((resolve, reject) => {
60-
ext.storage.sync.get(
61-
['subjectPrefix', 'emailService', 'selectedTextPos', 'blankLine'],
62-
(result) => {
63-
if (ext.runtime && ext.runtime.lastError) {
64-
reject(ext.runtime.lastError);
65-
} else {
66-
resolve(result);
67-
}
68-
}
69-
);
70-
});
71-
42+
const data = await ext.storage.sync.get(['subjectPrefix', 'emailService', 'selectedTextPos', 'blankLine']);
43+
7244
const prefix = data.subjectPrefix || "";
73-
const service = data.emailService || "mailto"; // Matches options.html values
45+
const service = data.emailService || "mailto";
7446
const selectedTextPos = data.selectedTextPos || "above";
7547
const blankLine = !!data.blankLine;
7648

7749
let link = tab.url;
7850
let body = "";
79-
80-
// Construct email body based on selection and placement settings
51+
8152
if (selectedText && selectedText.trim()) {
8253
if (selectedTextPos === "above") {
8354
body = selectedText + (blankLine ? "\n\n" : "\n") + link;
@@ -97,11 +68,10 @@ async function openComposeWindow() {
9768
} else if (service === "mailto") {
9869
composeUrl = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
9970
} else {
100-
// Gmail is the fallback service
10171
composeUrl = `https://mail.google.com/mail/?view=cm&fs=1&su=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
10272
}
10373

104-
// Execution logic: Web-based vs System-based
74+
// Execution logic
10575
if (service === "gmail" || service === "outlook") {
10676
// Webmail requires a popup window
10777
await ext.windows.create({
@@ -110,19 +80,29 @@ async function openComposeWindow() {
11080
width: 800,
11181
height: 600
11282
});
113-
} else {
114-
// mailto: uses the offscreen document to prevent the "empty window" bug
115-
await openMailtoInOffscreen(composeUrl);
83+
} else {
84+
// FIXED: Inject the mailto trigger directly into the active tab
85+
// This treats the link as a user-initiated action from the page context.
86+
console.log("Injecting mailto trigger into active tab...");
87+
await ext.scripting.executeScript({
88+
target: { tabId: tab.id },
89+
func: (url) => {
90+
const link = document.createElement('a');
91+
link.href = url;
92+
document.body.appendChild(link);
93+
link.click();
94+
document.body.removeChild(link);
95+
},
96+
args: [composeUrl]
97+
});
11698
}
11799
} catch (error) {
118-
console.error("Page Mail: Failed to open compose window:", error);
119-
await ext.tabs.create({
120-
url: ext.runtime.getURL("error.html")
121-
});
100+
console.error("Page Mail Error:", error);
101+
await ext.tabs.create({ url: ext.runtime.getURL("error.html") });
122102
}
123103
}
124104

125-
// Event Listeners
105+
// Event Listeners (Must be at the top level)
126106
ext.action.onClicked.addListener(openComposeWindow);
127107

128108
ext.commands.onCommand.addListener((command) => {
@@ -133,8 +113,6 @@ ext.commands.onCommand.addListener((command) => {
133113

134114
ext.runtime.onInstalled.addListener((details) => {
135115
if (details.reason === "install" || details.reason === "update") {
136-
ext.tabs.create({
137-
url: ext.runtime.getURL("onboarding.html")
138-
});
116+
ext.tabs.create({ url: ext.runtime.getURL("onboarding.html") });
139117
}
140118
});

0 commit comments

Comments
 (0)