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

Should scripts be re-running when going backwards and forwards though history? #2705

Open
vzjrz opened this issue Nov 19, 2017 · 7 comments
Open

Comments

@vzjrz
Copy link

vzjrz commented Nov 19, 2017

I don't know if this is a greasemonkey or firefox bug but after the new updates I noticed some unusual behavior from my scripts.
Scripts are running again on pages where they already ran when using the back and forward arrows. I checked with the old versions of gm and firefox and that's not how they used to work. In the old version of firefox I guess pages would completely rerender and therefore when scripts reran they would run on unmodified pages.

// ==UserScript==
// @name        Test
// @namespace     test
// @include       *://en.wikipedia.org/*
// @require       https://code.jquery.com/jquery-3.1.1.min.js
// @description test
// ==/UserScript==
(function () {
  'use strict';

   let tests = $('#test');
  
  // Needed with new updates:
  if (tests.length !== 0) {
    console.log('Previous test div detected');
  }
  
  $('body').append('<div id="test">');
})();
  1. Install this script and go to https://en.wikipedia.org/wiki/Main_Page
  2. Click on a link to go to a different url
  3. Go back
  4. Go forward
  5. Go back

In gm 3.17 this script would never print Previous test div detected but in gm 4.0 going forwards and back multiple times just keeps adding more and more divs.
Is this an intended change?

@Sxderp
Copy link
Contributor

Sxderp commented Nov 19, 2017

Not able to reproduce with FF 59.0a1 + Latest master.

@vzjrz
Copy link
Author

vzjrz commented Nov 19, 2017

Man I should really test things out before I write bug reports. I found the bug on another site and tried to write simple case for google.com but checking that out now it doesn't appear to work there. I have updated the steps to reproduce it.

@Sxderp
Copy link
Contributor

Sxderp commented Nov 19, 2017

Cool. Was able to reproduce. I believe I know a fix. Will submit shortly.

@arantius
Copy link
Collaborator

This is probably complicated by fastback, which if it applies then the answer is no, but if it does not then the answer is yes.

@Sxderp
Copy link
Contributor

Sxderp commented Nov 19, 2017

In response to the comment on the pull (I think it's better to respond here then a commit comment).
I see your point, and it can somewhat be forcibly reproduced. The initial post in this issue had used google as a test subject. And for whatever reason google searches don't work with fastback (thus the original problem never appeared).

With the change performing a back / forward on google does not see the script executed. No div was added to the DOM.

@Sxderp
Copy link
Contributor

Sxderp commented Nov 19, 2017

I had a thought and just tested with #2635 and it looks like that also solves the forward/backward button issue.

@arantius arantius added this to the 4.x milestone Nov 21, 2017
@arantius arantius removed this from the 4.x milestone Jan 19, 2018
@Strubbl
Copy link

Strubbl commented Apr 13, 2021

At the moment with Firefox 87 the behaviour is like this:

  1. visit site x and the GM script gets executed
  2. visit site y
  3. use FF87's history back button
  4. site x is shown again, but the GM script is not executed again and the page looks like it was never executed before

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

4 participants