Fix A small bug with the marketplace uninstall button and some css, run format.

This commit is contained in:
wearrrrr 2024-07-12 15:24:14 -05:00
parent fe8833e4ec
commit 67d9de5adc
11 changed files with 1943 additions and 1938 deletions

3715
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -78,5 +78,4 @@ const languageList = [
// }, 1000);
// }
// }
</script>

View file

@ -1,5 +1,4 @@
<script>
function switchTheme() {
let currentTheme = localStorage.getItem("alu__selectedTheme");
@ -42,7 +41,7 @@
});
}
};
}
};
function loadStyleFromAtob() {
const style = document.createElement("style");
style.textContent = window.loadedThemeAtob;

View file

@ -82,8 +82,5 @@ export async function registerAndUpdateSW() {
}
export async function initTransport() {
await TransportMgr.setTransport(
TransportMgr.getTransport(),
localStorage.getItem("alu__wispUrl") || wispURLDefault
);
await TransportMgr.setTransport(TransportMgr.getTransport(), localStorage.getItem("alu__wispUrl") || wispURLDefault);
}

View file

@ -4,13 +4,9 @@ import marketplaceManifest from "../../json/marketplace.json";
const installButtons = document.getElementsByClassName("btn-install");
import IDBManager, { type ExtensionMetadata } from "./IDBManager";
// This just makes it shorter to type
interface HTMLButton extends HTMLButtonElement {}
enum EXT_RETURN {
ACTION_SUCCESS = 0,
INSTALL_FAILED = -1,
@ -52,8 +48,7 @@ Array.from(installButtons).forEach((btn) => {
});
}
});
};
}
break;
case EXT_RETURN.ALREADY_INSTALLED:
notifMessage = `${title} is already installed!`;
@ -70,7 +65,7 @@ Array.from(installButtons).forEach((btn) => {
notification.success(notifMessage);
setTimeout(() => {
window.location.reload();
}, 1000)
}, 1000);
notification.options.duration = 999999;
let btn = document.querySelector(`button[data-slug="${ret.slug}"]`) as HTMLButton;
setInstallBtnText(btn);
@ -119,12 +114,13 @@ async function installExtension(ext: ExtensionMetadata, slug: string): Promise<I
});
}
document.querySelectorAll("button[data-uninstall-slug]").forEach((btn) => {
function addUninstallEventListeners() {
document.querySelectorAll("button[data-uninstall-slug]").forEach((btn) => {
btn.addEventListener("click", async (event) => {
if (!confirm("Are you sure you want to uninstall this extension?")) {
return;
}
let uninst = await uninstallExtension((event.target as HTMLButton).dataset.uninstallSlug!)
let uninst = await uninstallExtension((event.target as HTMLButton).dataset.uninstallSlug!);
let notification = new Notyf({
duration: 999999,
position: { x: "right", y: "bottom" },
@ -147,8 +143,16 @@ document.querySelectorAll("button[data-uninstall-slug]").forEach((btn) => {
setTimeout(() => {
window.location.reload();
}, 2000);
})
})
});
});
}
addUninstallEventListeners();
document.addEventListener("astro:after-swap", () => {
addUninstallEventListeners();
});
async function uninstallExtension(slug: string): Promise<InstallReturn> {
return new Promise<InstallReturn>((resolve, reject) => {
@ -168,7 +172,7 @@ async function uninstallExtension(slug: string): Promise<InstallReturn> {
let currTheme = localStorage.getItem("alu__selectedTheme");
if (currTheme) {
if (JSON.parse(currTheme!).value == ext.result.themeName) {
console.log("Reverting theme to default!")
console.log("Reverting theme to default!");
localStorage.setItem("alu__selectedTheme", JSON.stringify({ name: "Alu", value: "alu" }));
}
}
@ -190,7 +194,7 @@ async function uninstallExtension(slug: string): Promise<InstallReturn> {
};
};
});
};
}
function setInstallBtnText(btn: HTMLButton) {
btn.disabled = true;

View file

@ -1,7 +1,7 @@
{
"dev.wearr.adblock": {
"title": "Alu Adblocker",
"description": "Alu Adblocker is the best adblocker for web proxy services. It blocks up to 97% of all trackers and ads.",
"description": "Alu Adblocker is the best adblocker for web proxy services. Blocking up to 97% of all trackers and ads.",
"version": "0.0.1",
"image": "/marketplace/adblock/adblock.png",
"script": "/marketplace/adblock/index.js",

View file

@ -29,33 +29,33 @@ export function getStaticPaths() {
</Layout>
<script>
let search = document.getElementById('games-search-input') as HTMLInputElement;
let mainContent = document.getElementById('main-content') as HTMLDivElement;
search.addEventListener('input', () => {
let search = document.getElementById("games-search-input") as HTMLInputElement;
let mainContent = document.getElementById("main-content") as HTMLDivElement;
search.addEventListener("input", () => {
let filter = search.value.toUpperCase();
let games = mainContent.children;
let results = 0;
for (let i = 0; i < games.length; i++) {
let game = games[i] as HTMLDivElement;
let name = game.getAttribute('data-name')!;
let name = game.getAttribute("data-name")!;
if (name.toUpperCase().indexOf(filter) > -1) {
game.style.display = '';
game.style.display = "";
results++;
} else {
game.style.display = 'none';
game.style.display = "none";
}
}
console.log(results)
console.log(results);
if (results === 0) {
let noResults = document.querySelector('.no-results') as HTMLDivElement;
let noResults = document.querySelector(".no-results") as HTMLDivElement;
if (noResults) {
noResults.style.display = 'block';
noResults.innerHTML = 'No results found';
noResults.style.display = "block";
noResults.innerHTML = "No results found";
}
} else {
let noResults = document.querySelector('.no-results') as HTMLDivElement;
let noResults = document.querySelector(".no-results") as HTMLDivElement;
if (noResults) {
noResults.style.display = 'none';
noResults.style.display = "none";
}
}
});

View file

@ -71,6 +71,11 @@ type MarketplaceItem = {
padding: 20px;
border-radius: 15px;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.marketplace-item-image {
width: 64px;
@ -79,6 +84,10 @@ type MarketplaceItem = {
.marketplace-item-desc {
width: 80%;
margin: 0 auto;
overflow: hidden;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
height: 40px;
}
.marketplace-btn {
width: 100%;