SoraHjort / webcomic_reader

Webcomic Reader userscript at
https://openuserjs.org/scripts/anka-213/Webcomic_Reader
MIT License
10 stars 1 forks source link

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

Open SoraHjort opened 1 year ago

SoraHjort commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.