Skip to content

Commit 8f9ca5d

Browse files
feat: added first working version with toggle
1 parent fa57059 commit 8f9ca5d

13 files changed

+77
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

Whitespace-only changes.

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

addOutline.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[].forEach.call(document.querySelectorAll("*"), function (a) {
2+
a.style.outline =
3+
"1px solid #" + (~~(Math.random() * (1 << 24))).toString(16);
4+
});

background.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
chrome.runtime.onInstalled.addListener(() => {
2+
chrome.action.setBadgeText({
3+
text: "",
4+
});
5+
});
6+
7+
const extensions = "https://developer.chrome.com/docs/extensions";
8+
const webstore = "https://developer.chrome.com/docs/webstore";
9+
10+
chrome.action.onClicked.addListener(async (tab) => {
11+
// Retrieve the action badge to check if the extension is 'ON' or 'OFF'
12+
const prevState = await chrome.action.getBadgeText({ tabId: tab.id });
13+
// Next state will always be the opposite
14+
const nextState = prevState === "ON" ? "OFF" : "ON";
15+
16+
// Set the action badge to the next state
17+
await chrome.action.setBadgeText({
18+
tabId: tab.id,
19+
text: nextState === "ON" ? "ON" : "",
20+
});
21+
22+
if (nextState === "ON") {
23+
await chrome.scripting.executeScript({
24+
target: { tabId: tab.id, allFrames: true },
25+
files: ["addOutline.js"],
26+
});
27+
} else if (nextState === "OFF") {
28+
await chrome.scripting.executeScript({
29+
target: { tabId: tab.id, allFrames: true },
30+
files: ["removeOutline.js"],
31+
});
32+
}
33+
});

focus-mode.css

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
body > .scaffold > :is(top-nav, navigation-rail, side-nav, footer),
2+
main > :not(:last-child),
3+
main > :last-child > navigation-tree,
4+
main .toc-container {
5+
display: none;
6+
}
7+
8+
main > :last-child {
9+
margin-top: min(10vmax, 10rem);
10+
margin-bottom: min(10vmax, 10rem);
11+
}

images/.DS_Store

8 KB
Binary file not shown.

images/icon-128.png

2.26 KB
Loading

images/icon-16.png

291 Bytes
Loading

images/icon-32.png

679 Bytes
Loading

images/icon-48.png

1.34 KB
Loading

manifest.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "Diver",
4+
"description": "Diver deep into elements of your webpage",
5+
"version": "0.1",
6+
"permissions": ["activeTab", "scripting"],
7+
"homepage_url": "https://github.com/thoughtlessmind/diver",
8+
"icons": {
9+
"16": "images/icon-16.png",
10+
"32": "images/icon-32.png",
11+
"48": "images/icon-48.png",
12+
"128": "images/icon-128.png"
13+
},
14+
"background": {
15+
"service_worker": "background.js"
16+
},
17+
"action": {
18+
"default_icon": {
19+
"16": "images/icon-16.png",
20+
"32": "images/icon-32.png",
21+
"48": "images/icon-48.png",
22+
"128": "images/icon-128.png"
23+
}
24+
}
25+
}

removeOutline.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[].forEach.call(document.querySelectorAll("*"), function (a) {
2+
a.style.outline = "none";
3+
});

0 commit comments

Comments
 (0)