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

Auto expand fails in other languages than English #35

Closed
Lucki opened this issue Jul 9, 2023 · 3 comments
Closed

Auto expand fails in other languages than English #35

Lucki opened this issue Jul 9, 2023 · 3 comments

Comments

@Lucki
Copy link

Lucki commented Jul 9, 2023

The current implementation fails to find any expandable nodes if the language isn't English:

clickableImages = document.querySelectorAll('[aria-label="Expand here"]');

E.g. German needs:

- clickableImages = document.querySelectorAll('[aria-label="Expand here"]'); 
+ clickableImages = document.querySelectorAll('[aria-label="hier erweitern"]');

However, this seems like a really fragile way to do this.

@Lucki
Copy link
Author

Lucki commented Jul 9, 2023

I've seen you comments under the various keyboard navigation scripts and those have the same problem:

- const buttonText = event.code === nextPageKey ? "Next" : "Prev";
+ const buttonText = event.code === nextPageKey ? "Weiter" : "Zurück";

Comments are even worse with the singular state.

        case openCommentsKey:
            if (event.shiftKey) {
+                 try {
                    window.open(
-                     currentEntry.querySelector("a.btn[title$='Comments']").href,
+                         currentEntry.querySelector("a.btn[title$='Kommentar']").href,
                    );
+                 } catch (error) {
+                     window.open(
+                         currentEntry.querySelector("a.btn[title$='Kommentare']").href,
+                     );
+                 }
            } else {
+                 try {
-                     currentEntry.querySelector("a.btn[title$='Comments']").href,
+                     currentEntry.querySelector("a.btn[title$='Kommentar']").click();
+                 } catch (error) {
+                     currentEntry.querySelector("a.btn[title$='Kommentare']").click();
+                 }
            }
            break;

There has to be a better way.

@howdy-tsc
Copy link
Owner

Thank you for the reports and thank you for chiming in. Right now, Manipulating the DOM objects are limited and we are using what is being given to us with lemmy-ui. Im an amateur and doing this with my limited know how and learning a lot! If anyone has a better idea than me please help out. I admittedly made the function quickly with what seemed obvious. Perhaps there is something I am overlooking to make this work without the literally query all selector being required for functionality like this.

We are doing a code clean up right now which will give me some time to pause and revaluate some functions as the script is going to look vastly different on 0.2

Thank you.

@howdy-tsc
Copy link
Owner

@csm10495 implemented a fix that looks for the classname versus the language dynamic text of the expand link. Should fix it.Thank you @csm10495!!! It's in as of 0.2.0.1

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

No branches or pull requests

2 participants