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

What is the correct way of reloading scripts during development? #3079

Closed
AnnanFay opened this issue Apr 30, 2020 · 4 comments
Closed

What is the correct way of reloading scripts during development? #3079

AnnanFay opened this issue Apr 30, 2020 · 4 comments

Comments

@AnnanFay
Copy link

AnnanFay commented Apr 30, 2020

How do people reload scripts while editing them? I have tried looking online and in the issues here but cannot figure out the proper way of doing it.

I am currently using Firefox 56 from 2017 to do development because it's the latest version which will reload local script files as I edit them (GM3.17). I have the build process copy the scripts into the gm_scripts and it generally works. This is however a horrific 'solution'. I must be missing something obvious which other developers are doing.

What is the correct way to get a greasemonkey script to automatically reload during development when I edit it in an external file or when a file is generated from a build process?

@Cerberus-tm
Copy link

I'm not sure I understand: why would you want to reload a script? What does that mean? You don't mean reloading a web page?

@AnnanFay
Copy link
Author

AnnanFay commented Apr 30, 2020

@Cerberus-tm I write scripts by iteratively improving them. I need to run the script in the browser each time I make an edit to detect any mistakes I have made and see if my most recent changes had the intended effect. That way I know any mistakes are caused by the most recent changes.

  1. Write script
  2. Run in browser
  3. Detect bugs
  4. Fix bugs
  5. Go to 2

Repeat steps 2-4 a few hundred times because I make many mistakes.

In older firefox+GM versions reloading the page will also reload the script from disk. So I do mean reloading the web page, though that's just an implicit consequence of needing to reload the userscript.

@arantius
Copy link
Collaborator

arantius commented May 1, 2020

Scripts run at page load time. Reload the page.

(Most scripts modify the page, there's no "re-run the script" without reloading the page to give it a fresh page to modify, anyway.)

@arantius arantius closed this as completed May 1, 2020
@AnnanFay
Copy link
Author

AnnanFay commented May 1, 2020

So I do mean reloading the web page, though that's just an implicit consequence of needing to reload the userscript.

@arantius I do not mind reloading the page to reload the script and am not looking for this. How do I update the script?

I think you are misunderstanding my question. I am using Sublime Text to edit my script and I am using NPM and Grunt to compile a user.js file on the hard drive. I then need to update the script in the browser so I can test it.

How can I update the script which is stored in GM after editing it in a source code editor?

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

No branches or pull requests

3 participants