Skip to content

Commit 037ee45

Browse files
authored
Use aria-label for Preferences selector (#2181)
* Use aria-label for Preferences selector instead of fragile selector * Remove note about fragile selector * Remove unused "style" code
1 parent fded6ae commit 037ee45

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

source/browser.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ async function openHiddenPreferences(): Promise<boolean> {
222222
if (!isPreferencesOpen()) {
223223
document.documentElement.classList.add('hide-preferences-window');
224224

225-
const style = document.createElement('style');
226-
// Hide both the backdrop and the preferences dialog
227-
style.textContent = `${selectors.preferencesSelector} ._3ixn, ${selectors.preferencesSelector} ._59s7 { opacity: 0 !important }`;
228-
document.body.append(style);
229-
230225
await openPreferences();
231226

232227
return true;
@@ -661,7 +656,7 @@ async function openPreferences(): Promise<void> {
661656
}
662657

663658
function isPreferencesOpen(): boolean {
664-
return Boolean(document.querySelector<HTMLElement>('[aria-label=Preferences]'));
659+
return Boolean(document.querySelector<HTMLElement>(selectors.preferencesSelector));
665660
}
666661

667662
async function closePreferences(): Promise<void> {

source/browser/selectors.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export default {
1717
userMenuNewSidebar: '[role=navigation] > div > div:nth-child(2) > div > div > div:nth-child(1) [role=button]',
1818
viewsMenu: '.x9f619.x1n2onr6.x1ja2u2z.x78zum5.xdt5ytf.x2lah0s.x193iq5w.xdj266r',
1919
selectedConversation: '[role=navigation] [role=grid] [role=row] [role=gridcell] [role=link][aria-current=page]',
20-
// ! Very fragile selector (most likely cause of hidden dialog issue)
21-
preferencesSelector: 'div[role=dialog][class="x1n2onr6 x1ja2u2z x1afcbsf x78zum5 xdt5ytf x1a2a7pz x6ikm8r x10wlt62 x71s49j x1jx94hy x1g2kw80 xxadwq3 x16n5opg x3hh19s xl7ujzl x1kl8bxo xhkep3z xb3b7hn xwhkkir xeb55yp x17omtbh"]',
20+
preferencesSelector: '[aria-label=Preferences]',
2221
// TODO: Fix this selector for new design
2322
messengerSoundsSelector: '._374d ._6bkz',
2423
conversationMenuSelectorNewDesign: '[role=menu]',

0 commit comments

Comments
 (0)