From e620cc0551080dc96bb17a9df89699da6ba23fb7 Mon Sep 17 00:00:00 2001 From: yakisova41 Date: Fri, 27 Dec 2024 03:59:57 +0900 Subject: [PATCH 1/2] HotFix grease support --- src/main.ts | 13 ++++++++----- src/methods/styleInject.ts | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 76dd38f..c747ad0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -29,11 +29,14 @@ function envChecker() { if (GM_info.scriptHandler === "Userscripts") { return "userscript_ios"; } - if (GM_info.userAgentData.platform === "Windows") { - return "userscript_windows"; - } else { - return "userscript_not_windows"; + + if (typeof GM_info.userAgentData !== "undefined") { + if (GM_info.userAgentData.platform === "Windows") { + return "userscript_windows"; + } } + + return "userscript_not_windows"; } else { return "extension"; } @@ -103,7 +106,7 @@ function headFound( } }, 100); - styleInject(head); + styleInject(head, env); } function main() { diff --git a/src/methods/styleInject.ts b/src/methods/styleInject.ts index f490e05..fade4ae 100644 --- a/src/methods/styleInject.ts +++ b/src/methods/styleInject.ts @@ -3,7 +3,14 @@ import { colors, paths } from "../values"; /** * Add style to head */ -export function styleInject(head: Element) { +export function styleInject( + head: Element, + env: + | "userscript_ios" + | "userscript_windows" + | "userscript_not_windows" + | "extension" +) { const style = document.createElement("style"); const verifiedSelector = `a[href="/i/verified-choose"] > div > div > svg > g > path`; @@ -50,6 +57,9 @@ export function styleInject(head: Element) { d:path("${paths.oldHomePath}"); } + ${ + env === "extension" || env === "userscript_windows" + ? ` a[data-testid="SideNav_NewTweet_Button"], button[data-testid="tweetButtonInline"], button[data-testid="tweetButtonInline"], button[data-testid="tweetButton"] { background-color: var(--x-to-twitter-theme)!important; } @@ -57,6 +67,9 @@ export function styleInject(head: Element) { a[data-testid="SideNav_NewTweet_Button"] div[dir="ltr"], a[data-testid="SideNav_NewTweet_Button"] > div[dir="ltr"] > svg, button[data-testid="tweetButtonInline"] div[dir="ltr"], button[data-testid="tweetButtonInline"] div[dir="ltr"], button[data-testid="tweetButton"] div[dir="ltr"] { color: rgb(255, 255, 255)!important; } + ` + : "" + } `; head.appendChild(style); } From b53d123e4f7d2d5e8c281f9600cabf0b2d8569c0 Mon Sep 17 00:00:00 2001 From: yakisova41 Date: Fri, 27 Dec 2024 04:00:16 +0900 Subject: [PATCH 2/2] v3.0.1 --- extension/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/manifest.json b/extension/manifest.json index 8f61054..19cbda0 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_Name__", "short_name": "xToTwitter", - "version": "3.0.0", + "version": "3.0.1", "manifest_version": 3, "description": "__MSG_Description__", "default_locale": "en",