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

[Feature] Higher/Lower Order (or Highlight/Grey Out) for the script (not) applying the current URL in SPA #2048

Open
cyfung1031 opened this issue Mar 12, 2024 · 5 comments

Comments

@cyfung1031
Copy link
Contributor

cyfung1031 commented Mar 12, 2024

Motivation

In YouTube, it is Single Page Application, so all of them have to set to @match https://www.youtube.com/* to ensure them can be executed after the SPA is switched to the desired page (url changed due to history state)

Motivation 1: Currently for such a UserJS used in SPA, it is not clear enough to let users know which page(s) it will apply.

Motivation 2: Too many scripts shown under the YouTube SPA. Some are not really "working" in the current URL

Currently the ON/OFF is 100% equal to the @match which is not enough for SPA

I want some ways to grey out the option so that user can know that it is not applying to the current page.
But this can be wrong (code is actually executing) => might be just some lighter/darker colors.
so I hope that there can be some config to make the script go up/down in the menu.

Screen Shot 2024-03-12 at 12 37 46

Proposed Solution

In addition to @match, hope there can be @match-active @match-inactive

It can handle the SPA history state change and popstate change as well.
If @match-active is fulfilled (supposed @match is matched first), the script row will be shown in a HIGHER position (or color highlight)
If @match-inactive is fulfilled (supposed @match is matched first), the script row will be shown in a LOWER position (or fade-out color)

these are just for the display in the menu. no effect on the actual JS execution.

Use Cases

Example Script: https://greasyfork.org/en/scripts/489605-youtube-watch-later-remove-button-on-hover/code


// ==UserScript==
// @name         YouTube Watch Later Remove Button on Hover
// @namespace    http://tampermonkey.net/
// @version      0.6.1
// @description  Show a remove button on hover over video thumbnails in the Watch Later list
// @license MIT
// @match        https://www.youtube.com/*
// @match-active        https://www.youtube.com/playlist?list=WL
// @run-at              document-start
// @grant               none
// @inject-into         page
// ==/UserScript==
@cyfung1031 cyfung1031 changed the title [Feature] Higher/Lower Order (or Grey Out) for the script not applying the current URL in SPA [Feature] Higher/Lower Order (or Grey Out) for the script (not) applying the current URL in SPA Mar 12, 2024
@cyfung1031 cyfung1031 changed the title [Feature] Higher/Lower Order (or Grey Out) for the script (not) applying the current URL in SPA [Feature] Higher/Lower Order (or Highlight/Grey Out) for the script (not) applying the current URL in SPA Mar 12, 2024
@tophf
Copy link
Member

tophf commented Mar 12, 2024

We can't know if a script is not active on the current SPA route, because it depends on its inner logic. The document is the same for a SPA, so Violentmonkey cannot "activate" or "deactivate" a running script. Such script can signal its state via GM_registerMenuCommand.

@tophf tophf closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@tophf tophf reopened this Mar 12, 2024
@tophf
Copy link
Member

tophf commented Mar 12, 2024

Ah, you already mentioned that. Geez I'm so impatient, sorry.

@tophf
Copy link
Member

tophf commented Mar 12, 2024

We won't implement @match-active idea because as I explained above we can't be sure the script is really active or inactive, so it's wrong to just trust it blindly.

Maybe we can add GM_setMenuState which will do something to the script name in the popup or add/change its icon?
@gera2ld

@gera2ld
Copy link
Member

gera2ld commented Mar 12, 2024

Yeah sounds like a good idea.

@cyfung1031
Copy link
Contributor Author

cyfung1031 commented Mar 13, 2024

We can't know if a script is not active on the current SPA route, because it depends on its inner logic. The document is the same for a SPA, so Violentmonkey cannot "activate" or "deactivate" a running script. Such script can signal its state via GM_registerMenuCommand.

Yes. the idea is that, there can be some ways to move the script upwards or downwards as the script is not really applying to the current page URL.

// @xxxxxxxx        https://www.youtube.com/playlist?list=WL

can help people to know which URL is applying on.

Other ways (like GM_setMenuState as you mentioned) are also acceptable although config inside the program makes it less noticeable to the general users.

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

3 participants