diff --git a/.gitignore b/.gitignore index 9b1ee42..402da6a 100644 --- a/.gitignore +++ b/.gitignore @@ -173,3 +173,5 @@ dist # Finder (MacOS) folder config .DS_Store + +tweaks_*.zip \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 4d78c4e..39e57ef 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 1b6a595..cdd7ba1 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,18 @@ { "name": "tweaks", + "version": "0.1.0", "module": "index.ts", "type": "module", "scripts": { - "dev": "vite" + "dev": "vite", + "build": "vite build && npm-build-zip --source=dist --destination=." }, "devDependencies": { "@biomejs/biome": "^1.8.3", "@types/bun": "latest", "@types/lodash.isequal": "^4.5.8", "@types/webextension-polyfill": "^0.10.7", + "npm-build-zip": "^1.0.4", "vite-plugin-web-extension": "^4.1.6" }, "peerDependencies": { @@ -20,4 +23,4 @@ "vite": "^5.3.5", "webextension-polyfill": "^0.12.0" } -} \ No newline at end of file +} diff --git a/src/dom.ts b/src/dom.ts index 4d73adb..5ee0fa5 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -1,4 +1,5 @@ -import isEqual from "lodash.isequal"; +import { isPathEqual } from "./utils"; + const REFRESH_RATE = 1000; export async function waitForElementToExist( @@ -49,7 +50,7 @@ export function addPageChangeHandler(func: (path: OsuPath) => void) { hash: location.hash, }; - if (!isEqual(currentPath, newPath)) { + if (!isPathEqual(currentPath, newPath)) { func(newPath); currentPath = newPath; } diff --git a/src/utils.ts b/src/utils.ts index 29aa586..55d77b7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,7 @@ // Color parsing function + +import type { OsuPath } from "./dom"; + // minified, original is from https://stackoverflow.com/a/68580275 export function parseCssColor(str: string): [number, number, number] { const div = document.createElement("div"); @@ -10,3 +13,7 @@ export function parseCssColor(str: string): [number, number, number] { div.remove(); return res; } + +export function isPathEqual(a: OsuPath, b: OsuPath) { + return a.pathname === b.pathname && a.hash === b.hash; +}