Skip to content

Commit

Permalink
Merge pull request #42 from yakisova41/fix-grease
Browse files Browse the repository at this point in the history
Fix grease
  • Loading branch information
yakisova41 authored Dec 26, 2024
2 parents f03d206 + b53d123 commit 7cd9d4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 8 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down Expand Up @@ -103,7 +106,7 @@ function headFound(
}
}, 100);

styleInject(head);
styleInject(head, env);
}

function main() {
Expand Down
15 changes: 14 additions & 1 deletion src/methods/styleInject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down Expand Up @@ -50,13 +57,19 @@ 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;
}
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);
}

0 comments on commit 7cd9d4c

Please sign in to comment.