手机chrome查看源代码_如何查看Chrome扩展程序的源代码

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

手机chrome查看源代码

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

Every Chrome extension that you install on your computer is actually constructed out of a special zip file that contains files and folders of Javascript code and other resources. The great thing is that you can actually look into the source code of an extension and see what it is really doing.

实际上,您计算机上安装的每个Chrome扩展程序都是由一个特殊的zip文件构建而成的,该文件包含JavaScript代码和其他资源的文件和文件夹。 很棒的事情是,您实际上可以查看扩展的源代码,并查看扩展的实际作用。

The problem with browser extensions is that so many of them are spying on you, inserting ads into your browser, or doing all sorts of other nefarious things. So if you want to check into the source code yourself, these are the two easy ways to do that.

浏览器扩展的问题在于, 有太多这样的扩展在监视您在浏览器中插入广告进行其他各种邪恶的事情 。 因此,如果您想亲自检查源代码,这是两种简单的方法。

Luckily there’s even a way to see the source code of an extension before you install it, although sadly that way requires installing an extension. Keep reading for all the details.

幸运的是,甚至可以安装扩展之前查看扩展的源代码,尽管遗憾的是,这种方法需要安装扩展。 继续阅读所有细节。

在硬盘上查找Chrome扩展程序源代码 (Find a Chrome Extension Source Code on Your Hard Drive)

The first method is used to view the source code of extensions that are currently installed in your Google Chrome Browser. Begin by navigating to the “chrome://extensions/” page. Alternatively, you can click on the three horizontal bars on the top right of the Chrome window and then click on the “More tools” option then click on “Extensions”.

第一种方法用于查看Google Chrome浏览器中当前安装的扩展程序的源代码。 首先导航到“ chrome:// extensions / ”页面。 或者,您可以单击Chrome窗口右上角的三个水平栏,然后单击“更多工具”选项,然后单击“扩展”。

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

Now that you are on your extensions page, you will need to tick the checkbox on the top right of the page that says “Developer mode” and find the ID for the extension you want the source code for. For the purposes of this demonstration, we will use the ID for “AdBlock” which is “ID: gighmmpiobklfepjocnamgkkbiglidom”

现在您已经在扩展程序页面上,您将需要勾选页面右上方的复选框,即“开发人员模式”,并找到您想要源代码的扩展程序的ID。 在本演示中,我们将使用“ AdBlock”的ID,即“ ID:gighmmpiobklfepjocnamgkkbiglidom”

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

Now that you know the ID of the extension, you will need to open Windows explorer by opening any folder or pressing the “Windows button” and “E” at the same time.

现在您知道扩展的ID,您将需要通过打开任何文件夹或同时按“ Windows按钮”和“ E”来打开Windows资源管理器。

Once there, type in the following into the location bar:

到达后,在位置栏中输入以下内容:

%localappdata%

%localappdata%

Now you’ll need to navigate down through the folders like this: Google -> Chrome -> User Data -> Profile -> Extensions. In some cases your Profile folder might be called something different like Profile 1, so just keep that in mind as you browse down.

现在,您需要向下浏览以下文件夹:Google-> Chrome->用户数据->个人资料->扩展程序。 在某些情况下,您的Profile文件夹可能被称为Profile 1之类的名称,因此在浏览时请记住这一点。

Once you are there, you should be able to see a bunch of folders with really long names, and one of them will match the extension ID you are looking for.

到达那里后,您应该能够看到一堆名称非常长的文件夹,其中一个将与您要查找的扩展名ID匹配。

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

Once you enter this folder, you should see another folder titled with the version of the extension. Simply double click on that icon again to see all the files and folders associated with your extension’s source code.

输入此文件夹后,您应该会看到另一个标题为扩展名的文件夹。 只需再次双击该图标即可查看与扩展程序源代码关联的所有文件和文件夹。

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

使用Chrome扩展程序源代码查看器 (Using the Chrome Extension Source Code Viewer)

In this method, you will need to download this extension that allows you to view the source code or CRX file for any extension in the Google Web Store.

使用这种方法,您将需要下载此扩展程序该扩展程序允许您查看Google Web Store中任何扩展程序的源代码或CRX文件。

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

Once the extension has been installed, you should see a popup confirmation dialog like the one below.

安装扩展程序后,您应该会看到一个弹出确认对话框,如下所示。

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

Now that it is installed, you can go into the Google Chrome Web Store and view the source code of any app. Just click on the yellow icon in the location bar and you’ll be given a choice to either download the file as a zip file or view it online.

安装完成后,您可以进入Google Chrome网上应用店并查看任何应用程序的源代码。 只需单击位置栏中的黄色图标,您就可以选择将文件下载为zip文件或在线查看。

If you download as a zip file, you can just unzip the file and view it using any regular text file viewer. Alternatively, if you decide to view the source code online, you will see something more along these lines in a new Chrome Tab.

如果下载为zip文件,则只需解压缩文件并使用任何常规文本文件查看器进行查看。 另外,如果您决定在线查看源代码,则将在新的Chrome标签中看到这些内容。

手机chrome查看源代码_如何查看Chrome扩展程序的源代码

That’s all there is to it.

这里的所有都是它的。

翻译自: https://www.howtogeek.com/198964/how-to-view-the-source-code-of-a-chrome-extension/

手机chrome查看源代码