Skip to content

Commit

Permalink
Added Hide WaterMark (#109)
Browse files Browse the repository at this point in the history
* Working on hiding watermark

* Fixed sticker scrubbing.

* Updated documentation

* Updated changelog
  • Loading branch information
Unthrottled authored Aug 22, 2021
1 parent 1784d74 commit 56b3464
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 74 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

# 15.2.0 [Hide Watermark]

- Added the **Hide VSCode Watermark** command that...well... hides the VS Code watermark that shows when all editor tabs are closed.

![Hidden Watermark](https://user-images.githubusercontent.com/15972415/130338907-3105bf84-5715-4488-879a-db58c5c4c1cb.png)


# 15.1.1 [Asset Installation UX]

- Installation progress notification goes away after install. [#107](https://github.com/doki-theme/doki-theme-vscode/issues/107)
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ You can choose themes from various, Anime, Manga, or Visual Novels:

- [Configuration](#configuration)
- [Background Images](#background-images)
- [Hide VSCode Watermark](#hide-watermark)
- [Stickers](#sticker)
- [Custom Assets](#custom-assets)
- [Suggestive Content](#suggestive-content)
Expand All @@ -83,6 +84,15 @@ This feature will set the background image to the current theme's official wallp
![Zero Two Code](./readmeStuff/wallpaper_code.png)
![Zero Two Code](./readmeStuff/wallpaper_background.png)

## Hide Watermark

Tired of the the VSCode watermark cramping your style?
You have the ability to hide it using **Hide VSCode Watermark**, so you can fully enjoy your art.

**Important!!** Hiding the watermark requires me to corrupt VS-Code by modifying CSS. You will have to use the "Remove Sticker/Background" command to restore VS Code back to supported status before unistalling. You can close VSCode and start it back up remove the annoying `Unsupported` warning. The plugin automatically fixes VSCode's checksums.

![Hidden Watermark](./readmeStuff/hide_watermark.gif)

## Stickers

**Show sticker** allows you to control the presence of the cute sticker in the bottom right-hand corner of your IDE.
Expand All @@ -91,7 +101,6 @@ This feature will set the background image to the current theme's official wallp

![Ibuki's Dark Sticker](./readmeStuff/sticker.png)


## Custom Assets

Hey alright, you have the ability to set the image to be used for all the doki-themes. Allowed image types: jpg, png, gif. You'll have to put these changes in the `settings.json` in your VSCode.
Expand Down
79 changes: 42 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "The Doki Theme",
"description": "A bunch of themes with cute anime girls. Code with your waifu!",
"publisher": "unthrottled",
"version": "15.1.1",
"version": "15.2.0",
"license": "MIT",
"icon": "Doki-Theme.png",
"galleryBanner": {
Expand Down Expand Up @@ -32,6 +32,7 @@
"onStartupFinished",
"onCommand:doki-theme.doki.changelog",
"onCommand:doki-theme.remove.sticker",
"onCommand:doki-theme.remove.watermark",
"onCommand:doki-theme.theme.Maika",
"onCommand:doki-theme.theme.wallpaper.Maika",
"onCommand:doki-theme.theme.Mai Dark",
Expand Down Expand Up @@ -221,6 +222,10 @@
"command": "doki-theme.remove.sticker",
"title": "Doki-Theme: Remove Sticker/Background"
},
{
"command": "doki-theme.remove.watermark",
"title": "Doki-Theme: Hide VSCode Watermark"
},
{
"command": "doki-theme.theme.Maika",
"title": "Doki-Theme: Install Maika's Sticker"
Expand Down Expand Up @@ -835,22 +840,16 @@
"path": "./generatedThemes/Maika.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "98878c8e-9f91-4e25-930d-dd7d280d9e35",
"label": "Doki Theme: BunnySenpai: Mai",
"path": "./generatedThemes/Mai Light.theme.json",
"uiTheme": "vs"
},
{
"id": "0527c6fc-316a-4f80-9459-d92ced0e6492",
"label": "Doki Theme: BunnySenpai: Mai",
"path": "./generatedThemes/Mai Dark.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "9a310731-ab2d-40f5-b502-fa5419f799a2",
"label": "Doki Theme: DDLC: Monika",
"path": "./generatedThemes/Monika Light.theme.json",
"id": "98878c8e-9f91-4e25-930d-dd7d280d9e35",
"label": "Doki Theme: BunnySenpai: Mai",
"path": "./generatedThemes/Mai Light.theme.json",
"uiTheme": "vs"
},
{
Expand All @@ -860,9 +859,9 @@
"uiTheme": "vs-dark"
},
{
"id": "91415015-8fe3-48eb-9951-70a5cd6cbb7f",
"label": "Doki Theme: DDLC: Natsuki",
"path": "./generatedThemes/Natsuki Light.theme.json",
"id": "9a310731-ab2d-40f5-b502-fa5419f799a2",
"label": "Doki Theme: DDLC: Monika",
"path": "./generatedThemes/Monika Light.theme.json",
"uiTheme": "vs"
},
{
Expand All @@ -871,6 +870,12 @@
"path": "./generatedThemes/Natsuki Dark.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "91415015-8fe3-48eb-9951-70a5cd6cbb7f",
"label": "Doki Theme: DDLC: Natsuki",
"path": "./generatedThemes/Natsuki Light.theme.json",
"uiTheme": "vs"
},
{
"id": "cb8ef4b7-0844-4a04-b08b-754086598de4",
"label": "Doki Theme: DDLC: Sayori",
Expand Down Expand Up @@ -949,18 +954,18 @@
"path": "./generatedThemes/Rei.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "4fd5cb34-d36e-4a3c-8639-052b19b26ba1",
"label": "Doki Theme: Franxx: Zero Two",
"path": "./generatedThemes/Zero Two Light.theme.json",
"uiTheme": "vs"
},
{
"id": "8c99ec4b-fda0-4ab7-95ad-a6bf80c3924b",
"label": "Doki Theme: Franxx: Zero Two",
"path": "./generatedThemes/Zero Two Dark.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "4fd5cb34-d36e-4a3c-8639-052b19b26ba1",
"label": "Doki Theme: Franxx: Zero Two",
"path": "./generatedThemes/Zero Two Light.theme.json",
"uiTheme": "vs"
},
{
"id": "5ec63d95-1e7d-4649-b3d0-0078af8f8740",
"label": "Doki Theme: FutureDiary: Yuno",
Expand Down Expand Up @@ -997,18 +1002,18 @@
"path": "./generatedThemes/Aqua.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "8474d98d-7bb1-462c-82b1-dd7c512142a6",
"label": "Doki Theme: KonoSuba: Darkness",
"path": "./generatedThemes/Darkness Light.theme.json",
"uiTheme": "vs"
},
{
"id": "774ec7ad-d6a0-4d9c-b195-2f54d72ab664",
"label": "Doki Theme: KonoSuba: Darkness",
"path": "./generatedThemes/Darkness Dark.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "8474d98d-7bb1-462c-82b1-dd7c512142a6",
"label": "Doki Theme: KonoSuba: Darkness",
"path": "./generatedThemes/Darkness Light.theme.json",
"uiTheme": "vs"
},
{
"id": "63fe4617-4cac-47a5-9b93-6794514c35ad",
"label": "Doki Theme: KonoSuba: Megumin",
Expand Down Expand Up @@ -1063,18 +1068,18 @@
"path": "./generatedThemes/Coconut.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "ea7a8b00-2d86-4e06-81a2-5c14a46264d5",
"label": "Doki Theme: NekoPara: Maple",
"path": "./generatedThemes/Maple Light.theme.json",
"uiTheme": "vs"
},
{
"id": "13407818-da66-432b-94e3-fd2192e98118",
"label": "Doki Theme: NekoPara: Maple",
"path": "./generatedThemes/Maple Dark.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "ea7a8b00-2d86-4e06-81a2-5c14a46264d5",
"label": "Doki Theme: NekoPara: Maple",
"path": "./generatedThemes/Maple Light.theme.json",
"uiTheme": "vs"
},
{
"id": "31d5574d-f56b-408f-81dc-9d44feeb62c2",
"label": "Doki Theme: NekoPara: Vanilla",
Expand Down Expand Up @@ -1111,18 +1116,18 @@
"path": "./generatedThemes/Echidna.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "e828aaae-aa8c-4084-8993-d64697146930",
"label": "Doki Theme: Re:Zero: Emilia",
"path": "./generatedThemes/Emilia Light.theme.json",
"uiTheme": "vs"
},
{
"id": "696de7c1-3a8e-4445-83ee-3eb7e9dca47f",
"label": "Doki Theme: Re:Zero: Emilia",
"path": "./generatedThemes/Emilia Dark.theme.json",
"uiTheme": "vs-dark"
},
{
"id": "e828aaae-aa8c-4084-8993-d64697146930",
"label": "Doki Theme: Re:Zero: Emilia",
"path": "./generatedThemes/Emilia Light.theme.json",
"uiTheme": "vs"
},
{
"id": "ecb74f1c-8c84-40c4-916f-601039ba2af0",
"label": "Doki Theme: Re:Zero: Ram",
Expand Down
Binary file added readmeStuff/hide_watermark.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 3 additions & 11 deletions src/ConfigWatcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from "vscode";
import { fixCheckSums } from "./CheckSumService";
import { InstallStatus } from "./StickerService";
import { attemptToInstallSticker, attemptToInstallWallpaper, getCurrentThemeAndSticker, handleInstallFailure } from "./ThemeManager";
import { attemptToInstallSticker, attemptToInstallWallpaper, getCurrentThemeAndSticker, handleInstallFailure, handleInstallMessage, showInstallNotification } from "./ThemeManager";

export const CONFIG_NAME = "doki";
export const CONFIG_STICKER = "sticker.path";
Expand Down Expand Up @@ -52,16 +52,8 @@ export const watchConfigChanges = (
handleInstallFailure(extensionContext, theme);
} else if (hadSuccess) {
fixCheckSums();
vscode.window
.showInformationMessage(
`Custom Assets installed!\n Please restart your VSCode`,
{ title: "Restart VSCode" }
)
.then((item) => {
if (item) {
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
});
const message = `VSCode Watermark hidden! ${handleInstallMessage}`;
showInstallNotification(message)
}
currentConfig = newBoiConfig
})
Expand Down
2 changes: 1 addition & 1 deletion src/NotificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { VSCodeGlobals } from "./VSCodeGlobals";
import { attemptToGreetUser } from "./WelcomeService";

const SAVED_VERSION = "doki.theme.version";
const DOKI_THEME_VERSION = "v15.1.1";
const DOKI_THEME_VERSION = "v15.2.0";

export function attemptToNotifyUpdates(context: vscode.ExtensionContext) {
const savedVersion = VSCodeGlobals.globalState.get(SAVED_VERSION);
Expand Down
74 changes: 63 additions & 11 deletions src/StickerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export enum InstallStatus {
}

const stickerComment = "/* Stickers */";
const hideComment = "/* Hide Watermark */";
const wallpaperComment = "/* Background Image */";

const getStickerIndex = (currentCss: string) =>
currentCss.indexOf(stickerComment);
const getHideIndex = (currentCss: string) =>
currentCss.indexOf(hideComment);
const getWallpaperIndex = (currentCss: string) =>
currentCss.indexOf(wallpaperComment);

Expand Down Expand Up @@ -143,6 +146,19 @@ function buildStickerCss({ stickerDataURL: stickerUrl }: DokiStickers): string {
`;
}

function buildHideWaterMarkCSS(): string {
return `
${hideComment}
.monaco-workbench .part.editor.has-watermark>.content.empty .editor-group-container>.editor-group-letterpress,
.monaco-workbench .part.editor>.content.empty>.watermark>.watermark-box
{
display: none !important;
}
`;
}



function buildCSSWithStickers(dokiStickers: DokiStickers): string {
return `${getStickerScrubbedCSS()}${buildStickerCss(dokiStickers)}`;
}
Expand All @@ -151,6 +167,11 @@ function buildCSSWithWallpaper(dokiStickers: DokiStickers): string {
return `${getWallpaperScrubbedCSS()}${buildWallpaperCss(dokiStickers)}`;
}

function buildCSSWithoutWatermark(): string {
return `${getWatermarkScrubbedCSS()}${buildHideWaterMarkCSS()}`;
}


function installEditorStyles(styles: string) {
fs.writeFileSync(editorCss, styles, "utf-8");
}
Expand Down Expand Up @@ -189,6 +210,14 @@ export async function installWallPaper(
);
}

export async function hideWaterMark(): Promise<InstallStatus> {
if (!canWrite()) return InstallStatus.FAILURE;

installEditorStyles(buildCSSWithoutWatermark())
return InstallStatus.INSTALLED
}


async function installStyles(
sticker: Sticker,
context: vscode.ExtensionContext,
Expand All @@ -213,36 +242,59 @@ async function installStyles(

function getScrubbedCSS() {
const currentCss = fs.readFileSync(editorCss, "utf-8");
const stickerIndex = getStickerIndex(currentCss);
const trimmedCss = trimCss(currentCss, stickerIndex);
return trimCss(trimmedCss, getWallpaperIndex(trimmedCss));
return indexGetters.reduce(
(trimmedCss, indexFinderDude) => trimCss(trimmedCss, indexFinderDude(trimmedCss)),
currentCss
);
}

type IndexFinderDude = (currentCss: string) => number;

function scrubCssOfAsset(
getAssetOneIndex: (currentCss: string) => number,
getAssetToRemoveIndex: (currentCss: string) => number
getOtherAssets: IndexFinderDude[],
getAssetToRemoveIndex: IndexFinderDude
) {
const currentCss = fs.readFileSync(editorCss, "utf-8");
const otherAssetIndex = getAssetOneIndex(currentCss);
const otherAssetIndices = getOtherAssets.map(assetFinder => assetFinder(currentCss));
const assetToRemoveIndex = getAssetToRemoveIndex(currentCss);
if (otherAssetIndex < 0) {
const otherIndex = otherAssetIndices.reduce((accum, index) => Math.max(accum, index), -1);
if (otherIndex < 0) {
return trimCss(currentCss, assetToRemoveIndex);
} else if (assetToRemoveIndex > -1) {
const smolestGreater = otherAssetIndices
.filter(otherIndex => assetToRemoveIndex < otherIndex)
.reduce((accum, index) => Math.min(accum, index), Number.POSITIVE_INFINITY)
return (
currentCss.substring(0, assetToRemoveIndex) +
(assetToRemoveIndex < otherAssetIndex
? "\n" + currentCss.substring(otherAssetIndex, currentCss.length)
(smolestGreater < Number.POSITIVE_INFINITY
? "\n" + currentCss.substring(smolestGreater, currentCss.length)
: "")
);
}
return currentCss;
}

const indexGetters = [
getStickerIndex, getWallpaperIndex, getHideIndex
]

function getWallpaperScrubbedCSS() {
return scrubCssOfAsset(getStickerIndex, getWallpaperIndex);
return scrubCssOfAsset(
indexGetters.filter(getter => getter !== getWallpaperIndex),
getWallpaperIndex
);
}
function getStickerScrubbedCSS() {
return scrubCssOfAsset(getWallpaperIndex, getStickerIndex);
return scrubCssOfAsset(
indexGetters.filter(getter => getter !== getStickerIndex),
getStickerIndex
);
}
function getWatermarkScrubbedCSS() {
return scrubCssOfAsset(
indexGetters.filter(getter => getter !== getHideIndex),
getHideIndex
);
}

function trimCss(currentCss: string, index: number): string {
Expand Down
Loading

0 comments on commit 56b3464

Please sign in to comment.