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", 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); }