Initial curated DockDeck source from 26772208f608782e88c736dc70878e7b5abd3916
This commit is contained in:
commit
3c61fba98f
146 files changed
+45229
No files matched your search
@@ -0,0 +1,33 @@
|
||||
/* global chrome */
|
||||
|
||||
const DEFAULT_DOCKDECK_URL = "http://127.0.0.1:1218/";
|
||||
const NEW_TAB_URLS = new Set([
|
||||
"chrome://newtab/",
|
||||
"opera://startpage/",
|
||||
"opera://startpageshared/",
|
||||
]);
|
||||
|
||||
async function openDockDeckForNewTab(tabId, url) {
|
||||
if (NEW_TAB_URLS.has(url)) {
|
||||
const { dockdeckUrl } = await chrome.storage.sync.get({
|
||||
dockdeckUrl: DEFAULT_DOCKDECK_URL,
|
||||
});
|
||||
chrome.tabs.update(tabId, { url: dockdeckUrl });
|
||||
}
|
||||
}
|
||||
|
||||
chrome.tabs.onCreated.addListener((tab) => {
|
||||
openDockDeckForNewTab(tab.id, tab.pendingUrl || tab.url || "");
|
||||
});
|
||||
|
||||
chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
|
||||
if (changeInfo.url) {
|
||||
openDockDeckForNewTab(tabId, changeInfo.url);
|
||||
}
|
||||
});
|
||||
|
||||
chrome.runtime.onStartup.addListener(() => {
|
||||
chrome.storage.sync
|
||||
.get({ dockdeckUrl: DEFAULT_DOCKDECK_URL })
|
||||
.then(({ dockdeckUrl }) => chrome.tabs.create({ url: dockdeckUrl }));
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "DockDeck New Tab",
|
||||
"version": "1.2.0",
|
||||
"description": "Opens DockDeck whenever a new tab is created.",
|
||||
"permissions": ["tabs", "storage"],
|
||||
"options_page": "options.html",
|
||||
"background": {
|
||||
"service_worker": "background.js"
|
||||
},
|
||||
"chrome_url_overrides": {
|
||||
"newtab": "newtab.html"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>DockDeck</title>
|
||||
<style>
|
||||
html {
|
||||
background: #101719;
|
||||
color: #f4f7f5;
|
||||
font:
|
||||
16px system-ui,
|
||||
sans-serif;
|
||||
}
|
||||
body {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
place-items: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>Opening DockDeck…</p>
|
||||
<script src="newtab.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,5 @@
|
||||
/* global chrome, window */
|
||||
|
||||
chrome.storage.sync
|
||||
.get({ dockdeckUrl: "http://127.0.0.1:1218/" })
|
||||
.then(({ dockdeckUrl }) => window.location.replace(dockdeckUrl));
|
||||
@@ -0,0 +1,45 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>DockDeck New Tab settings</title>
|
||||
<style>
|
||||
body {
|
||||
max-width: 42rem;
|
||||
margin: 3rem auto;
|
||||
padding: 0 1rem;
|
||||
font:
|
||||
16px system-ui,
|
||||
sans-serif;
|
||||
}
|
||||
label,
|
||||
input,
|
||||
button {
|
||||
display: block;
|
||||
}
|
||||
input {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
margin: 0.5rem 0 1rem;
|
||||
padding: 0.65rem;
|
||||
}
|
||||
#status {
|
||||
min-height: 1.5rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>DockDeck New Tab</h1>
|
||||
<label for="dockdeck-url">DockDeck URL</label>
|
||||
<input
|
||||
id="dockdeck-url"
|
||||
type="url"
|
||||
required
|
||||
placeholder="http://127.0.0.1:1218/"
|
||||
/>
|
||||
<button id="save" type="button">Save</button>
|
||||
<p id="status" role="status"></p>
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
/* global chrome, document, URL */
|
||||
|
||||
const input = document.querySelector("#dockdeck-url");
|
||||
const status = document.querySelector("#status");
|
||||
|
||||
chrome.storage.sync
|
||||
.get({ dockdeckUrl: "http://127.0.0.1:1218/" })
|
||||
.then(({ dockdeckUrl }) => {
|
||||
input.value = dockdeckUrl;
|
||||
});
|
||||
|
||||
document.querySelector("#save").addEventListener("click", async () => {
|
||||
try {
|
||||
const url = new URL(input.value.trim());
|
||||
if (!["http:", "https:"].includes(url.protocol)) throw new Error();
|
||||
await chrome.storage.sync.set({ dockdeckUrl: url.href });
|
||||
status.textContent = "Saved.";
|
||||
} catch {
|
||||
status.textContent = "Enter a valid HTTP(S) URL.";
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user