谷歌浏览器 - 扩展与应用程序 [英] Google Chrome - Extension vs App

查看:163
本文介绍了谷歌浏览器 - 扩展与应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将jQuery包含在用户本地存储中,并在用户页面加载时加载(搜索页面)



我从来没有对chrome做任何事情,所以我想从某种方式开始。作为一条经验法则:选择一个 /developer.chrome.com/apps/about_apps.htmlrel =nofollow noreferrer> app 如果你想开发一个独立的应用程序。如果您想与浏览器交互(例如修改网页),请构建扩展

在您的情况下,您肯定需要一个扩展名。




  • 更改起始页 - 在清单中使用 chrome_url_overrides 文件覆盖 newtab

  • 本地存储jQuery:尽管可以将jQuery存储在本地存储中, jQuery扩展名。

    要将它添加到用户的搜索页面,您必须使用内容脚本。默认情况下,内容脚本在与页面不同的执行环境中运行(文档的DOM被共享)。通常,这种行为是需要的。如果您真的想将jQuery库公开给页面中的脚本,请查看这个答案

    如果你真的想从远程位置加载一些脚本并将它用作内容脚本,阅读 Chrome扩展程序将外部JavaScript添加到当前页面的HTML



我不确定改变背景和标志的含义。如果您指的是浏览器的外观,唯一的选择是创建一个主题。这必须是一个单独的扩展名。


I want to modify chrome start page, change background and maybe logo.

I want to include jQuery in users local storage and load it while users page loads ( search page )

I never done anything with chrome so I want some way where to start. Do I go reading with apps or extensions?

解决方案

As a rule of thumb: Choose an app if you want to develop an (independent) application that can stand on its own. If you want to interact with the browser (e.g. modify a web page), build an extension.

In your case, you definitely need an extension.

  • Change start page - use chrome_url_overrides in the manifest file to override newtab.
  • Locally store jQuery: Although it's possible to store jQuery in local storage, you're probably fine with packaging jQuery with your extension.
    To add it to your user's "search page", you have to use a content script. By default, content scripts run in an execution environment that is different from the page (the document's DOM is shared though). Usually, this behavior is desired. If you really want to expose the jQuery library to the scripts in the page, take a look at this answer.
    If you really want to load some script from a remote location and use it as a content script, read Chrome extension adding external javascript to current page's html.

I'm not sure what you mean by "change background and maybe logo". If you're referring to the browser's appearance, the only option to do that is by creating a theme. This must be a separate extension.

这篇关于谷歌浏览器 - 扩展与应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆