If you open the browser console on the VKontakte page, then enter

$ 

We will see the jQuery object in the output, but if we embed it on the UserScript page:

 function append() { console.log( $ ); }; window.setInterval( append, 1000 ); 

then exactly once a second the error undefined will fall into the console.
In what namespace to look for jQuery and how can it be, because UserScript runs in a global context and in the same context does the work take place if you directly enter commands into the console?

  • I deleted my answer because I misunderstood the cause of the error. (Checked on the site with jQuery, and not on the very VC). In the evening I will look in more detail. I leave a dump of rules from your comment: {"name": "VK music", "urlRegex": "^ vk.com", "urlExcludeRegex": "", "ena ... > \ nfunction appendMusicNow () {\ n \ u0020 \ u0020console.log ($); \ n \ u0020 \ u0020if (typeof ($) == \ "undefined \") return; \ n \ u0020 \ u0020console.log (\ "ok \"); \ n}; \ n \ n \ nwindow.setInterval (appendMusicNow, 1000); \ n </ SCRIPT> "," js ":" "," filters ": []} - VenZell
  • Unfortunately, it was not possible to find a solution. - VenZell
  • there $ is not jQuery but function $ (selector, [startNode]) {[Command Line API]} respectively, we write window.my _ $ = $ from the console; function append () {console.log (window.my_ $); }; window.setInterval (append, 1000); - zb '
  • 9
    Vkontakte is not a variable window.$ . What is displayed is the console api ( developer.chrome.com/devtools/docs/commandline-api ). In FF a similar thing like. - Dmitry Manannikov

2 answers 2

Commands from the console are executed in the context of window + the browser's API available. What you see is a link to one of API browser's API methods. You can get acquainted with the API system in the documentation of the corresponding browser.
VK site itself does not use jQuery library in its work.

    Perhaps not connected jQuery , connect yourself:

     // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js