Skip to content

Commit a6196c4

Browse files
committed
Release 1.0.1
1 parent cbfc805 commit a6196c4

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "read-lite",
33
"displayName": "ReadLite - Simple Reading Mode",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"description": "A simple reading mode extension to make web reading more comfortable",
66
"author": "ReadLite Team",
77
"license": "MIT",
88
"scripts": {
9+
"clean": "rm -rf .plasmo/ build/",
910
"dev": "plasmo dev",
1011
"build": "plasmo build",
1112
"package": "plasmo build --zip",
@@ -33,6 +34,7 @@
3334
"@types/turndown": "^5.0.5",
3435
"eslint": "^8.55.0",
3536
"jest": "^29.7.0",
37+
"jimp": "^1.6.0",
3638
"prettier": "^3.1.0",
3739
"typescript": "^5.3.3"
3840
},

src/background.ts

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66
// Track which tabs have content scripts loaded
77
const tabsWithContentScript = new Set<number>();
88

9+
// Track active state of the extension
10+
let isActive = false;
11+
12+
// Colors based on the purple book icon
13+
const BADGE_BACKGROUND_COLOR: [number, number, number, number] = [177, 156, 217, 255]; // #B19CD9 - Lavender purple (original icon color)
14+
915
// Listen for content script ready messages
1016
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
1117

1218
// Mark tab as having content script ready
1319
if (message.type === "CONTENT_SCRIPT_READY" && sender.tab?.id) {
1420
tabsWithContentScript.add(sender.tab.id);
15-
sendResponse({ received: true });
21+
sendResponse({ received: true });
1622
return true;
1723
}
1824

@@ -72,22 +78,55 @@ async function toggleReaderMode(tabId: number) {
7278
}
7379
}
7480

81+
/**
82+
* Update the extension icon state
83+
* @param active - Whether the extension is active
84+
*/
85+
function updateIconState(active: boolean) {
86+
if (active) {
87+
// For active state: use "on" text with a compact badge
88+
chrome.action.setBadgeText({ text: "ON" });
89+
90+
// Use the lavender purple color that matches the icon
91+
chrome.action.setBadgeBackgroundColor({
92+
color: BADGE_BACKGROUND_COLOR
93+
});
94+
95+
// Make badge text smaller and more compact
96+
chrome.action.setBadgeTextColor({ color: "#FFFFFF" });
97+
} else {
98+
// For inactive state: clear the badge completely
99+
chrome.action.setBadgeText({ text: "" });
100+
}
101+
102+
// Store the current state
103+
isActive = active;
104+
}
105+
75106
// Listen for extension icon clicks
76107
chrome.action.onClicked.addListener(async (tab) => {
77108
if (!tab.id) return;
78109

79-
110+
// Toggle the active state
111+
isActive = !isActive;
112+
113+
// Update the icon to reflect the new state
114+
updateIconState(isActive);
115+
80116
try {
81117
// Execute script to dispatch the custom event directly
82118
await chrome.scripting.executeScript({
83119
target: { tabId: tab.id },
84120
func: () => {
85-
// Create and dispatch the event directly
121+
// Create and dispatch the event directly
86122
document.dispatchEvent(new CustomEvent('READLITE_TOGGLE_INTERNAL'));
87123
}
88124
});
89125

90-
} catch (error) {
126+
} catch (error) {
91127
console.error("Error executing script:", error);
92128
}
93-
});
129+
});
130+
131+
// Initialize icon state on extension load
132+
updateIconState(isActive);

0 commit comments

Comments
 (0)