question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could't use @require resource in devtool when @grant is't none

See original GitHub issue
// @name        Test
// @namespace   test
// @match       *://*/*
// @grant       GM_addStyle
// @require     https://unpkg.com/jquery
// @run-at      document-start
// @version     1.0
// @author      -

when set @grant GM_addStyle, jQuery couldn’t use in the script. it works while @grant is none.

How to reproduce it?

  1. set @grant GM_addStyle
  2. use $ or jQuery in chrome devtool for debug
  3. jQuery is not defined

What is the expected result?

Could use jquery in the devtool.

What is the actual result?

jQuery is not defined.

What is the result in the upcoming release?

Environment

  • Browser:
  • Browser version:
  • Violentmonkey version:
  • OS:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tophfcommented, May 22, 2021

This is how userscripts work. Their window and global variables are sandboxed when @grant is not none.

0reactions
yola-0316commented, May 22, 2021

@tophf I’m testing in chrome, it not works. Maybe many sites have been used jQuery. I am used d3 do testing replace jQuery to avoid confusion.

Chrome version 90.0.4430.212 on windows 10. image image It works when change GM_addStyle to none.

Read more comments on GitHub >

github_iconTop Results From Across the Web

This userscript won't use the page's jQuery anymore ... - GitHub
This userscript won't use the page's jQuery anymore (even though there's '@grant none') and one of the @require rule (tablesorter) doesn't work either...
Read more >
Can't find javascript source map to debug in chrome devtools
When I open up resources.entry.js in the chrome debugger, I see the following. source map detected. However, I can't seem to actually find...
Read more >
react-devtools | Yarn - Package Manager
This package can be used to debug non-browser-based React applications (e.g. React Native, mobile browser or embedded webview, Safari). React DevTools ...
Read more >
The specified module 'Module Name' was not loaded because ...
Problem: When trying to import the PnP PowerShell module, I got an error message “Import-Module: The specified module 'SharePointPnPPowerShellOnline' was ...
Read more >
Azure Identity SDK (JS) How to Authenticate to User's Azure ...
I am not trying to grant users access to my app, but access to their own Azure account. Is InteractiveBrowserCredential what I should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found