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

Known Issue with Chromium browsers: xpath last() #27

Open
SoraHjort opened this issue Feb 7, 2023 · 2 comments
Open

Known Issue with Chromium browsers: xpath last() #27

SoraHjort opened this issue Feb 7, 2023 · 2 comments

Comments

@SoraHjort
Copy link
Owner

Some of the sites use a multi if/else setup with the xpath capture. This normally works fine, however for who know show long it has not been working on chrome userscript extensions (TamperMonkey or ViolentMonkey). Yet this works fine with the Firefox versions of those extensions leading me to believe that it's an issue that google made to chromium.

What this causes is that, in the case of Next and Back, is that the console errors out and is unable to parse the capture rules for that navigation. Making the script to not cache pages.

I'm making this issue primarily for two reasons.

  1. To let people know that yet it is a known issue. And that it is recommended for those few sites to use the userscript with Firefox or forks of that browser.
  2. To see if anyone knows of the specific change to Chrome based browsers security to cause this. So that we can see about looking for a way around it.
@SoraHjort
Copy link
Owner Author

SoraHjort commented May 27, 2023

xpath issue seems to be related this pair of lines

    if(!isFirefox() && elem!=document && query.charAt(0)!='.')
        query = (query.charAt(0)=='/' ? '.' : './') + query;

removing the line seems to fix the issue, but I have no idea why it was put in in the first place. Was there an issue with non-firefox browsers at some point with userscripts?

All I can find is that these two lines were part of the initial commit by ameboide 11 years ago. Due to the length of time it has been since it was put in, it's more than likely it was to solve an issue that no longer exists. But I am unsure.

For the time being, I'll push a change to the fixes-and-additions dev branch that disables those two lines. They'll be simply commented out for the time being. Still there in the event we find out that they are still needed, it'll be on hand for quick reversion.

But this will fix various sites on chrome, such as oglaf, furaffinity, pasteldefender, and possibly others that did something like

next: ['(//a[contains(text(),"FORWARD")]|//img[contains(@src, "fore")]/..)[last()]'],

to handle multiple possible navigations captures in a single string.

SoraHjort added a commit that referenced this issue May 27, 2023
@SoraHjort
Copy link
Owner Author

May have found a better solution than removing the lines. As I've yet to find out the reason behind why the two lines exist, which may still be needed by some out of date browser(?), the better option would to change the isFirefox function to check for Gecko instead of Gecko/, since many browsers these days will have (KHTML, like Gecko) to bypass scripts trying to be restricted to specific browsers, and normally scripts just look for Gecko.

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

1 participant