问题
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:
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;
Open any page where Tampermonkey can be activated ( https://stackoverflow.com/ for instance).
- Open the Developer tools -> Console.
- 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