Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 1d49593

Browse files
Update: reverse and reduce states for opacity bookmarklet toggle
1 parent 6ee410f commit 1d49593

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

src/Background/index.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,28 @@ const { getPrefs, defaultPrefs } = Preferences.init({
99
getOrigin: async () => TabHelper.getTabOrigin(),
1010
});
1111

12-
const listener = (request, sender) =>
13-
new Promise((res, _) => {
14-
switch (request.message) {
15-
case 'storePrefs': {
16-
res(StorageHelper.storePrefs(request.action, request.data));
17-
break;
18-
}
19-
case 'retrievePrefs': {
20-
res(StorageHelper.retrievePrefs(request.action));
21-
break;
22-
}
23-
case 'setIconBadgeText': {
24-
TabHelper.getActiveTab().then((tab) => {
25-
chrome.browserAction.setBadgeText({ text: request.data, tabId: tab.id });
26-
res(true);
27-
});
28-
break;
29-
}
30-
default:
31-
res(false);
32-
break;
12+
const listener = (request, sender) => new Promise((res, _) => {
13+
switch (request.message) {
14+
case 'storePrefs': {
15+
res(StorageHelper.storePrefs(request.action, request.data));
16+
break;
3317
}
34-
});
18+
case 'retrievePrefs': {
19+
res(StorageHelper.retrievePrefs(request.action));
20+
break;
21+
}
22+
case 'setIconBadgeText': {
23+
TabHelper.getActiveTab().then((tab) => {
24+
chrome.browserAction.setBadgeText({ text: request.data, tabId: tab.id });
25+
res(true);
26+
});
27+
break;
28+
}
29+
default:
30+
res(false);
31+
break;
32+
}
33+
});
3534

3635
const commandListener = async (command) => {
3736
Logger.logInfo('commmand fired', command);

src/Bookmarklet/esbuild.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ build({
2525
<a href='javascript:${outputScript.replace('ACTION_TO_FIRE', 'fireSaccadesIntervalTransition')};' aria-role="button" aria-description="toggle saccades interval">Toggle SaccadesInterval</a>
2626
<a href='javascript:${outputScript.replace('ACTION_TO_FIRE', 'fireSaccadesColorTransition')};' aria-role="button" aria-description="toggle saccades color">Toggle SaccadesColor</a>
2727
<a href='javascript:${outputScript.replace('ACTION_TO_FIRE', 'fireFixationStemOpacityTransition')};' aria-role="button" aria-description="toggle fixation stem opacity">Toggle FixationStemOpacity</a>
28-
<br>
2928
<p>Drag any of the links above onto your bookmark bar to save it as a bookmarklet which works on any site just like the full extension</p>
3029
3130
`,

src/Bookmarklet/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ function writeAttributesToDom() {
2222
document.body.getAttribute('saccades-color') ?? saccadesColor,
2323
);
2424

25-
document.body.setAttribute('fixation-stem-opacity', document.body.getAttribute('fixation-stem-opacity') ?? fixationStemOpacity);
25+
document.body.setAttribute(
26+
'fixation-stem-opacity',
27+
document.body.getAttribute('fixation-stem-opacity') ?? fixationStemOpacity,
28+
);
2629
}
2730

2831
writeAttributesToDom();
@@ -58,13 +61,11 @@ const stateTransitions = {
5861
['dark-100', ''],
5962
],
6063
'fixation-stem-opacity': [
61-
[null, '20'],
62-
[0, 20],
63-
[20, 40],
64-
[40, 60],
65-
[60, 80],
66-
[80, 100],
67-
[100, 0],
64+
[null, '100'],
65+
[0, 100],
66+
[100, 80],
67+
[80, 40],
68+
[40, 0],
6869
],
6970
};
7071

0 commit comments

Comments
 (0)