Skip to content

Not working on Violentmonkey #1

Closed

Description

@Leny1337

Script works fine on Greasemonkey or Tampermonkey, but it's not working (only sometimes starts, but mostly not loading) on Violentmonkey.
I think problem is wrong execution order.
Here you can find some informations about that: violentmonkey/violentmonkey#1157
For me setting "Run-At" with document-end fixes black theme, but not everything. It should be fixed inside script code.

Activity

  1. bearbyt3z commented on Apr 23, 2021

    @bearbyt3z
    Collaborator

    @run-at parameter is set to document-start intentionally, please see this commit: cd1f0e8
    The problem was that without such a configuration there was a white background flash before the site was loaded, so the "run-at document-end" is not a solution here.
    The link provided states that document.documentElement is guaranteed to be present in "run-at document-start" configuration, and this is exactly how Tweaker inserts its own style:

    (document.head || document.documentElement).insertAdjacentHTML('afterend', `<style id="pepper-tweaker-style">${css}</style>`);

    Unfortunately I have never used Violentmonkey and I'm testing script mainly in Tampermonkey, so probably the easiest solution would be switching to Tampermonkey/Greasemonkey until Violentmonkey will fix this issue.

  2. Leny1337 commented on Apr 23, 2021

    @Leny1337
    Author

    Yeah, didn't looked at whole code, it was just a dirty fix. As you can read on issue I've mentioned, Violentmonkey has "fixed" an issue with timings, so Tampermonkey/Greasemonkey should be fixed, because they are working wrong from the standards perspective 😄

  3. bearbyt3z commented on Apr 23, 2021

    @bearbyt3z
    Collaborator

    I don't think this is related to timings in Tampermonkey (or Greasemonkey). The problem is that when injecting CSS via JavaScript in a userscript after the document is loaded, there is a small amount of time when the original CSS is applied. So to avoid such an issue the proper CSS would have to be loaded before the original one via document.documentElement and the "run-at document-start" configuration.

  4. Leny1337 commented on Apr 28, 2021

    @Leny1337
    Author

    Ok, got it. Thanks for the explanation.

    FYI setting manually run-at document-body in Violentmonkey (v2.12.14) works fine now with this script (no issues with reloading page multiple times, no issues with dark mode).

    I'm closing this issue for now.

  5. bearbyt3z commented on Apr 28, 2021

    @bearbyt3z
    Collaborator

    @Leny1996 Thanks for reporting the solution. I will add a comment to the README file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions