Add Vencord save support

This commit is contained in:
Idrees Hassan
2025-11-16 11:05:44 -05:00
parent e7be2b7661
commit 37a30ea509
10 changed files with 85 additions and 16 deletions

BIN
dist/extension.zip vendored

Binary file not shown.

View File

@@ -976,9 +976,9 @@
// @ts-expect-error
if (chrome.runtime.lastError) {
// @ts-expect-error
console.error(chrome.runtime.lastError);
error(chrome.runtime.lastError);
} else {
console.log("Settings saved successfully");
log("Settings saved successfully");
}
});
}
@@ -1693,6 +1693,13 @@
border: none !important;
}
.birb-sticky-note-input::placeholder {
font-family: "Monocraft", monospace !important;
font-size: 14px !important;
background-color: transparent !important;
color: rgba(0, 0, 0, 0.35) !important;
}
.birb-sticky-note-input:focus {
outline: none !important;
box-shadow: none !important;

View File

@@ -1736,6 +1736,13 @@ module.exports = class PocketBird extends Plugin {
border: none !important;
}
.birb-sticky-note-input::placeholder {
font-family: "Monocraft", monospace !important;
font-size: 14px !important;
background-color: transparent !important;
color: rgba(0, 0, 0, 0.35) !important;
}
.birb-sticky-note-input:focus {
outline: none !important;
box-shadow: none !important;

View File

@@ -1698,6 +1698,13 @@
border: none !important;
}
.birb-sticky-note-input::placeholder {
font-family: "Monocraft", monospace !important;
font-size: 14px !important;
background-color: transparent !important;
color: rgba(0, 0, 0, 0.35) !important;
}
.birb-sticky-note-input:focus {
outline: none !important;
box-shadow: none !important;

25
dist/vencord/birb.js vendored
View File

@@ -950,15 +950,15 @@ export const Birb = () => {
}
}
class LocalContext extends Context {
class VencordContext extends Context {
/**
* @override
* @returns {Promise<BirbSaveData|{}>}
*/
async getSaveData() {
log("Loading save data from localStorage");
return JSON.parse(localStorage.getItem(SAVE_KEY) ?? "{}");
// @ts-expect-error
return await Vencord.Api.DataStore.get(SAVE_KEY) ?? {};
}
/**
@@ -966,14 +966,14 @@ export const Birb = () => {
* @param {BirbSaveData} saveData
*/
async putSaveData(saveData) {
log("Saving data to localStorage");
localStorage.setItem(SAVE_KEY, JSON.stringify(saveData));
// @ts-expect-error
await Vencord.Api.DataStore.set(SAVE_KEY, saveData);
}
/** @override */
resetSaveData() {
log("Resetting save data in localStorage");
localStorage.removeItem(SAVE_KEY);
// @ts-expect-error
Vencord.Api.DataStore.del(SAVE_KEY);
}
}
@@ -1679,6 +1679,13 @@ export const Birb = () => {
border: none !important;
}
.birb-sticky-note-input::placeholder {
font-family: "Monocraft", monospace !important;
font-size: 14px !important;
background-color: transparent !important;
color: rgba(0, 0, 0, 0.35) !important;
}
.birb-sticky-note-input:focus {
outline: none !important;
box-shadow: none !important;
@@ -2616,7 +2623,7 @@ export const Birb = () => {
});
}
initializeApplication(new LocalContext());
initializeApplication(new VencordContext());
})();

7
dist/web/birb.js vendored
View File

@@ -1678,6 +1678,13 @@
border: none !important;
}
.birb-sticky-note-input::placeholder {
font-family: "Monocraft", monospace !important;
font-size: 14px !important;
background-color: transparent !important;
color: rgba(0, 0, 0, 0.35) !important;
}
.birb-sticky-note-input:focus {
outline: none !important;
box-shadow: none !important;

View File

@@ -26,6 +26,6 @@
</div>
<div id="spacer"></div>
<!-- <script type="module" src="spritesheet-compiler.js"></script> -->
<script src="../dist/birb.js"></script>
<script src="../dist/web/birb.js"></script>
</body>
</html>

View File

@@ -181,9 +181,9 @@ export class BrowserExtensionContext extends Context {
// @ts-expect-error
if (chrome.runtime.lastError) {
// @ts-expect-error
console.error(chrome.runtime.lastError);
error(chrome.runtime.lastError);
} else {
console.log("Settings saved successfully");
log("Settings saved successfully");
}
});
}
@@ -276,6 +276,33 @@ export class ObsidianContext extends Context {
}
}
export class VencordContext extends Context {
/**
* @override
* @returns {Promise<BirbSaveData|{}>}
*/
async getSaveData() {
// @ts-expect-error
return await Vencord.Api.DataStore.get(SAVE_KEY) ?? {};
}
/**
* @override
* @param {BirbSaveData} saveData
*/
async putSaveData(saveData) {
// @ts-expect-error
await Vencord.Api.DataStore.set(SAVE_KEY, saveData);
}
/** @override */
resetSaveData() {
// @ts-expect-error
Vencord.Api.DataStore.del(SAVE_KEY);
}
}
/**
* Parse URL parameters into a key-value map
* @param {string} url

View File

@@ -1,4 +1,4 @@
import { initializeApplication } from "../../application.js";
import { LocalContext } from "../../context.js";
import { VencordContext } from "../../context.js";
initializeApplication(new LocalContext());
initializeApplication(new VencordContext());

View File

@@ -357,6 +357,13 @@
border: none !important;
}
.birb-sticky-note-input::placeholder {
font-family: "Monocraft", monospace !important;
font-size: 14px !important;
background-color: transparent !important;
color: rgba(0, 0, 0, 0.35) !important;
}
.birb-sticky-note-input:focus {
outline: none !important;
box-shadow: none !important;