how to Use the Tampermonkey API from the Chrome console

时间:2023-03-08 22:23:27

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 ( http://*.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).