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

v0.2: observe page changes and inject the script before page load #3

Merged
merged 6 commits into from
Feb 9, 2023

Conversation

Oreoxmt
Copy link
Owner

@Oreoxmt Oreoxmt commented Feb 9, 2023

  • Fix v0.1: the userscript fails to work after switching pages in GitHub #2
  • Uses MutationObserver to observe page changes and triggers EnsureFileLink and EnsureCommentButton functions
  • Add a mark to specify elements created by this script
  • Check existing elements before adding a comment button and File element
  • Use @run-at document-start to inject the script as soon as possible

- add a new metadata @run-at
- the script will be injected before page load
- Documentation: https://www.tampermonkey.net/documentation.php?locale=en#meta:run_at

Signed-off-by: Aolin <aolinz@outlook.com>
Signed-off-by: Aolin <aolinz@outlook.com>
…s no comment-button element

Signed-off-by: Aolin <aolinz@outlook.com>
- rename from CreateFileLink to EnsureFileLink
- add File element only when there is no file-link-span element

Signed-off-by: Aolin <aolinz@outlook.com>
…serving page changes

Signed-off-by: Aolin <aolinz@outlook.com>
Signed-off-by: Aolin <aolinz@outlook.com>
@Oreoxmt Oreoxmt merged commit e7df2f8 into main Feb 9, 2023
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

Successfully merging this pull request may close these issues.

v0.1: the userscript fails to work after switching pages in GitHub
1 participant