Fix A small bug with the marketplace uninstall button and some css, run format.
This commit is contained in:
parent
fe8833e4ec
commit
67d9de5adc
11 changed files with 1943 additions and 1938 deletions
3715
pnpm-lock.yaml
generated
3715
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -78,5 +78,4 @@ const languageList = [
|
||||||
// }, 1000);
|
// }, 1000);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function switchTheme() {
|
function switchTheme() {
|
||||||
let currentTheme = localStorage.getItem("alu__selectedTheme");
|
let currentTheme = localStorage.getItem("alu__selectedTheme");
|
||||||
|
|
||||||
|
|
@ -42,7 +41,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
function loadStyleFromAtob() {
|
function loadStyleFromAtob() {
|
||||||
const style = document.createElement("style");
|
const style = document.createElement("style");
|
||||||
style.textContent = window.loadedThemeAtob;
|
style.textContent = window.loadedThemeAtob;
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,5 @@ export async function registerAndUpdateSW() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initTransport() {
|
export async function initTransport() {
|
||||||
await TransportMgr.setTransport(
|
await TransportMgr.setTransport(TransportMgr.getTransport(), localStorage.getItem("alu__wispUrl") || wispURLDefault);
|
||||||
TransportMgr.getTransport(),
|
|
||||||
localStorage.getItem("alu__wispUrl") || wispURLDefault
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,13 +4,9 @@ import marketplaceManifest from "../../json/marketplace.json";
|
||||||
const installButtons = document.getElementsByClassName("btn-install");
|
const installButtons = document.getElementsByClassName("btn-install");
|
||||||
import IDBManager, { type ExtensionMetadata } from "./IDBManager";
|
import IDBManager, { type ExtensionMetadata } from "./IDBManager";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This just makes it shorter to type
|
// This just makes it shorter to type
|
||||||
interface HTMLButton extends HTMLButtonElement {}
|
interface HTMLButton extends HTMLButtonElement {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum EXT_RETURN {
|
enum EXT_RETURN {
|
||||||
ACTION_SUCCESS = 0,
|
ACTION_SUCCESS = 0,
|
||||||
INSTALL_FAILED = -1,
|
INSTALL_FAILED = -1,
|
||||||
|
|
@ -52,8 +48,7 @@ Array.from(installButtons).forEach((btn) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
case EXT_RETURN.ALREADY_INSTALLED:
|
case EXT_RETURN.ALREADY_INSTALLED:
|
||||||
notifMessage = `${title} is already installed!`;
|
notifMessage = `${title} is already installed!`;
|
||||||
|
|
@ -70,7 +65,7 @@ Array.from(installButtons).forEach((btn) => {
|
||||||
notification.success(notifMessage);
|
notification.success(notifMessage);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}, 1000)
|
}, 1000);
|
||||||
notification.options.duration = 999999;
|
notification.options.duration = 999999;
|
||||||
let btn = document.querySelector(`button[data-slug="${ret.slug}"]`) as HTMLButton;
|
let btn = document.querySelector(`button[data-slug="${ret.slug}"]`) as HTMLButton;
|
||||||
setInstallBtnText(btn);
|
setInstallBtnText(btn);
|
||||||
|
|
@ -119,36 +114,45 @@ async function installExtension(ext: ExtensionMetadata, slug: string): Promise<I
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelectorAll("button[data-uninstall-slug]").forEach((btn) => {
|
function addUninstallEventListeners() {
|
||||||
btn.addEventListener("click", async (event) => {
|
document.querySelectorAll("button[data-uninstall-slug]").forEach((btn) => {
|
||||||
if (!confirm("Are you sure you want to uninstall this extension?")) {
|
btn.addEventListener("click", async (event) => {
|
||||||
return;
|
if (!confirm("Are you sure you want to uninstall this extension?")) {
|
||||||
}
|
return;
|
||||||
let uninst = await uninstallExtension((event.target as HTMLButton).dataset.uninstallSlug!)
|
}
|
||||||
let notification = new Notyf({
|
let uninst = await uninstallExtension((event.target as HTMLButton).dataset.uninstallSlug!);
|
||||||
duration: 999999,
|
let notification = new Notyf({
|
||||||
position: { x: "right", y: "bottom" },
|
duration: 999999,
|
||||||
dismissible: true,
|
position: { x: "right", y: "bottom" },
|
||||||
ripple: true,
|
dismissible: true,
|
||||||
|
ripple: true,
|
||||||
|
});
|
||||||
|
switch (uninst.code) {
|
||||||
|
case EXT_RETURN.ACTION_SUCCESS:
|
||||||
|
notification.success(`Uninstalled ${uninst.title}!`);
|
||||||
|
let btn = document.querySelector(`button[data-slug="${uninst.slug}"]`) as HTMLButton;
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.textContent = "Install";
|
||||||
|
btn.classList.remove("installed");
|
||||||
|
(event.target as HTMLButton).classList.add("btn-hidden");
|
||||||
|
break;
|
||||||
|
case EXT_RETURN.INSTALL_FAILED:
|
||||||
|
notification.error(`Failed to uninstall ${uninst.title}!`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 2000);
|
||||||
});
|
});
|
||||||
switch (uninst.code) {
|
});
|
||||||
case EXT_RETURN.ACTION_SUCCESS:
|
}
|
||||||
notification.success(`Uninstalled ${uninst.title}!`);
|
|
||||||
let btn = document.querySelector(`button[data-slug="${uninst.slug}"]`) as HTMLButton;
|
addUninstallEventListeners();
|
||||||
btn.disabled = false;
|
document.addEventListener("astro:after-swap", () => {
|
||||||
btn.textContent = "Install";
|
addUninstallEventListeners();
|
||||||
btn.classList.remove("installed");
|
});
|
||||||
(event.target as HTMLButton).classList.add("btn-hidden");
|
|
||||||
break;
|
|
||||||
case EXT_RETURN.INSTALL_FAILED:
|
|
||||||
notification.error(`Failed to uninstall ${uninst.title}!`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 2000);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
async function uninstallExtension(slug: string): Promise<InstallReturn> {
|
async function uninstallExtension(slug: string): Promise<InstallReturn> {
|
||||||
return new Promise<InstallReturn>((resolve, reject) => {
|
return new Promise<InstallReturn>((resolve, reject) => {
|
||||||
|
|
@ -168,7 +172,7 @@ async function uninstallExtension(slug: string): Promise<InstallReturn> {
|
||||||
let currTheme = localStorage.getItem("alu__selectedTheme");
|
let currTheme = localStorage.getItem("alu__selectedTheme");
|
||||||
if (currTheme) {
|
if (currTheme) {
|
||||||
if (JSON.parse(currTheme!).value == ext.result.themeName) {
|
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" }));
|
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) {
|
function setInstallBtnText(btn: HTMLButton) {
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"dev.wearr.adblock": {
|
"dev.wearr.adblock": {
|
||||||
"title": "Alu Adblocker",
|
"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",
|
"version": "0.0.1",
|
||||||
"image": "/marketplace/adblock/adblock.png",
|
"image": "/marketplace/adblock/adblock.png",
|
||||||
"script": "/marketplace/adblock/index.js",
|
"script": "/marketplace/adblock/index.js",
|
||||||
|
|
|
||||||
|
|
@ -29,33 +29,33 @@ export function getStaticPaths() {
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let search = document.getElementById('games-search-input') as HTMLInputElement;
|
let search = document.getElementById("games-search-input") as HTMLInputElement;
|
||||||
let mainContent = document.getElementById('main-content') as HTMLDivElement;
|
let mainContent = document.getElementById("main-content") as HTMLDivElement;
|
||||||
search.addEventListener('input', () => {
|
search.addEventListener("input", () => {
|
||||||
let filter = search.value.toUpperCase();
|
let filter = search.value.toUpperCase();
|
||||||
let games = mainContent.children;
|
let games = mainContent.children;
|
||||||
let results = 0;
|
let results = 0;
|
||||||
for (let i = 0; i < games.length; i++) {
|
for (let i = 0; i < games.length; i++) {
|
||||||
let game = games[i] as HTMLDivElement;
|
let game = games[i] as HTMLDivElement;
|
||||||
let name = game.getAttribute('data-name')!;
|
let name = game.getAttribute("data-name")!;
|
||||||
if (name.toUpperCase().indexOf(filter) > -1) {
|
if (name.toUpperCase().indexOf(filter) > -1) {
|
||||||
game.style.display = '';
|
game.style.display = "";
|
||||||
results++;
|
results++;
|
||||||
} else {
|
} else {
|
||||||
game.style.display = 'none';
|
game.style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(results)
|
console.log(results);
|
||||||
if (results === 0) {
|
if (results === 0) {
|
||||||
let noResults = document.querySelector('.no-results') as HTMLDivElement;
|
let noResults = document.querySelector(".no-results") as HTMLDivElement;
|
||||||
if (noResults) {
|
if (noResults) {
|
||||||
noResults.style.display = 'block';
|
noResults.style.display = "block";
|
||||||
noResults.innerHTML = 'No results found';
|
noResults.innerHTML = "No results found";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let noResults = document.querySelector('.no-results') as HTMLDivElement;
|
let noResults = document.querySelector(".no-results") as HTMLDivElement;
|
||||||
if (noResults) {
|
if (noResults) {
|
||||||
noResults.style.display = 'none';
|
noResults.style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,11 @@ type MarketplaceItem = {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
.marketplace-item-image {
|
.marketplace-item-image {
|
||||||
width: 64px;
|
width: 64px;
|
||||||
|
|
@ -79,6 +84,10 @@ type MarketplaceItem = {
|
||||||
.marketplace-item-desc {
|
.marketplace-item-desc {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
height: 40px;
|
||||||
}
|
}
|
||||||
.marketplace-btn {
|
.marketplace-btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
|
|
@ -221,23 +221,23 @@ export function getStaticPaths() {
|
||||||
|
|
||||||
function setupCustomizationSettings() {
|
function setupCustomizationSettings() {
|
||||||
let store = window.idb.transaction("InstalledExtensions", "readonly").objectStore("InstalledExtensions");
|
let store = window.idb.transaction("InstalledExtensions", "readonly").objectStore("InstalledExtensions");
|
||||||
store.getAll().onsuccess = (event) => {
|
store.getAll().onsuccess = (event) => {
|
||||||
const result = event.target.result;
|
const result = event.target.result;
|
||||||
if (result) {
|
if (result) {
|
||||||
result.forEach((extension) => {
|
result.forEach((extension) => {
|
||||||
if (extension.type === "theme" && extension.themeName) {
|
if (extension.type === "theme" && extension.themeName) {
|
||||||
// Create a dropdown item for the theme
|
// Create a dropdown item for the theme
|
||||||
addThemeToDropdown(extension);
|
addThemeToDropdown(extension);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
applySavedLocalStorage("alu__selectedTheme", "dropdown__selected-theme");
|
applySavedLocalStorage("alu__selectedTheme", "dropdown__selected-theme");
|
||||||
applySavedLocalStorage("alu__selectedLanguage", "dropdown__selected-language");
|
applySavedLocalStorage("alu__selectedLanguage", "dropdown__selected-language");
|
||||||
let themeDropdown = document.getElementById("dropdown__selected-theme-menu");
|
let themeDropdown = document.getElementById("dropdown__selected-theme-menu");
|
||||||
let languageDropdown = document.getElementById("dropdown__selected-language-menu");
|
let languageDropdown = document.getElementById("dropdown__selected-language-menu");
|
||||||
applyDropdownEventListeners(themeDropdown, "dropdown__selected-theme", "alu__selectedTheme", changeTheme);
|
applyDropdownEventListeners(themeDropdown, "dropdown__selected-theme", "alu__selectedTheme", changeTheme);
|
||||||
applyDropdownEventListeners(languageDropdown, "dropdown__selected-language", "alu__selectedLanguage", navigateToNewLangaugePage);
|
applyDropdownEventListeners(languageDropdown, "dropdown__selected-language", "alu__selectedLanguage", navigateToNewLangaugePage);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupCloakingSettings() {
|
function setupCloakingSettings() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue