// ==UserScript== // @name Shopee shopping cart display liked products // @name:zh-Han 蝦皮購物車顯示喜愛的商品 // @name:zh-TW 蝦皮購物車顯示喜愛的商品 // @name:zh-CN 虾皮购物车显示喜爱的商品 // @description Products that have been liked are displayed below the Shopee shopping cart. // @description:zh-Han 在蝦皮購物車下方顯示已按過喜歡的商品。 // @description:zh-TW 在蝦皮購物車下方顯示已按過喜歡的商品。 // @description:zh-CN 在虾皮购物车下方显示已按过喜欢的商品。 // @copyright 2024, HrJasn (https://greasyfork.org/zh-TW/users/142344-jasn-hr) // @license MIT // @icon https://www.google.com/s2/favicons?domain=shopee.tw // @homepageURL https://greasyfork.org/zh-TW/users/142344-jasn-hr // @supportURL https://greasyfork.org/zh-TW/users/142344-jasn-hr // @version 1.1 // @namespace https://greasyfork.org/zh-TW/users/142344-jasn-hr // @grant none // @match http*://shopee.tw // @match http*://shopee.tw/* // @downloadURL none // ==/UserScript== (() => { window.addEventListener('load',() => { let observer; observer = new MutationObserver( (mutations) => { mutations.forEach((adNds)=>{ adNds.addedNodes.forEach(async (adNde)=>{ if( (adNde) && (adNde.classList) && (adNde.classList.contains("shopee-header-section")) ){ console.log(adNde); let userLang = navigator.userLanguage || navigator.language || navigator.browserLanguage || navigator.systemLanguage; let userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; let liked_count = await fetch("https://shopee.tw/api/v4/pages/get_like_count", { "method": "GET" }).then((response) => { return response.json(); }).then((json) => { return json; }); let LikedItemsMaxCount = liked_count.data.total_count || liked_count.data.distribution.product_liked_count || 20; let liked_items = await fetch("https://shopee.tw/api/v4/pages/get_liked_items?category_ids=&cursor=0&keyword=&limit=" + LikedItemsMaxCount.toString() + "&offset=0&status=0", { "method": "GET", "headers": { "x-api-source": "rn", "x-shopee-language": userLang, "x-shopee-client-timezone": userTimezone, "user-agent": "Android app Shopee appver=32511 app_type=1 platform=native_android os_ver=30 Cronet/102.0.5005.61", "accept-encoding": "gzip, deflate, br" } }).then((response) => { return response.json(); }).then((json) => { return json; }); console.log(liked_items) for (let lin = 0; lin < liked_items.data.items.length; lin++) { let lio = liked_items.data.items[lin]; let NewDiv = await AddLikedItem(lio); console.log(NewDiv); }; async function AddLikedItem(likeitemJson){ let itemname = likeitemJson.name; let contenthref = "/" + itemname + "-i." + likeitemJson.shopid + "." + likeitemJson.itemid; let imgid = likeitemJson.image; let itemprice = likeitemJson.price / 100000; const liketitle = [...document.querySelectorAll('div.shopee-header-section')].find((e)=>{return e.innerText.match(/喜歡|like/)}); const likelist = liketitle.nextSibling; let NewDiv = likelist.insertBefore(document.createElement("div"), likelist.firstChild); NewDiv.classList.add("N_YeYe"); NewDiv.style.transition = 'all 0.2s'; NewDiv.insertAdjacentHTML('afterbegin', `