how to Use the Tampermonkey API from the Chrome console

本文介绍了一种方法,用于将GreaseMonkey (GM) API中的特定函数暴露给全局作用域,使得这些函数可以在任意页面上被调用。通过修改指定的用户脚本并在支持的网站上激活Tampermonkey,开发者可以轻松地使用这些GM函数。

 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值