Skip to content

Commit cb24b8c

Browse files
committed
Small changes
1 parent 8be61a0 commit cb24b8c

19 files changed

Lines changed: 986 additions & 632 deletions

Chrome/GM_api/Values/GM_getValue.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
if (typeof GM_getValue === 'undefined') {
2-
// GM_getValue should be synchronous per Greasemonkey/Tampermonkey spec.
3-
// Store values in localStorage so we can return them immediately.
42
window.GM_getValue = (name, defaultValue) => {
53
try {
64
const raw = localStorage.getItem(`GM_value_${name}`);

Chrome/GM_api/Values/GM_setValue.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
if (typeof GM_setValue === 'undefined') {
2-
// Synchronous implementation using localStorage for immediate persistence.
32
window.GM_setValue = (name, value) => {
43
try {
54
localStorage.setItem(`GM_value_${name}`, JSON.stringify(value));

Chrome/background.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const state = new BackgroundState();
2828
const OFFSCREEN_DOCUMENT_PATH = "offscreen.html";
2929

3030
// Utility functions
31+
// :)
3132
function safeSetBadge(tabId, text = "", color = "#007bff") {
3233
chrome.action.setBadgeText({ tabId, text }).catch((err) => {
3334
if (!isIgnorableTabError(err)) {
@@ -182,6 +183,7 @@ const gmApiHandlers = {
182183
},
183184

184185
// Cross-origin XHR via fetch
186+
// Stay CSP complient
185187
async xmlhttpRequest(message) {
186188
const details = message.details || {};
187189

@@ -192,7 +194,6 @@ const gmApiHandlers = {
192194
const fetchInit = {
193195
method: details.method || "GET",
194196
headers: details.headers || {},
195-
// Allow sending cookies for same-origin if desired
196197
credentials: details.synchronous ? "include" : "same-origin",
197198
};
198199

Chrome/dashboard/dashboard-logic.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ async function saveSettings(settingsElements) {
171171
showNotification("Settings saved successfully", "success");
172172
chrome.runtime.sendMessage({ action: "settingsUpdated" });
173173

174-
// Apply theme immediately
175174
applyTheme(settings.darkMode);
176175
} catch (error) {
177176
console.error("Error saving settings:", error);
@@ -265,7 +264,6 @@ async function refreshDashboard() {
265264
filterScripts(elements, state);
266265
}
267266

268-
// Helper to toggle theme
269267
function applyTheme(isDark) {
270268
const body = document.body;
271269
if (isDark) {
@@ -275,7 +273,6 @@ function applyTheme(isDark) {
275273
}
276274
}
277275

278-
// Export current script in Tampermonkey format (.user.js)
279276
function exportScript(script) {
280277
try {
281278
const code = script.code || "";
@@ -307,7 +304,6 @@ function exportScript(script) {
307304
}
308305
}
309306

310-
// Attach functions to global so dashboard-ui can use them
311307
window.exportScript = exportScript;
312308
window.toggleScript = toggleScript;
313309
window.editScript = editScript;

Chrome/dashboard/dashboard-ui.js

Lines changed: 2 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ function updateWebsiteFilterOptions(scripts, websiteFilter) {
3333
}
3434
}
3535

36-
// Clear all options
3736
while (websiteFilter.firstChild) {
3837
websiteFilter.removeChild(websiteFilter.firstChild);
3938
}
40-
// Add "All Websites" option
39+
4140
const allOption = document.createElement("option");
4241
allOption.value = "";
4342
allOption.textContent = "All Websites";
@@ -68,7 +67,6 @@ function updateScriptsList(scripts, elements) {
6867
return;
6968
}
7069

71-
// show scripts
7270
if (elements.scriptsTable) elements.scriptsTable.style.display = "table";
7371
if (elements.emptyState) elements.emptyState.style.display = "none";
7472

@@ -145,56 +143,6 @@ function createStatusToggleCell(script) {
145143
return statusCell;
146144
}
147145

148-
function createFaviconCell(script) {
149-
const faviconCell = document.createElement("td");
150-
const faviconContainer = document.createElement("div");
151-
faviconContainer.className = "favicon-container";
152-
153-
// mutli favs
154-
const uniqueHosts = new Set();
155-
156-
// get fav for each
157-
if (script.targetUrls && script.targetUrls.length > 0) {
158-
script.targetUrls.forEach((url) => {
159-
try {
160-
let hostname;
161-
if (url.includes("://")) {
162-
hostname = new URL(url).hostname;
163-
} else {
164-
hostname = url.split("/")[0];
165-
}
166-
167-
if (!uniqueHosts.has(hostname)) {
168-
uniqueHosts.add(hostname);
169-
170-
if (faviconContainer.children.length < 3) {
171-
const faviconWrapper = createFaviconWrapper(hostname);
172-
faviconContainer.appendChild(faviconWrapper);
173-
}
174-
}
175-
} catch (error) {
176-
// skip invalid (e.g. "about:blank") URLs
177-
}
178-
});
179-
}
180-
if (uniqueHosts.size > 3) {
181-
const extraHosts = Array.from(uniqueHosts).slice(3);
182-
const counterElement = createFaviconCounter(extraHosts);
183-
faviconContainer.appendChild(counterElement);
184-
}
185-
186-
// FALLBACK!
187-
if (faviconContainer.children.length === 0) {
188-
const fallback = document.createElement("div");
189-
fallback.className = "favicon-fallback";
190-
fallback.textContent = (script.name[0] || "?").toUpperCase();
191-
faviconContainer.appendChild(fallback);
192-
}
193-
194-
faviconCell.appendChild(faviconContainer);
195-
return faviconCell;
196-
}
197-
198146
function createIconCell(script) {
199147
const iconCell = document.createElement("td");
200148
const container = document.createElement("div");
@@ -218,68 +166,6 @@ function createIconCell(script) {
218166
return iconCell;
219167
}
220168

221-
function createFaviconWrapper(hostname) {
222-
const faviconWrapper = document.createElement("div");
223-
faviconWrapper.className = "favicon-wrapper";
224-
faviconWrapper.title = hostname;
225-
226-
const faviconImg = document.createElement("img");
227-
const faviconUrl = `https://s2.googleusercontent.com/s2/favicons?domain=${hostname}`;
228-
229-
console.log(`Fetching favicon for ${hostname}:`, faviconUrl);
230-
231-
faviconImg.src = faviconUrl;
232-
faviconImg.alt = "";
233-
faviconImg.className = "favicon";
234-
faviconImg.onerror = function () {
235-
console.warn(`Failed to load favicon for ${hostname}`);
236-
const fallbackText = hostname.replace(/\*\./g, "").charAt(0).toUpperCase();
237-
const fallbackDiv = document.createElement("div");
238-
fallbackDiv.className = "favicon-fallback";
239-
fallbackDiv.textContent = fallbackText;
240-
this.parentElement.innerHTML = ""; // Clear previous content
241-
this.parentElement.appendChild(fallbackDiv);
242-
};
243-
244-
faviconWrapper.appendChild(faviconImg);
245-
return faviconWrapper;
246-
}
247-
248-
function createFaviconCounter(extraHosts) {
249-
const counter = document.createElement("div");
250-
counter.className = "favicon-counter";
251-
counter.textContent = `+${extraHosts.length}`;
252-
const dropdown = document.createElement("div");
253-
dropdown.className = "favicon-dropdown";
254-
255-
const urlList = document.createElement("ul");
256-
urlList.className = "favicon-url-list";
257-
258-
extraHosts.forEach((hostname) => {
259-
const listItem = document.createElement("li");
260-
listItem.className = "favicon-url-item";
261-
const favicon = document.createElement("img");
262-
favicon.src = `https://${hostname}/favicon.ico`;
263-
favicon.alt = "";
264-
favicon.onerror = () => {
265-
const fallbackDiv = document.createElement("div");
266-
fallbackDiv.className = "favicon-fallback";
267-
fallbackDiv.textContent = (hostname[0] || "?").toUpperCase();
268-
favicon.replaceWith(fallbackDiv);
269-
};
270-
271-
const domain = document.createElement("span");
272-
domain.textContent = hostname;
273-
274-
listItem.append(favicon, domain);
275-
urlList.appendChild(listItem);
276-
});
277-
278-
dropdown.appendChild(urlList);
279-
counter.appendChild(dropdown);
280-
return counter;
281-
}
282-
283169
function createActionsCell(script) {
284170
const actionsCell = document.createElement("td");
285171
actionsCell.className = "script-actions";
@@ -408,20 +294,16 @@ function escapeHtml(unsafe) {
408294
.replace(/&/g, "&amp;")
409295
.replace(/</g, "&lt;")
410296
.replace(/>/g, "&gt;")
411-
.replace(/\"/g, "&quot;")
297+
.replace(/"/g, "&quot;")
412298
.replace(/'/g, "&#039;");
413299
}
414300

415-
// ----------------------------------------------
416-
// About Tab helpers
417-
// ----------------------------------------------
418301
function setupAboutNav(aboutContainer) {
419302
if (!aboutContainer) return;
420303

421304
const navButtons = aboutContainer.querySelectorAll(".about-nav");
422305
const sections = aboutContainer.querySelectorAll(".about-section");
423306

424-
// ensure exporting section exists
425307
const contentEl = aboutContainer.querySelector(".about-content");
426308
if (contentEl && !contentEl.querySelector("#exporting")) {
427309
contentEl.insertAdjacentHTML(
@@ -447,7 +329,6 @@ function setupAboutNav(aboutContainer) {
447329
});
448330
}
449331

450-
// Expose helpers for other modules
451332
window.updateWebsiteFilterOptions = updateWebsiteFilterOptions;
452333
window.updateScriptsList = updateScriptsList;
453334
window.showNotification = showNotification;

Chrome/editor.html

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ <h3 class="panel-title">Script Resources</h3>
352352
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
353353
</svg>
354354
</button>
355-
<button type="button" class="toolbar-btn" id="formatBtn" title="Format code (Alt+Shift+F)">
355+
<button type="button" class="toolbar-btn" id="formatBtn" title="Format code (Alt+F)">
356356
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
357357
<path d="M4 7V4h16v3M9 20h6M12 4v16"></path>
358358
</svg>
@@ -361,6 +361,7 @@ <h3 class="panel-title">Script Resources</h3>
361361
</div>
362362
<div class="toolbar-info">
363363
<span id="cursorInfo" class="cursor-info">Line 1, Column 1</span>
364+
<div class="perf-badge hidden" id="perfTierBadge" title="Performance optimizations active"></div>
364365
</div>
365366
</div>
366367
</main>
@@ -389,28 +390,53 @@ <h3>Keyboard Shortcuts</h3>
389390
<thead>
390391
<tr>
391392
<th>Action</th>
392-
<th>Shortcut</th>
393+
<th>Windows/Linux</th>
394+
<th>macOS</th>
393395
</tr>
394396
</thead>
395397
<tbody>
396398
<tr>
397399
<td>Save Script</td>
398400
<td><kbd>Ctrl</kbd> + <kbd>S</kbd></td>
401+
<td><kbd>Cmd</kbd> + <kbd>S</kbd></td>
399402
</tr>
400403
<tr>
401404
<td>Format Code</td>
402-
<td><kbd>Shift</kbd> + <kbd>Alt</kbd> + <kbd>F</kbd></td>
405+
<td><kbd>Alt</kbd> + <kbd>F</kbd></td>
406+
<td><kbd>Alt</kbd> + <kbd>F</kbd></td>
403407
</tr>
404408
<tr>
405-
<td>Toggle Sidebar</td>
406-
<td><kbd>Ctrl</kbd> + <kbd>\</kbd></td>
409+
<td>Autocomplete</td>
410+
<td><kbd>Ctrl</kbd> + <kbd>Space</kbd></td>
411+
<td><kbd>Ctrl</kbd> + <kbd>Space</kbd></td>
407412
</tr>
408413
<tr>
409414
<td>Toggle Comment</td>
410415
<td><kbd>Ctrl</kbd> + <kbd>/</kbd></td>
416+
<td><kbd>Cmd</kbd> + <kbd>/</kbd></td>
417+
</tr>
418+
<tr>
419+
<td>Toggle Minimap</td>
420+
<td><kbd>Ctrl</kbd> + <kbd>M</kbd></td>
421+
<td><kbd>Cmd</kbd> + <kbd>M</kbd></td>
422+
</tr>
423+
<tr>
424+
<td>Full Screen</td>
425+
<td colspan="2"><kbd>F11</kbd></td>
426+
</tr>
427+
<tr>
428+
<td>Exit Full Screen</td>
429+
<td colspan="2"><kbd>Esc</kbd></td>
430+
</tr>
431+
<tr>
432+
<td>Indent / Insert Spaces</td>
433+
<td colspan="2"><kbd>Tab</kbd> (selection indents; otherwise inserts spaces)</td>
411434
</tr>
412435
</tbody>
413436
</table>
437+
<p class="help-note" style="margin-top:8px;color:#9CA3AF;">
438+
Notes: Shortcuts reflect the current editor configuration. Formatting uses the built-in beautifier. The minimap can also be toggled from Settings.
439+
</p>
414440
</div>
415441
</div>
416442
<div class="help-tab-content" id="help-tab-wildcards">

Chrome/editor.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ class ScriptEditor {
510510
markAsDirty: () => this.markAsDirty(),
511511
markAsUnsaved: () => this.markAsUnsaved(),
512512
debouncedSave: () => this._debouncedSave(),
513-
saveScript: () => this.saveScript()
514513
};
515514

516515
// Setup additional UI components that need callbacks
@@ -989,9 +988,7 @@ document.addEventListener("DOMContentLoaded", () => {
989988
});
990989
});
991990

992-
/**
993-
* Reads darkMode from storage and toggles body.light-theme.
994-
*/
991+
995992
async function applyThemeFromSettings() {
996993
try {
997994
const { settings = {} } = await chrome.storage.local.get("settings");

Chrome/styles/e_header_footer.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
.status-info {
9595
display: flex;
9696
align-items: center;
97+
gap: var(--space-sm);
9798
}
9899

99100
.status-badge {
@@ -175,6 +176,40 @@
175176
display: none !important;
176177
}
177178

179+
/* Performance Tier Badge */
180+
.perf-badge {
181+
display: inline-flex;
182+
align-items: center;
183+
gap: 6px;
184+
padding: 4px 8px;
185+
border-radius: var(--radius-md);
186+
font-size: var(--text-xs);
187+
font-weight: var(--font-medium);
188+
color: var(--text-primary);
189+
background: var(--bg-tertiary);
190+
border: 1px solid var(--border-primary);
191+
box-shadow: var(--shadow-xs);
192+
}
193+
194+
.perf-badge::before {
195+
content: '';
196+
width: 8px;
197+
height: 8px;
198+
border-radius: 999px;
199+
background: var(--accent);
200+
box-shadow: 0 0 8px var(--accent);
201+
}
202+
203+
.perf-badge.tier-large::before {
204+
background: #f59e0b; /* amber-500 */
205+
box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
206+
}
207+
208+
.perf-badge.tier-huge::before {
209+
background: #ef4444; /* red-500 */
210+
box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
211+
}
212+
178213
.sr-only {
179214
position: absolute !important;
180215
width: 1px !important;

0 commit comments

Comments
 (0)