diff --git a/.vite/pack-extension.js b/.vite/pack-extension.js index 88ca1ee..903602c 100644 --- a/.vite/pack-extension.js +++ b/.vite/pack-extension.js @@ -3,6 +3,7 @@ import path from "path"; import { buildScriptsAndStyles } from "./lib/content-scripts.js"; import { extractInlineScriptsFromIndex } from "./lib/index-file.js"; import { normalizePath } from "vite"; +import fs from "fs"; /** * Build addition assets required for the extension and pack it into the directory. @@ -92,6 +93,47 @@ export async function packExtension(settings) { manifest.passVersionFromPackage(path.resolve(settings.rootDir, 'package.json')); manifest.saveTo(path.resolve(settings.exportDir, 'manifest.json')); + const iconsDirectory = path.resolve(settings.exportDir, 'icons'); + + switch (process.env.SITE) { + case "derpibooru": + case "tantabus": + const siteIconsDirectory = path.resolve(iconsDirectory, process.env.SITE); + + if (!fs.existsSync(siteIconsDirectory)) { + console.warn(`Can't find replacement icons for site ${process.env.SITE}`); + break; + } + + console.log(`Found replacement icons for ${process.env.SITE}, swapping them...`); + + fs.readdirSync(siteIconsDirectory).forEach(fileName => { + const originalIconPath = path.resolve(settings.exportDir, fileName); + const replacementIconPath = path.resolve(siteIconsDirectory, fileName); + + if (!fs.existsSync(originalIconPath)) { + console.warn(`Original icon not found: ${originalIconPath}`) + return; + } + + fs.rmSync(originalIconPath); + fs.cpSync(replacementIconPath, originalIconPath); + + console.log(`Replaced: ${path.relative(settings.rootDir, replacementIconPath)} → ${path.relative(settings.rootDir, originalIconPath)}`); + }); + + break; + } + + if (fs.existsSync(iconsDirectory)) { + console.log('Cleaning up icon replacements directory'); + + fs.rmSync(iconsDirectory, { + recursive: true, + force: true, + }); + } + extractInlineScriptsFromIndex(path.resolve(settings.exportDir, 'index.html')); } diff --git a/src/assets/icon/README.md b/src/assets/icon/README.md new file mode 100644 index 0000000..3e715cb --- /dev/null +++ b/src/assets/icon/README.md @@ -0,0 +1,57 @@ +# Extension Icon + +This folder contains original resources used to make an icon for the extension. Since I'm not really an icon designer, I +ended up just composing the icon from sites logos + the shorthand name of the extension with fancy font. Nothing +special. + +## Sources + +All resources used for composing an icon are stored here as copies just to not lose anything. Original assets are +sourced from the following places: + +- [Derpibooru Logo](https://github.com/derpibooru/philomena/blob/40ffb1b75bd0d96db24fa7c84bce36fcb7f2935f/assets/static/favicon.svg) +- [Furbooru Logo](https://github.com/furbooru/philomena/blob/cbfde406de34734403c06952bcaca51db6df1390/assets/static/favicon.svg) +- [Tantabus Logo](https://github.com/tantabus-ai/philomena/blob/285a7666ae4be46ac4da36bbc9ac8fda9e5c0fc3/assets/static/favicon.svg) +- [RoundFeather Font](https://drive.google.com/file/d/18ggNplAZNYtO4eNtMUpv3XpkeOAxSkxm/view?usp=sharing) + - Made by [allorus162](https://bsky.app/profile/allorus162.bsky.social) + - [Original Bluesky post](https://bsky.app/profile/allorus162.bsky.social/post/3mfqntff4j22i) + +## Rendering + +**Note:** You don't need to do anything to pack current version of icon to the extension. All icons are already pre-rendered and +placed into the `static` directory. + +For now, any change to the icons will require manual re-rendering of PNG versions of the logos used when packing +extension for the release. All you need is to open `/src/assets/icon/icon.svg` in software like Inskape, hide the +currently opened logo and toggle the required one and save it into `icon256.png`, `icon128.png`, `icon48.png` and +`icon16.png`. + +For the font on the bottom-right to work, you will need to install it from the file +`src/assets/icon/fonts/roundfeather-regular-1.001.ttf` (or you can download and install it from the source link). + +You should render them into `/static` directory in the following structure: + +- Place Furbooru icons into `/static` directory +- Then add same icons for Derpibooru and Tantabus into `/static/icons/depribooru` and `/static/icons/tantabus` + respectively. + +Resulting structure will look like this: + +``` +static/ + icons/ + derpibooru/ + icon16.png + icon48.png + icon128.png + icon256.png + tantabus/ + icon16.png + icon48.png + icon128.png + icon256.png + icon16.png + icon48.png + icon128.png + icon256.png +``` diff --git a/src/assets/icon/favicons/derpibooru.svg b/src/assets/icon/favicons/derpibooru.svg new file mode 100644 index 0000000..2dec1d7 --- /dev/null +++ b/src/assets/icon/favicons/derpibooru.svg @@ -0,0 +1,2 @@ + + diff --git a/src/assets/icon/favicons/furbooru.svg b/src/assets/icon/favicons/furbooru.svg new file mode 100644 index 0000000..0d5f3a7 --- /dev/null +++ b/src/assets/icon/favicons/furbooru.svg @@ -0,0 +1,2 @@ + + diff --git a/src/assets/icon/favicons/tantabus.svg b/src/assets/icon/favicons/tantabus.svg new file mode 100644 index 0000000..6c07350 --- /dev/null +++ b/src/assets/icon/favicons/tantabus.svg @@ -0,0 +1,41 @@ + + diff --git a/src/assets/icon/fonts/roundfeather-regular-1.001.ttf b/src/assets/icon/fonts/roundfeather-regular-1.001.ttf new file mode 100644 index 0000000..73030eb Binary files /dev/null and b/src/assets/icon/fonts/roundfeather-regular-1.001.ttf differ diff --git a/src/assets/icon/icon.svg b/src/assets/icon/icon.svg new file mode 100644 index 0000000..48e85b2 --- /dev/null +++ b/src/assets/icon/icon.svg @@ -0,0 +1,115 @@ + +PTA diff --git a/static/icon.svg b/static/icon.svg deleted file mode 100644 index 1cf7596..0000000 --- a/static/icon.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/static/icon128.png b/static/icon128.png index 050b1d8..a6441ae 100644 Binary files a/static/icon128.png and b/static/icon128.png differ diff --git a/static/icon16.png b/static/icon16.png index 63dd587..d92f9e7 100644 Binary files a/static/icon16.png and b/static/icon16.png differ diff --git a/static/icon256.png b/static/icon256.png index 5954b69..0d108fa 100644 Binary files a/static/icon256.png and b/static/icon256.png differ diff --git a/static/icon48.png b/static/icon48.png index 296725d..05909da 100644 Binary files a/static/icon48.png and b/static/icon48.png differ diff --git a/static/icons/derpibooru/icon128.png b/static/icons/derpibooru/icon128.png new file mode 100644 index 0000000..d8f8e24 Binary files /dev/null and b/static/icons/derpibooru/icon128.png differ diff --git a/static/icons/derpibooru/icon16.png b/static/icons/derpibooru/icon16.png new file mode 100644 index 0000000..f2d30be Binary files /dev/null and b/static/icons/derpibooru/icon16.png differ diff --git a/static/icons/derpibooru/icon256.png b/static/icons/derpibooru/icon256.png new file mode 100644 index 0000000..bcfdfc0 Binary files /dev/null and b/static/icons/derpibooru/icon256.png differ diff --git a/static/icons/derpibooru/icon48.png b/static/icons/derpibooru/icon48.png new file mode 100644 index 0000000..958c8fb Binary files /dev/null and b/static/icons/derpibooru/icon48.png differ diff --git a/static/icons/tantabus/icon128.png b/static/icons/tantabus/icon128.png new file mode 100644 index 0000000..489139d Binary files /dev/null and b/static/icons/tantabus/icon128.png differ diff --git a/static/icons/tantabus/icon16.png b/static/icons/tantabus/icon16.png new file mode 100644 index 0000000..1547eb8 Binary files /dev/null and b/static/icons/tantabus/icon16.png differ diff --git a/static/icons/tantabus/icon256.png b/static/icons/tantabus/icon256.png new file mode 100644 index 0000000..7fc0fb4 Binary files /dev/null and b/static/icons/tantabus/icon256.png differ diff --git a/static/icons/tantabus/icon48.png b/static/icons/tantabus/icon48.png new file mode 100644 index 0000000..295e002 Binary files /dev/null and b/static/icons/tantabus/icon48.png differ