From d753bee5e379666a5fb54e50495d41d5c3c19437 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Sat, 26 Nov 2022 13:43:15 +0700 Subject: [PATCH] aov: add apl2022 click script --- apps/ws-scrcpy/README.md | 1 + games/{Arena_of_Valor => aov}/.gitkeep | 0 games/{Arena_of_Valor => aov}/README.md | 0 games/aov/apl2022-clicker.js | 139 ++++++++++++++++++ .../AWC_AutoSpin.js => aov/awc_autospin.js} | 0 .../NotParadoxLauncher_Win_Proton.sh | 0 .../README.md | 0 .../Win_Proton_dowser_patch.sh | 0 games/{LoL => lol}/linux/README.md | 0 games/{LoL => lol}/linux/discord_rpc.sh | 0 games/{LoL => lol}/linux/garena_wrapper.sh | 0 games/{LoL => lol}/linux/sulaunchhelper2.sh | 0 games/{LoL => lol}/linux/syscall_check.sh | 0 userscripts/messenger-dynamic-sidebar.user.js | 67 +++++++++ 14 files changed, 207 insertions(+) rename games/{Arena_of_Valor => aov}/.gitkeep (100%) rename games/{Arena_of_Valor => aov}/README.md (100%) create mode 100644 games/aov/apl2022-clicker.js rename games/{Arena_of_Valor/AWC_AutoSpin.js => aov/awc_autospin.js} (100%) rename games/{Cities_Skylines => cities_skylines}/NotParadoxLauncher_Win_Proton.sh (100%) rename games/{Cities_Skylines => cities_skylines}/README.md (100%) rename games/{Cities_Skylines => cities_skylines}/Win_Proton_dowser_patch.sh (100%) rename games/{LoL => lol}/linux/README.md (100%) rename games/{LoL => lol}/linux/discord_rpc.sh (100%) rename games/{LoL => lol}/linux/garena_wrapper.sh (100%) rename games/{LoL => lol}/linux/sulaunchhelper2.sh (100%) rename games/{LoL => lol}/linux/syscall_check.sh (100%) create mode 100644 userscripts/messenger-dynamic-sidebar.user.js diff --git a/apps/ws-scrcpy/README.md b/apps/ws-scrcpy/README.md index 8bdab6f..9e3c03e 100644 --- a/apps/ws-scrcpy/README.md +++ b/apps/ws-scrcpy/README.md @@ -36,6 +36,7 @@ cd ~ git clone https://github.com/NetrisTV/ws-scrcpy cd ./ws-scrcpy npm install +cd .. curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/Apps/ws-scrcpy/ws-scrcpy-launcher.py chmod +x ws-scrcpy-launcher.py ``` diff --git a/games/Arena_of_Valor/.gitkeep b/games/aov/.gitkeep similarity index 100% rename from games/Arena_of_Valor/.gitkeep rename to games/aov/.gitkeep diff --git a/games/Arena_of_Valor/README.md b/games/aov/README.md similarity index 100% rename from games/Arena_of_Valor/README.md rename to games/aov/README.md diff --git a/games/aov/apl2022-clicker.js b/games/aov/apl2022-clicker.js new file mode 100644 index 0000000..623f849 --- /dev/null +++ b/games/aov/apl2022-clicker.js @@ -0,0 +1,139 @@ +if (!window.location.href.startsWith("https://apl2022.lienquan.garena.vn")) { + console.error("This script is for https://apl2022.lienquan.garena.vn only."); +} + +async function getCurrentUser() { + const rsp = await fetch('/graphql', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + operationName: "getUser", + query: ` + query getUser { + getUser { + id + name + icon + profile { + id + ...Profile + __typename + } + __typename + } + } + + fragment Profile on Profile { + tcid + clicks + totalClicks + dailyClicks + claimedGift + currentGift + receivedServerGift + subMissions + claimedDailyGift + date + item { + id + name + type + image + limitation + currentClaimed + __typename + } + sentWish + __typename + } + `, + variables: {}, + }), + }) + if (!rsp.ok) { + throw `Failed to get current user info` + } + return (await rsp.json()).data.getUser; +} + +async function postClick(amount) { + const rsp = await fetch('/graphql', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + operationName: "doDailyClick", + query: ` + mutation doDailyClick($clicks: Int!) { + dailyClick(clicks: $clicks) { + id + ...Profile + __typename + } + } + + fragment Profile on Profile { + tcid + clicks + totalClicks + dailyClicks + claimedGift + currentGift + receivedServerGift + subMissions + claimedDailyGift + date + item { + id + name + type + image + limitation + currentClaimed + __typename + } + sentWish + __typename + } + `, + variables: { + clicks: amount, + }, + }), + }) + if (!rsp.ok) { + throw `Failed to post click request with amount ${amount}` + } +} + +async function main() { + console.log("Fetching user information..."); + let user; + try { + user = await getCurrentUser(); + } catch(e) { + console.error(e); + return; + } + console.log(`Hello, ${user.name}!`); + console.log("Calculating remaining clicks needed..."); + const clicksNeeded = 1000 - user.profile.dailyClicks; + if (clicksNeeded == 0) { + console.warn("You've already clicked enough for a day :D"); + return; + } + console.log(`Clicks needed: ${clicksNeeded}`); + console.log("Sending click request..."); + try { + postClick(clicksNeeded); + } catch(e) { + console.error(e); + return; + } + console.log("Success! Please reload page to see the changes."); +} + +main() diff --git a/games/Arena_of_Valor/AWC_AutoSpin.js b/games/aov/awc_autospin.js similarity index 100% rename from games/Arena_of_Valor/AWC_AutoSpin.js rename to games/aov/awc_autospin.js diff --git a/games/Cities_Skylines/NotParadoxLauncher_Win_Proton.sh b/games/cities_skylines/NotParadoxLauncher_Win_Proton.sh similarity index 100% rename from games/Cities_Skylines/NotParadoxLauncher_Win_Proton.sh rename to games/cities_skylines/NotParadoxLauncher_Win_Proton.sh diff --git a/games/Cities_Skylines/README.md b/games/cities_skylines/README.md similarity index 100% rename from games/Cities_Skylines/README.md rename to games/cities_skylines/README.md diff --git a/games/Cities_Skylines/Win_Proton_dowser_patch.sh b/games/cities_skylines/Win_Proton_dowser_patch.sh similarity index 100% rename from games/Cities_Skylines/Win_Proton_dowser_patch.sh rename to games/cities_skylines/Win_Proton_dowser_patch.sh diff --git a/games/LoL/linux/README.md b/games/lol/linux/README.md similarity index 100% rename from games/LoL/linux/README.md rename to games/lol/linux/README.md diff --git a/games/LoL/linux/discord_rpc.sh b/games/lol/linux/discord_rpc.sh similarity index 100% rename from games/LoL/linux/discord_rpc.sh rename to games/lol/linux/discord_rpc.sh diff --git a/games/LoL/linux/garena_wrapper.sh b/games/lol/linux/garena_wrapper.sh similarity index 100% rename from games/LoL/linux/garena_wrapper.sh rename to games/lol/linux/garena_wrapper.sh diff --git a/games/LoL/linux/sulaunchhelper2.sh b/games/lol/linux/sulaunchhelper2.sh similarity index 100% rename from games/LoL/linux/sulaunchhelper2.sh rename to games/lol/linux/sulaunchhelper2.sh diff --git a/games/LoL/linux/syscall_check.sh b/games/lol/linux/syscall_check.sh similarity index 100% rename from games/LoL/linux/syscall_check.sh rename to games/lol/linux/syscall_check.sh diff --git a/userscripts/messenger-dynamic-sidebar.user.js b/userscripts/messenger-dynamic-sidebar.user.js new file mode 100644 index 0000000..4c21729 --- /dev/null +++ b/userscripts/messenger-dynamic-sidebar.user.js @@ -0,0 +1,67 @@ +// ==UserScript== +// @name Dynamic Sidebar +// @namespace tretrauit-dev +// @match *://www.messenger.com +// @icon https://genshin.hoyoverse.com/favicon.ico +// @grant none +// @version 1.0 +// @author tretrauit +// @description Dynamic Sidebar for Facebook Messenger (messenger.com) +// @homepageURL https://gitlab.com/tretrauit/scripts +// @supportURL https://gitlab.com/tretrauit/scripts/-/issues +// @downloadURL https://gitlab.com/tretrauit/scripts/-/raw/main/userscripts/messenger-dynamic-sidebar.user.js +// ==/UserScript== + +function injectCSS(css) { + const style = document.createElement('style'); + style.appendChild(document.createTextNode(css)); + document.head.appendChild(style); +} + +function findElement(tag, properties) { + const elements = document.querySelectorAll(tag); + elementLoop: + for (const element of elements) { + for (const [key, value] of Object.entries(properties)) { + if (element.getAttribute(key) != value) { + continue elementLoop; + } + } + return element; + } +} + +function getAncestor(element, level) { + for (let i = 0; i < level; i++) { + element = element.parentNode; + } + return element; +} + +console.log("Scanning class for components..."); +let searchBox = findElement("input", {"aria-autocomplete": "list"}); +if (searchBox != null) { + searchBox = getAncestor(searchBox, 7); +} +let textHeader = findElement("span", {"style": "line-height: 28px;"}); +let header; +if (textHeader != null) { + header = getAncestor(textHeader, 7); + textHeader = textHeader.childNodes[0]; +} +let unreadIndicator = findElement("span", {"data-visualcompletion": "ignore"}); +let actionBar = findElement("div", {"aria-expanded": "false"}); +if (actionBar != null) { + actionBar = actionBar.parentNode; +} +let chats = findElement("div", {"aria-label": "Chats"}); +if (chats != null) { + chats = chats.parentNode; +} + +console.log("Search box:", searchBox); +console.log("Header:", header); +console.log("Text header:", textHeader); +console.log("Unread message indicator:", unreadIndicator); +console.log("Action bar:", actionBar); +console.log("Chat tab:", chats); \ No newline at end of file