Use the Tampermonkey API from the Chrome console?

一个人想着一个人 提交于 2019-12-03 21:47:34

问题


Is there any way use Tampermonkey's API in Chrome's JavaScript console?

I want to mess with functions like GM_xmlhttpRequest() and GM_listValues().


回答1:


  1. Create the following script:

    // ==UserScript==
    // @name       Exports some GM functions
    // @namespace  Whatever
    // @match      *
    // ==/UserScript==
    // WARNING: Any page can now use these methods! Be careful,
    // or change "@match *" to "@match https://example.com" and
    // visit https://example.com to test the API.
    unsafeWindow.GM_xmlhttpRequest = GM_xmlhttpRequest;
    unsafeWindow.GM_listValues = GM_listValues;
    
  2. Open any page where Tampermonkey can be activated ( https://stackoverflow.com/ for instance).

  3. Open the Developer tools -> Console.
  4. Done, you can now do whatever you want with the exported methods (from step 1).



来源:https://stackoverflow.com/questions/14059078/use-the-tampermonkey-api-from-the-chrome-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!