Skip to content

Instantly share code, notes, and snippets.

@protoEvangelion
Created August 7, 2025 15:35
Show Gist options
  • Select an option

  • Save protoEvangelion/8e356354c13beaa4896f326e6d8e208c to your computer and use it in GitHub Desktop.

Select an option

Save protoEvangelion/8e356354c13beaa4896f326e6d8e208c to your computer and use it in GitHub Desktop.
Modify vscode css
import fs from "fs/promises";
import { createHash } from "crypto";
import path from "path";
// Base app path
const appRoot = "/Applications/Visual Studio Code.app/Contents/Resources/app"; // VS Code
// const appRoot = "/Applications/Cursor.app/Contents/Resources/app"; // Cursor
const cssPath = path.join(appRoot, "out/vs/workbench/custom.css");
const htmlPath = path.join(
appRoot,
"out/vs/code/electron-browser/workbench/workbench.html"
);
const productJsonPath = path.join(appRoot, "product.json");
// Step 1: Write custom.css
const cssContent = `
.quick-input-widget {
width: 80vw !important;
left: 50% !important;
transform: translateX(-50%) !important;
margin-left: 0 !important;
max-width: 1500px !important;
}
`.trim();
await fs.writeFile(cssPath, cssContent, "utf8");
// Step 2: Modify workbench.html
let html = await fs.readFile(htmlPath, "utf8");
const cssTag = `<link rel="stylesheet" href="../../../workbench/workbench.desktop.main.css">`;
const cssHash = createHash("sha256")
.update(cssContent)
.digest("hex")
.slice(0, 8);
const customTag = `<link rel="stylesheet" href="../../../workbench/custom.css?v=${cssHash}">`;
// Remove existing custom.css
html = html
.split("\n")
.filter((line) => !line.includes('href="../../../workbench/custom.css'))
.join("\n");
// Insert new custom tag
html = html.replace(cssTag, `${cssTag}\n\t\t${customTag}`);
// Update html file
await fs.writeFile(htmlPath, html, "utf8");
console.log("Custom CSS updated with version:", cssHash);
// Step 3: Compute checksum of modified workbench.html
const contents = await fs.readFile(htmlPath);
const checksum = createHash("sha256")
.update(contents)
.digest("base64")
.replace(/=+$/, "");
// Step 4: Update product.json
const productRaw = await fs.readFile(productJsonPath, "utf8");
const product = JSON.parse(productRaw);
if (
product.checksums["vs/code/electron-sandbox/workbench/workbench.html"] !==
checksum
) {
product.checksums["vs/code/electron-sandbox/workbench/workbench.html"] =
checksum;
await fs.writeFile(productJsonPath, JSON.stringify(product, null, 2), "utf8");
console.log("Checksum updated:", checksum);
} else {
console.log("Checksum already up to date:", checksum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment