Skip to content

Commit 72526be

Browse files
committed
fix: disable voting for firefox
1 parent 6a27efd commit 72526be

9 files changed

Lines changed: 185 additions & 3 deletions

File tree

.changeset/better-teams-bet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"amgiflol": patch
3+
---
4+
5+
disable voting for firefox for time being

src/app.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// <srcDir>/app.config.ts
22
import { googleAnalytics4 } from "@wxt-dev/analytics/providers/google-analytics-4";
3+
import pkg from "../package.json";
34

45
export default defineAppConfig({
56
analytics: {
@@ -20,4 +21,5 @@ export default defineAppConfig({
2021
init: () => ({}),
2122
}),
2223
},
24+
version: pkg.version.toString(),
2325
});

src/app.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,10 @@ declare global {
176176
}
177177
}
178178

179+
declare module "wxt/utils/define-app-config" {
180+
export interface WxtAppConfig {
181+
version: string;
182+
}
183+
}
184+
179185
export {};

src/lib/Main.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
5656
:global(html:has(main.active)) {
5757
pointer-events: none;
58-
/* font-size: 16px !important; */
58+
font-size: 16px !important;
5959
6060
:global(body) {
6161
position: fixed;

src/lib/modules/EventsManager/index.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
createMessageHandler,
55
sendMessage,
66
} from "@/lib/core/MessageBus";
7+
// import { documentAttachment } from "@/lib/store/CssVariableBlocker.svelte";
78
import { MetaDataStore, UIStore } from "@/lib/store/index.svelte";
89
import { onMount } from "svelte";
910
@@ -112,6 +113,7 @@
112113
});
113114
</script>
114115

116+
<!-- {@attach documentAttachment()} -->
115117
<svelte:document
116118
onmousemove={handleMouseMove}
117119
onkeydown={handleKeyDown}

src/lib/modules/ExtenstionSettings/App.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { useAppConfig } from "#imports";
23
import {
34
createMessageHandler,
45
sendMessage,
@@ -7,6 +8,8 @@
78
import { browser } from "wxt/browser";
89
import "./app.css";
910
11+
const appConfig = useAppConfig();
12+
1013
let isLoading = $state(false);
1114
let errorMessage = $state("");
1215
let successMessage = $state("");
@@ -129,5 +132,6 @@
129132
{successMessage}
130133
</div>
131134
{/if}
135+
<footer class="text-end">v{appConfig.version}</footer>
132136
</div>
133137
</main>

src/lib/modules/Toolbar/ToolbarSettings.svelte

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<script lang="ts">
22
import Switch from "@/lib/components/Switch.svelte";
3-
import { createMessageHandler } from "@/lib/core/MessageBus";
43
import { UIStore } from "@/lib/store/index.svelte";
54
import { Cog } from "@lucide/svelte";
65
import { DropdownMenu } from "bits-ui";
76
import { fly } from "svelte/transition";
87
import UpvoteAction from "./UpvoteAction.svelte";
98
109
const uiStore = getContext<UIStore>("uiStore");
10+
// https://github.com/sm17p/amgiflol/issues/5
11+
const disableForFirefox = import.meta.env.FIREFOX;
1112
</script>
1213

1314
<!-- class="rounded-2xl bg-background-alt flex h-10 items-center gap-1" -->
@@ -52,6 +53,7 @@
5253
bind:checked={uiStore
5354
.toolbar
5455
.featureVotingVisible}
56+
disabled={disableForFirefox}
5557
labelText="Feature Voting"
5658
/>
5759
</span>
@@ -72,6 +74,7 @@
7274
class="min-w-[250px] flex justify-between items-center gap-3"
7375
>
7476
<UpvoteAction
77+
disabled={disableForFirefox}
7578
key="auto-hide-toolbar"
7679
label="Auto-Hide Toolbar"
7780
/>
@@ -86,6 +89,7 @@
8689
class="min-w-[250px] flex justify-between items-center gap-3"
8790
>
8891
<UpvoteAction
92+
disabled={disableForFirefox}
8993
key="auto-move-toolbar"
9094
label="Auto-Move Toolbar"
9195
/>
@@ -100,6 +104,7 @@
100104
class="min-w-[250px] flex justify-between items-center gap-3"
101105
>
102106
<UpvoteAction
107+
disabled={disableForFirefox}
103108
key="auto-move-sidepanel"
104109
label="Auto-Move Sidepanel"
105110
/>
@@ -114,6 +119,7 @@
114119
class="min-w-[250px] flex justify-between items-center gap-3"
115120
>
116121
<UpvoteAction
122+
disabled={disableForFirefox}
117123
key="multiple-trackers"
118124
label="Multiple Trackers"
119125
/>
@@ -128,6 +134,7 @@
128134
class="min-w-[250px] flex justify-between items-center gap-3"
129135
>
130136
<UpvoteAction
137+
disabled={disableForFirefox}
131138
key="neighbour-distances"
132139
label="Neighbour Distances"
133140
/>
@@ -142,6 +149,7 @@
142149
class="min-w-[250px] flex justify-between items-center gap-3"
143150
>
144151
<UpvoteAction
152+
disabled={disableForFirefox}
145153
key="onscreeen-measurement-lines"
146154
label="Onscreen Measurement Lines"
147155
/>
@@ -156,6 +164,7 @@
156164
class="min-w-[250px] flex justify-between items-center gap-3"
157165
>
158166
<UpvoteAction
167+
disabled={disableForFirefox}
159168
key="parent-traversal"
160169
label="Parent Traversal"
161170
/>
@@ -170,6 +179,7 @@
170179
class="min-w-[250px] flex justify-between items-center gap-3"
171180
>
172181
<UpvoteAction
182+
disabled={disableForFirefox}
173183
key="sibling-traversal"
174184
label="Sibling Traversal"
175185
/>
@@ -184,6 +194,7 @@
184194
class="min-w-[250px] flex justify-between items-center gap-3"
185195
>
186196
<UpvoteAction
197+
disabled={disableForFirefox}
187198
key="viewport-resizer"
188199
label="Viewport Resizer"
189200
/>
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
// oxlint-disable no-empty-file
2+
// import { Attachment } from "svelte/attachments";
3+
// import { SvelteSet } from "svelte/reactivity";
4+
5+
// export let cssVariables = new SvelteSet();
6+
7+
// export function documentAttachment(): Attachment {
8+
// let observer = new MutationObserver((mutations) => {
9+
// let shouldUpdate = false;
10+
11+
// mutations.forEach((mutation) => {
12+
// if (mutation.type === "childList") {
13+
// // Check if any added nodes are style/link elements
14+
// mutation.addedNodes.forEach((node) => {
15+
// if (node.nodeType === Node.ELEMENT_NODE) {
16+
// const tagName = node.tagName.toLowerCase();
17+
// if (
18+
// tagName === "style" ||
19+
// (tagName === "link" &&
20+
// node.rel === "stylesheet")
21+
// ) {
22+
// shouldUpdate = true;
23+
// }
24+
// }
25+
// });
26+
27+
// // Check if any removed nodes were style/link elements
28+
// mutation.removedNodes.forEach((node) => {
29+
// if (node.nodeType === Node.ELEMENT_NODE) {
30+
// const tagName = node.tagName.toLowerCase();
31+
// if (
32+
// tagName === "style" ||
33+
// (tagName === "link" &&
34+
// node.rel === "stylesheet")
35+
// ) {
36+
// shouldUpdate = true;
37+
// }
38+
// }
39+
// });
40+
// }
41+
42+
// // Watch for attribute changes on style/link elements
43+
// if (mutation.type === "attributes" && mutation.target) {
44+
// const tagName = mutation.target.tagName.toLowerCase();
45+
// if (
46+
// tagName === "style" ||
47+
// (tagName === "link" &&
48+
// mutation.target.rel === "stylesheet")
49+
// ) {
50+
// shouldUpdate = true;
51+
// }
52+
// }
53+
// });
54+
55+
// // if (shouldUpdate) {
56+
// // console.log(
57+
// // "Stylesheet changes detected, updating CSS variable blocks...",
58+
// // );
59+
// // // Small delay to ensure stylesheets are fully loaded
60+
// // setTimeout(() => {
61+
// // this.blockDocumentCSSVariables();
62+
// // }, 100);
63+
// // }
64+
// });
65+
// return (_element: Element) => {
66+
// const targetSelectors = [":root", "html", "html:root", "*"];
67+
68+
// try {
69+
// // Iterate through all stylesheets
70+
// for (const styleSheet of document.styleSheets) {
71+
// try {
72+
// console.log("🚀 ~ return ~ styleSheet:", styleSheet);
73+
// // Skip stylesheets we can't access (CORS)
74+
// if (!styleSheet.cssRules) continue;
75+
76+
// // Check each rule in the stylesheet
77+
// for (const rule of styleSheet.cssRules) {
78+
// if (rule instanceof CSSStyleRule) {
79+
// // Check if this rule targets a top-level selector
80+
// const selectorText = rule.selectorText
81+
// .toLowerCase();
82+
// const isTargetSelector = true ||
83+
// targetSelectors.some(
84+
// selector => selectorText.includes(selector),
85+
// );
86+
87+
// if (isTargetSelector && rule.style) {
88+
// // Extract CSS custom properties from this rule
89+
// for (let i = 0; i < rule.style.length; i++) {
90+
// const property = rule.style[i];
91+
// if (property.startsWith("--")) {
92+
// cssVariables.add(property);
93+
// }
94+
// }
95+
// }
96+
// }
97+
// }
98+
// } catch (e) {
99+
// // Skip stylesheets that can't be accessed (cross-origin)
100+
// console.warn(
101+
// "Cannot access stylesheet:",
102+
// styleSheet.href,
103+
// e,
104+
// );
105+
// }
106+
// }
107+
// } catch (e) {
108+
// console.error("Error extracting CSS variables:", e);
109+
// }
110+
111+
// setupStyleSheetObserver(observer);
112+
113+
// $inspect(cssVariables);
114+
115+
// return () => {
116+
// observer.disconnect();
117+
// };
118+
// };
119+
// }
120+
121+
// // Target selectors that define global CSS variables
122+
123+
// const a = (document: Document) => {
124+
// let element = document.querySelector("amgif-lol");
125+
// let elementhead = document.querySelector("amgif-lol > head");
126+
// console.log(
127+
// "🚀 ~ <svelte:body{@attach ~ body:",
128+
// document,
129+
// document.styleSheets,
130+
// element,
131+
// elementhead,
132+
// );
133+
// };
134+
135+
// function setupStyleSheetObserver(observer: MutationObserver) {
136+
// // Watch for changes to the document head (new stylesheets)
137+
138+
// // Start observing
139+
// observer.observe(document.head, {
140+
// childList: true,
141+
// subtree: true,
142+
// attributes: true,
143+
// attributeFilter: ["href", "rel"],
144+
// });
145+
146+
// // Also observe the document element for dynamically added styles
147+
// observer.observe(document.documentElement, {
148+
// childList: true,
149+
// subtree: true,
150+
// attributes: false,
151+
// });
152+
// }

src/lib/store/TrackerState.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ export class TrackerState implements App.TrackerState {
8787
}
8888

8989
public toggleLock() {
90+
this.isLocked = !this.isLocked;
9091
analytics.track("toggle_inspector_lock", {
9192
value: this.isLocked.toString(),
9293
});
93-
this.isLocked = !this.isLocked;
9494
}
9595

9696
public updateTrackerPosition() {

0 commit comments

Comments
 (0)