diff --git a/websites/Z/ZenMarket/metadata.json b/websites/Z/ZenMarket/metadata.json new file mode 100644 index 000000000000..b2a7ec4528d8 --- /dev/null +++ b/websites/Z/ZenMarket/metadata.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.10", + "author": { + "id": "82662823523516416", + "name": "maroxy" + }, + "service": "ZenMarket", + "description": { + "en": "Where to buy products from Japan? Want to buy from Japanese online stores and ship to your country? ZenMarket is the best Japan proxy shopping service for you!" + }, + "url": "zenmarket.jp", + "matches": [ + "*://zenmarket.jp/*" + ], + "version": "1.0.0", + "logo": "https://i.ibb.co/YWQTYzh/cy0lojzy.png", + "thumbnail": "https://i.ibb.co/vHCN9Rf/600x200.jpg", + "color": "#42749A", + "category": "other", + "tags": [ + "store", + "shopping", + "proxy" + ] +} \ No newline at end of file diff --git a/websites/Z/ZenMarket/presence.ts b/websites/Z/ZenMarket/presence.ts new file mode 100644 index 000000000000..734a7e3dcb55 --- /dev/null +++ b/websites/Z/ZenMarket/presence.ts @@ -0,0 +1,267 @@ +const presence = new Presence({ + clientId: "971483473024004157", + }), + browsingTimestamp = Math.floor(Date.now() / 1000); + +const enum Assets { + Logo = "https://i.ibb.co/YWQTYzh/cy0lojzy.png", +} + +presence.on("UpdateData", async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + details: "Browsing ZenMarket", + }, + { pathname, search, href } = document.location, + path = pathname.replace( + `/${document.querySelector("html").getAttribute("lang")}`, + "" + ); + + // Profile + + if (path === "/profile/" || path === "/profile/default.aspx") { + const warehouseTable: HTMLTableElement = document.querySelector( + "#productsBought > div:nth-child(1) > table" + ), + cartTable: HTMLTableElement = document.querySelector(".shop-stripped"), + warehouseItems = warehouseTable ? warehouseTable.rows.length : 0, + cartItems = cartTable ? cartTable.rows.length - 1 : 0; + + presenceData.details = "Viewing Account"; + presenceData.state = `${ + warehouseItems > 1 || warehouseItems === 0 + ? `${warehouseItems} items` + : `${warehouseItems} item` + } in warehouse || ${ + cartItems > 1 || cartItems === 0 + ? `${cartItems} items` + : `${cartItems} item` + } in cart`; + } + + if (path === "/profile/messages.aspx" || path === "/profile/support.aspx") + presenceData.details = "Viewing Messages"; + + if (path === "/profile/actions.aspx") + presenceData.details = "Looking at Events"; + + if (path === "/profile/watchlist.aspx") { + if ( + (search.includes("tab=auctions") && !search.includes("history")) || + !search + ) { + const products = document.querySelector( + "#auctions > div:nth-child(2) > .col-md-12" + ), + watchCount = products ? products.children.length - 1 : 0; + + presenceData.details = "Looking at watched auction items"; + presenceData.state = `${ + watchCount > 1 || watchCount === 0 + ? `${watchCount} items` + : `${watchCount} item` + } on the watchlist`; + } else if (search.includes("tab=auctions") && search.includes("history")) + presenceData.details = "Viewing history of watched auction items"; + else if (search.includes("tab=products")) { + const products = document.querySelector( + "#products > div:nth-child(2) > .col-md-12" + ), + watchCount = products ? products.children.length : 0; + + presenceData.details = "Looking at watched items"; + presenceData.state = `${ + watchCount > 1 || watchCount === 0 + ? `${watchCount} items` + : `${watchCount} item` + } on the watchlist`; + } else if (search.includes("tab=sellers")) + presenceData.details = "Viewing watched sellers"; + else if (search.includes("tab=recent")) + presenceData.details = "Looking at recently viewed items"; + } + + if (path === "/profile/parcel.aspx") presenceData.details = "Viewing parcels"; + + if (path === "/profile/payments.aspx") + presenceData.details = "Viewing transactions"; + + if (path === "/profile/levels.aspx") { + presenceData.details = "Checking current level"; + presenceData.state = `Current Level: ${ + document.querySelector("#lblCurrentTier").textContent + }`; + } + + if (path === "/profile/settings.aspx") + presenceData.details = "Viewing settings"; + + // Product view + + if (path === "/auction.aspx" && search.includes("itemCode")) { + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPriceY").textContent + } || Bids: ${document.querySelector("#bidNum").textContent} || Condition: ${ + document.querySelector("#lblItemStatus").textContent + } || Seller: ${document.querySelector("#seller").textContent}`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on Yahoo Auctions", + url: document.querySelector("#productPage").getAttribute("href"), + }, + ]; + } + + if (path === "/yshoppingproduct.aspx") { + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPrice").textContent + } || Condition: ${ + document.querySelector("#lblItemCondition").textContent + } || Seller: ${document.querySelector("#seller").textContent}`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on Yahoo Shopping", + url: document.querySelector("#productPage").getAttribute("href"), + }, + ]; + } + + if (path === "/mercariproduct.aspx") { + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPrice").textContent + } || Seller: ${document.querySelector("#seller").textContent}`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on Mercari", + url: document.querySelector("#productPage").getAttribute("href"), + }, + ]; + } + + if (path === "/rakumaproduct.aspx") { + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPrice").textContent + } || Seller: ${document.querySelector("#seller").textContent}`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on Rakuma", + url: document.querySelector("#productPage").getAttribute("href"), + }, + ]; + } + + if (path === "/rakutenproduct.aspx") { + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPrice").textContent + } || Seller: ${document.querySelector("#seller").textContent}`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on Rakuten", + url: document.querySelector("#productPage").getAttribute("href"), + }, + ]; + } + + if (path === "/amazonproduct.aspx") { + const condition: HTMLSpanElement = + document.querySelector("#lblConditionName"); + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPrice").textContent + } ${condition ? `|| Condition: ${condition.textContent}` : ""}`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on Amazon", + url: document.querySelector("#productPage").getAttribute("href"), + }, + ]; + } + + if (path === "/othershopproduct.aspx") { + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPrice").textContent + }`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on Original page", + url: document.querySelector("#productPage").getAttribute("href"), + }, + ]; + } + + if ( + path.includes("/s/") && + path.split("/").length === 4 && + document.querySelector("#itemTitle") + ) { + presenceData.details = `Looking at ${ + document.querySelector("#itemTitle").textContent + }`; + presenceData.state = `Price: ${ + document.querySelector("#lblPrice").textContent + } || Seller: ${document.querySelector("#aSeller").textContent}`; + presenceData.buttons = [ + { + label: "View on ZenMarket", + url: href, + }, + { + label: "View on ZenPlus", + url: document.querySelector("#itemUrl").getAttribute("href"), + }, + ]; + } + + if (presenceData.details) presence.setActivity(presenceData); + else presence.setActivity(); +});