Skip to content

Commit

Permalink
HotFix grease support
Browse files Browse the repository at this point in the history
  • Loading branch information
yakisova41 committed Dec 26, 2024
1 parent f03d206 commit e620cc0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
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 e620cc0

Please sign in to comment.