Last active
September 14, 2024 02:27
-
-
Save MeteorVE/ae5ef772218f2a6474847e12248e279a to your computer and use it in GitHub Desktop.
Painter for coloring sendou.ink build-card
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name sendou.ink-color-changer | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description change sendou.ink card color | |
| // @author MeteorV | |
| // @match https://sendou.ink/u* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=sendou.ink | |
| // @require https://openuserjs.org/src/libs/sizzle/GM_config.js | |
| // @grant GM_registerMenuCommand | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| window.addEventListener('load', function() { | |
| // after load | |
| update() | |
| }, false); | |
| var color_dict = {"color:yellow": "#fbffab", "color:blue":"#abeeff", "color:green":"#dcffa8", "color:red":"#fa7070", | |
| "color:grey":"#6e6f73", "color:purple":"#d9c1f5", "color:pink":"#fab4e8", "color:orange":"#fcbf79", | |
| "color:navy":"#72c1ff"} | |
| function update() { | |
| console.log("[Info]: Start to find"); | |
| var text_divs = document.getElementsByClassName("chakra-popover__body"); | |
| console.log(text_divs, "[Length]:",text_divs.length) | |
| if(text_divs==null){ | |
| console.log("[Info]: I can't find anything."); | |
| } | |
| for(var i=0; i<text_divs.length; i++){ | |
| if(text_divs[i].textContent.includes("color:")){ | |
| let target = text_divs[i].parentNode.parentNode.parentNode.parentNode.parentNode; | |
| let btn_group = text_divs[i].parentNode.parentNode.parentNode.querySelectorAll('button'); | |
| for(let i=0; i<btn_group.length; i++){ | |
| btn_group[i].style.color = "#000000"; | |
| } | |
| console.log("[Target's context]:", text_divs[i].textContent) | |
| for(const [key, value] of Object.entries(color_dict)){ | |
| if(text_divs[i].textContent.includes(key)){ | |
| target.style.backgroundColor = color_dict[key]; | |
| } | |
| }// end of for | |
| } | |
| if(text_divs[i].textContent.includes("color:#")){ | |
| let target = text_divs[i].parentNode.parentNode.parentNode.parentNode.parentNode; | |
| let btn_group = text_divs[i].parentNode.parentNode.parentNode.querySelectorAll('button'); | |
| for(let i=0; i<btn_group.length; i++){ | |
| btn_group[i].style.color = "#000000"; | |
| } | |
| let idx = text_divs[i].textContent.indexOf("color:#"); | |
| let color_text = text_divs[i].textContent.slice(idx+6, idx+13); | |
| target.style.backgroundColor = color_text; // e.g. #fbffab | |
| } | |
| }// end of for | |
| return | |
| } | |
| function color_rule(rule) { | |
| console.log("[Info]: Start to find rule img"); | |
| var imgs = document.getElementsByTagName("img"); | |
| console.log(imgs, "[Length]:",imgs.length) | |
| if(imgs==null){ | |
| console.log("[Info]: I can't find anything."); | |
| } | |
| var rule_dict = {"TW":"Mode (TW)", "SZ":"Mode (SZ)", "TC":"Mode (TC)", "RM":"Mode (RM)", "CB":"Mode (CB)"}; | |
| for(var i=0; i<imgs.length; i++){ | |
| if(imgs[i].alt == rule_dict[rule]){ | |
| let target = imgs[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; | |
| let btn_group = target.querySelectorAll('button'); | |
| for(let i=0; i<btn_group.length; i++){ | |
| btn_group[i].style.color = "#000000"; | |
| } | |
| target.style.backgroundColor = color_dict["color:yellow"]; | |
| } | |
| }// end of for | |
| return | |
| } | |
| function color_reset() { | |
| console.log("[Info]: Start to reset"); | |
| var text_divs = document.getElementsByClassName("chakra-popover__body"); | |
| console.log(text_divs, "[Length]:",text_divs.length) | |
| if(text_divs==null){ | |
| console.log("[Info]: I can't find anything."); | |
| } | |
| for(var i=0; i<text_divs.length; i++){ | |
| // var ldiv = text_divs[i]; | |
| if(text_divs[i].textContent.includes("color:")){ | |
| let target = text_divs[i].parentNode.parentNode.parentNode.parentNode.parentNode; | |
| let btn_group = text_divs[i].parentNode.parentNode.parentNode.querySelectorAll('button'); | |
| for(let i=0; i<btn_group.length; i++){ | |
| btn_group[i].style.color = "#1bb300"; | |
| } | |
| target.style.backgroundColor = null; | |
| } | |
| if(text_divs[i].textContent.includes("hidden:true")){ | |
| let target = text_divs[i].parentNode.parentNode.parentNode.parentNode.parentNode; | |
| target.style.display = ""; | |
| } | |
| }// end of for | |
| return | |
| } | |
| function remove() { | |
| console.log("[Info]: Start to hide something."); | |
| var text_divs = document.getElementsByClassName("chakra-popover__body"); | |
| console.log(text_divs, "[Length]:",text_divs.length) | |
| if(text_divs==null){ | |
| console.log("[Info]: I can't find anything."); | |
| } | |
| for(var i=0; i<text_divs.length; i++){ | |
| // var ldiv = text_divs[i]; | |
| if(text_divs[i].textContent.includes("hidden:true")){ | |
| let target = text_divs[i].parentNode.parentNode.parentNode.parentNode.parentNode; | |
| target.style.display = "none"; | |
| } | |
| }// end of for | |
| return | |
| } | |
| GM_registerMenuCommand("著色🎨🖌️!", update, "U"); | |
| GM_registerMenuCommand("隱藏特定組合🗑️", remove, "D"); | |
| GM_registerMenuCommand("高亮: 塗地💧", () => color_rule('TW')); | |
| GM_registerMenuCommand("高亮: 佔地🌊", () => color_rule("SZ")); | |
| GM_registerMenuCommand("高亮: 推塔🗼", () => color_rule("TC")); | |
| GM_registerMenuCommand("高亮: 運魚🐟", () => color_rule("RM")); | |
| GM_registerMenuCommand("高亮: 投蛤🦪", () => color_rule("CB")); | |
| GM_registerMenuCommand("還原初始狀態🔄", color_reset, "R"); | |
| // Emoji 參考 https://www.emojiall.com/zh-hant/categories/I | |
| // 顏色挑選器 https://www.google.com/search?q=online+color+picker | |
| })(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.