script only runs when page is reloaded

1,648 views
Skip to first unread message

neilw

unread,
May 6, 2012, 3:24:23 PM5/6/12
to greasemon...@googlegroups.com
<this question previously posted to StackOverflow>

I have a script to add some links to a changesets page in Rally.  The script works fine, but only when I reload the page.  If I just navigate (via links, forward/back buttons, etc.) to a matched page, the script does not run, but it is listed in the Greasemonkey menu, with a checkmark next to it.

So it seems like the matching is working fine, but for whatever reason the page is not firing the DOMContentLoaded event when I navigate to the page.  I tried @run-at document-start just for kicks, and it made no difference.

I'm not sure how to either (a) figure out what's going on, or (b) fix this.

Here is the @include rule, which seems to be working fine:
include        /^https://.*\.rallydev\.com/.*/changesets$/

And here is a URL that I'm testing with:
https://rally1.rallydev.com/#/4745909548/detail/userstory/6138899084/changesets

I wonder if the hash in the URL is causing a problem somehow, but I can't understand why it would work only on a reload.  Any thoughts?

Thanks,
Neil

Anthony Lieuallen

unread,
May 6, 2012, 5:00:06 PM5/6/12
to greasemon...@googlegroups.com
Can you provide the exact script behaving this way?  Or, ideally, a reduced test case which exhibits this behavior, on a page that doesn't require a login?

If so, it would be great if you could file this in our issue tracker:
https://github.com/greasemonkey/greasemonkey/issues

--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/greasemonkey-users/-/fBB_haNojzcJ.
To post to this group, send email to greasemon...@googlegroups.com.
To unsubscribe from this group, send email to greasemonkey-us...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.

neilw

unread,
May 6, 2012, 8:23:10 PM5/6/12
to greasemon...@googlegroups.com
The script contents don't seem to matter; I can demonstrate the problem with this:

// ==UserScript==
// @name           test_reload_problem
// @namespace      neil.weinstock.test
// @description    Just a simple script to demonstrate the problem
// @include        /^https://.*\.rallydev\.com/.*/changesets$/
// ==/UserScript==

alert("Script ran");

I don't know how to reproduce it on any other page than the ones I'm using, though, so I am setting up a free Rally trial account which I can give you access to, and I should be able to let you experience it there (crosses fingers).  The Rally account will only be up for 30 days, but hopefully that should be enough for you to see what the problem is.

Once I have the account ready, I'll file this on Github.

- Neil

On Sunday, May 6, 2012 5:00:06 PM UTC-4, Anthony Lieuallen wrote:
Can you provide the exact script behaving this way?  Or, ideally, a reduced test case which exhibits this behavior, on a page that doesn't require a login?

If so, it would be great if you could file this in our issue tracker:
https://github.com/greasemonkey/greasemonkey/issues

On Sun, May 6, 2012 at 3:24 PM, neilw <neil.we...@gmail.com> wrote:
<this question previously posted to StackOverflow>

I have a script to add some links to a changesets page in Rally.  The script works fine, but only when I reload the page.  If I just navigate (via links, forward/back buttons, etc.) to a matched page, the script does not run, but it is listed in the Greasemonkey menu, with a checkmark next to it.

So it seems like the matching is working fine, but for whatever reason the page is not firing the DOMContentLoaded event when I navigate to the page.  I tried @run-at document-start just for kicks, and it made no difference.

I'm not sure how to either (a) figure out what's going on, or (b) fix this.

Here is the @include rule, which seems to be working fine:
include        /^https://.*\.rallydev\.com/.*/changesets$/

And here is a URL that I'm testing with:
https://rally1.rallydev.com/#/4745909548/detail/userstory/6138899084/changesets

I wonder if the hash in the URL is causing a problem somehow, but I can't understand why it would work only on a reload.  Any thoughts?

Thanks,
Neil

--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/greasemonkey-users/-/fBB_haNojzcJ.
To post to this group, send email to greasemonkey-users@googlegroups.com.
To unsubscribe from this group, send email to greasemonkey-users+unsub...@googlegroups.com.

LWChris@LyricWiki

unread,
May 6, 2012, 8:38:16 PM5/6/12
to greasemon...@googlegroups.com
Am 07.05.2012 02:23, schrieb neilw:
> // @include /^https://.*\.rallydev\.com/.*/changesets$/

As this pattern can also be modelled with usual placeholders, it might
be worth to test if this behaviour also occurs if you don't use regular
expressions. Please try this rule:

> // @include https://*.rallydev.com/*/chagesets

RegExp is a rather new feature and the placeholders worked flawlessly
for me so far.

Chris

Neil Weinstock

unread,
May 6, 2012, 9:12:25 PM5/6/12
to greasemon...@googlegroups.com
Thanks for the suggestion.

I just tried it, and it behaves exactly the same. Really, though, I should have written the rule your way in the first place; the regexp is a bit of a sledgehammer in this case.

For matching pages, I'm always seeing the script appear in the Greasemonkey menu with a checkmark, even when the script does not execute. I would think that means that the matching rule is working properly.

But I'll try anything you suggest at this point. Next? :)

- Neil
> --
> You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
> To post to this group, send email to greasemon...@googlegroups.com.
> To unsubscribe from this group, send email to greasemonkey-us...@googlegroups.com.

Anthony Lieuallen

unread,
May 6, 2012, 9:15:37 PM5/6/12
to greasemon...@googlegroups.com
The real right thing to do here is use @match, which guarantees that the ".*" in the host name won't leak into the path name.  For now, I'll look at the appropriate page & script when I have access.

Neil Weinstock

unread,
May 7, 2012, 11:29:42 AM5/7/12
to greasemon...@googlegroups.com
I believe my problem has been solved on Stack Overflow.  The page data was being AJAXed in, although it didn't really look like it to me until I checked out the net logs in Firebug.  I was fooled by the way the code looked.

So now I'm using waitForKeyElements() script and it seems to be working.

The funny thing is, I was already using something like that in my script to wait until the required content was loaded, but now I'm matching on the entire Rally domain, so it's always checking in the background until it finds changesets on the page.  Not as pretty as I would like, but probably no other solution, so I'll take it.

Thanks a bunch for your help.

- Neil

Matt Sargent

unread,
May 7, 2012, 7:27:09 PM5/7/12
to greasemon...@googlegroups.com
The use of the "#" in the URL has lately become a common way to pass data into AJAXed pages.
Reply all
Reply to author
Forward
0 new messages