Skip to content

Commit 9434fe5

Browse files
authored
Update selector for chat view menu (#2182)
Using "role=navigation" is no longer unique enough to get the view menu.
1 parent 4e7e6f7 commit 9434fe5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

source/browser.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ async function withMenu(
4141

4242
async function isNewSidebar(): Promise<boolean> {
4343
// TODO: stopOnDomReady might not be needed
44-
await elementReady('[role=navigation] > div > div', {stopOnDomReady: false});
44+
await elementReady(selectors.leftSidebar, {stopOnDomReady: false});
4545

46-
const sidebars = document.querySelectorAll<HTMLElement>('[role=navigation] > div > div');
46+
const sidebars = document.querySelectorAll<HTMLElement>(selectors.leftSidebar);
4747

4848
return sidebars.length === 2;
4949
}
@@ -85,13 +85,11 @@ async function selectOtherListViews(itemNumber: number): Promise<void> {
8585

8686
if (newSidebar) {
8787
const items = document.querySelectorAll<HTMLElement>(
88-
`${selectors.viewsMenu} > span > a`,
88+
`${selectors.viewsMenu} span > a`,
8989
);
9090

9191
const selector = itemNumber <= items.length ? items[itemNumber - 1] : null;
9292

93-
console.log(selector);
94-
9593
if (selector) {
9694
selector.click();
9795
}

source/browser/selectors.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
leftSidebar: '[role="navigation"] > div > div', // ! Tray icon dependency
2+
leftSidebar: '[role="navigation"][class="x9f619 x1n2onr6 x1ja2u2z x78zum5 xdt5ytf x2lah0s x193iq5w xeuugli"] > div > div', // ! Tray icon dependency
33
chatsIcon: '[class="x9f619 x1n2onr6 x1ja2u2z x78zum5 xdt5ytf x2lah0s x193iq5w xdj266r"] a', // ! Tray icon dependency
44
conversationList: '[role=navigation] [role=grid] [class="x1n2onr6"]',
55
conversationSelector: '[role=main] [role=grid]',
@@ -15,7 +15,7 @@ export default {
1515
closePreferencesButton: 'div[role=dialog] > div > div > div:nth-child(2) > [role=button]',
1616
userMenu: '.qi72231t.o9w3sbdw.nu7423ey.tav9wjvu.flwp5yud.tghlliq5.gkg15gwv.s9ok87oh.s9ljgwtm.lxqftegz.bf1zulr9.frfouenu.bonavkto.djs4p424.r7bn319e.bdao358l.fsf7x5fv.tgm57n0e.jez8cy9q.s5oniofx.m8h3af8h.l7ghb35v.kjdc1dyq.kmwttqpk.dnr7xe2t.aeinzg81.srn514ro.oxkhqvkx.rl78xhln.nch0832m.om3e55n1.cr00lzj9.rn8ck1ys.s3jn8y49.g4tp4svg.o9erhkwx.dzqi5evh.hupbnkgi.hvb2xoa8.fxk3tzhb.jl2a5g8c.f14ij5to.l3ldwz01.icdlwmnq > .aglvbi8b.om3e55n1.i8zpp7h3.g4tp4svg',
1717
userMenuNewSidebar: '[role=navigation] > div > div:nth-child(2) > div > div > div:nth-child(1) [role=button]',
18-
viewsMenu: '.x9f619.x1n2onr6.x1ja2u2z.x78zum5.xdt5ytf.x2lah0s.x193iq5w.xurb0ha.x1sxyh0.xdj266r',
18+
viewsMenu: '.x9f619.x1n2onr6.x1ja2u2z.x78zum5.xdt5ytf.x2lah0s.x193iq5w.xdj266r',
1919
selectedConversation: '[role=navigation] [role=grid] [role=row] [role=gridcell] [role=link][aria-current]',
2020
// ! Very fragile selector (most likely cause of hidden dialog issue)
2121
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"]',

0 commit comments

Comments
 (0)