有没有办法在Chrome的JavaScript控制台中使用Tampermonkey's API

我想弄乱GM_xmlhttpRequest()GM_listValues()之类的功能。

最佳答案

  • 创建以下脚本:

    // ==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;
    
  • 打开可以激活Tampermonkey的任何页面(例如https://stackoverflow.com/)。
  • 打开开发人员工具->控制台。
  • 完成后,您现在可以使用导出的方法执行任何操作(从步骤1开始)。
  • 07-24 09:46
    查看更多