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

[FireMonkey] "Tab Scripts & CSS" sometimes does not show active scripts if url contains hash #576

Closed
Sanian-Creations opened this issue Jul 16, 2023 · 2 comments

Comments

@Sanian-Creations
Copy link

Issue

Here's a table of different match patterns, whether the script is active on the page, and whether it is listed under "Tab Scripts & CSS" in the Toolbar Icon Pop-up.

http://example.com/ http://example.com/#whatever
@match http://example.com/ active, listed active, not listed (!)
@match http://example.com/#whatever not active, not listed not active, listed (!)
@match http://example.com/* active, listed active, listed

Obviously, whether a script is active and listed in the pop-up menu should always be the same.

I believe that all scripts run on the correct pages, just that the "Tab Scripts & CSS" list is wrong. You might argue that for the case with both a hash in the match and in the url, the script should be active even though it currently isn't, but I'm quite certain that hashes are not a part of the Match Pattern spec, and so match patterns with a hash should never work.

How to reproduce

Add this style to FireMonkey, and then try out the combinations listed in the table above

/*
==UserCSS==
@name             example
@match            http://example.com/
==/UserCSS==
*/

* { color: red; }
  • If the script is active the text on the page should be red.
  • If the script is listed you should see a [1] over the Toolbar Icon. (or open the pop-up to make sure if you have other active scripts)

Cause and solution

It seems that there is a discrepancy between how scripts/styles are listed under "Tab Scripts & CSS" and how it is actually decided whether a script/style should run on a page.

  • To decide if a script should run, the hash is ignored, and then compared against the match.
  • To decide if a script should show under "Tab Scripts & CSS", the hash is NOT ignored, and then compared against the match. This is the problem, and should be made to ignore hashes also.
@erosman
Copy link
Owner

erosman commented Jul 16, 2023

The script injection and the popup display are completely difference processes:

  • Script injection is done via Firefox API which follows Match Patterns
  • Matching in Popup display is done manually by FireMonkey, using Regular Expression to match scripts to the Tab URL

The popup display process should remove the hash i.e.

const urls = [...new Set(frames.map(this.cleanUrl).filter(this.supported))];

support/content/match.js

Lines 37 to 39 in 599da96

static cleanUrl(url) {
return (url.url || url).replace(/#.*/, '').replace(/(:\/\/[^:/]+):\d+/, '$1');
}

I will check if there is an oversight.

@erosman
Copy link
Owner

erosman commented Jul 17, 2023

Found the reason. Fixed for v2.72

@erosman erosman added the done ✓ Completed label Jul 17, 2023
@erosman erosman closed this as completed Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants