Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix queried elements in document selector query search #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ajaayc
Copy link

@ajaayc ajaayc commented Jul 7, 2021

@bhattcodes I discovered your Chrome extension and tried it out myself. Unfortunately it seemed to break at this line in background.js:

 try {
            window.document.querySelector(".FbBiwc").click();
        } catch {
            console.log("ERROR");
        }

It looks like the Leave call button does not always have a class of "FbBiwc," and the class may have changed since you wrote this script and/or the class may change depending on region and/or how Chrome is configured. The querySelector function returns null and the ERROR message prints.

I made this adjustment to the querySelector function, replacing it with:

window.document.querySelector('[aria-label="Leave call"]').click();

I believe this change will be more robust because it instead relies on the label of the button, not the class. Hopefully the label will always be "Leave call."

@ajaayc
Copy link
Author

ajaayc commented Jul 7, 2021

My second commit c074815 makes a tweak to the feature of leaving the call when the number of attendees is lower than some threshold. The line

document.querySelector(".gV3Svc>span")

seemed to yield an error for me. I suspect that Google Meets has changed recently, causing the class id to be different. I replaced it with:

document.querySelector(".uGOf1d")

This fix assumes that the classID of that element won't change...this may or not be a valid assumption, but I looked through the div and there didn't seem to be a reliable way to get the number of attendees without relying on the classID--unlike the fix from the previous commit that looks at the button label.

@ajaayc ajaayc changed the title Make document selector query search by button label Make document selector query search by button label, Fix Num Attendees Feature Jul 7, 2021
@lordofthebrain
Copy link

Don't use:
window.document.querySelector('[aria-label="Leave call"]').click();
in other languages the aria-label has a different value.

Use this instead:
window.document.querySelector("button.QQrMi").click();

@ajaayc
Copy link
Author

ajaayc commented Jul 13, 2021

Thank you, @lordofthebrain. I did not know that aria-label has a different value depending on the language. I made the update and replaced the aria-label reference line to window.document.querySelector("button.QQrMi").click(). I also packed the end meeting procedures into a function called endCall() to eliminate duplicated code.

I verified that with my changes, all 3 features still work and that the Chrome extension is still functional when I load it locally into the browser following Step 2 of these instructions from Google Support.

@ajaayc ajaayc changed the title Make document selector query search by button label, Fix Num Attendees Feature Fix queried elements in document selector query search Jul 13, 2021
@lordofthebrain
Copy link

Thank you, @lordofthebrain. I did not know that aria-label has a different value depending on the language. I made the update and replaced the aria-label reference line to window.document.querySelector("button.QQrMi").click(). I also packed the end meeting procedures into a function called endCall() to eliminate duplicated code.

I verified that with my changes, all 3 features still work and that the Chrome extension is still functional when I load it locally into the browser following Step 2 of these instructions from Google Support.

Good work! For me, the extension also works again as it should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants