chrome 扩展程序

因为最近需要使用vue或别的一些扩展程序便利开发,

但无法FQ,只能到github下源码自己安装,而且不

懂扩展程序的原理,很容易安装出问题。

API:360翻译的文档

chrome的扩展文件主要看配置文件manifest.json。

只要这个对,一般都没有问题。

 写好的chrome扩展程序直接点击已解压扩展程序加载即可使用。

扫描二维码关注公众号,回复: 1560341 查看本文章

github:测试例子

资料:干货

对于一次性请求与响应模式,chrome.runtime.sendMessage(obj, function(response){})是从content scripts发生请求消息给Google Chrome扩展程序页面。

从Google Chrome扩展程序页面发送请求消息给content scripts的时候,需要给出当前tab的ID。

chrome.tabs.query(
    {active: true, currentWindow: true}, 
    function(tabs) {
          chrome.tabs.sendMessage(
            tabs[0].id, 
            {greeting: "hello"}, 
            function(response) {
                    console.log(response.farewell);
        });
});

猜你喜欢

转载自www.cnblogs.com/zhangzhicheng/p/9169246.html