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

with inject mode instant history.length is 1 more than it actually is #2364

Open
Owyn opened this issue Feb 28, 2025 · 0 comments
Open

with inject mode instant history.length is 1 more than it actually is #2364

Owyn opened this issue Feb 28, 2025 · 0 comments

Comments

@Owyn
Copy link

Owyn commented Feb 28, 2025

I have noticed my script can no longer detect when there is no back histry button on the page and it turned out that history.length returns 2 for userscripts when from browser console it returns 1 if the inject mode setting is turned to instant and the sandbox is JavaScript and the run at is document-start

example script:

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      2025-02-28
// @description  try to take over the world!
// @author       You
// @match        https://*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant        none
// @sandbox		JavaScript
// @run-at		document-start
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    console.error("history length: " + history.length);
})();

result:

Image

TM: 5.3.3
FireFox: 135.0.1 (64-bit)
Win: 10

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

1 participant