3

I found that I can install a Greasemonkey userscript in chrome by navigating to chrome://chrome/extensions/ first then dragging the *.user.js file onto this page.

Do I need to drag this script onto this page every time I change the script? What process should I use to reload my changed userscript as I change the script and want to see the changes?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Phil
  • 46,436
  • 33
  • 110
  • 175

2 Answers2

1

For just plain *.user.js files, yes, you must drag it (reinstall) each time you make a change.

However, if you manually create a folder structure and your own manifest.json file, as shown in the Controlling the Script and name section of this answer, then all you have to do is click the Reload link after each change -- or press CtrlR.

I usually keep the extensions page open in a different window, so I can quickly AltTab to the Reload link and back.

Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • Instead of having open *yet another window*, I strongly recommend an extension I wrote: It adds a button near the wrench, which reloads the extension on click. Then, you can just alt+Tab between your editor and Chrome to quickly reload the extension and see changes. See [this answer](http://stackoverflow.com/a/9645435/938089?how-do-i-auto-reload-a-chrome-extension-im-developing) for details (explanation on how the extension works + source code). – Rob W Sep 29 '12 at 07:50
  • @RobW, sounds promising, but it also sounds like you have to click? What I like about having Chrome's *Extensions* page open is that I can reload with 3 quick sets of keystrokes and never touch the mouse. – Brock Adams Sep 29 '12 at 08:38
  • You have to click indeed, but that's a design choice (I prefer a clear button over some obscure shortcut). It's also possible to bind a shortcut. The main reason for creating the extension is that I can switch between editor and Chrome with Alt+Tab, and reload the extension with one action (click), opposed to Alt+Tab to Chrome, Switch to tab, scroll down to extension, click Reload, switch back to tab where the Content script ought to be active (When I click on Reload, Chrome jumps up due to `#`). – Rob W Sep 29 '12 at 10:09
  • Not quite my workflow, but I imagine you do more Chrome work than me. I have 2 Chrome *windows* open, not tabs. So, it's (1) edit (2) alt-tab, alt-tab to extensions window (3) press Ctrl-R, (4) alt-tab, alt-tab to target window (5) Press F5. ... It's all lightning fast and I don't need to click (or mouse) at all. – Brock Adams Sep 29 '12 at 12:06
0

My approach is to develop under Firefox and then only move to Chrome and any other browsers I support at the end, when it's time to ensure my updates haven't broken something on secondary platforms.

The reason doing it in Firefox helps is that, once a Greasemonkey script has been installed, you can edit the installed file(s) in the gm_scripts folder and they'll get picked up next time you reload the page.

This even works for multi-file scripts using things like CoffeeScript... you just set things up so that whatever you use to generate your final file operates in "watch for changes and regenerate" mode and uses the installed gm_scripts path as the output file.

ssokolow
  • 14,938
  • 7
  • 52
  • 57