简体   繁体   English

如何将大量Javascript文件注入到CHROME扩展中?

[英]How to inject lots of Javascript files into CHROME EXTENSION?

I want to load lots of linked Javascript files by loading one core Javascript file. 我想通过加载一个核心Javascript文件来加载许多链接的Javascript文件。

There exist linked Javascript files. 存在链接的Javascript文件。


Core.js Core.js

sub_1.js, sub_2.js, sub_3.js, ......, sub_n.js sub_1.js,sub_2.js,sub_3.js,......,sub_n.js


How can I load these linked Javascript files into content script? 如何将这些链接的Javascript文件加载到内容脚本中?

There are so many Javascript files. 有太多的Javascript文件。 I want to load these by declaring only one core Javascript files. 我只想声明一个核心Javascript文件来加载它们。

I know ways to load each Javascript file. 我知道加载每个Javascript文件的方法。

[manifest.json]
....
"content_scripts": [
    {
      "matches": [....],
      "js": ["core.js", "sub_1.js", "sub_2.js"....]
    }
  ],
....

or 要么

[background.html]
<script>
...
chrome.tabs.executeScript(null, { file: "core.js" }, function() {
  chrome.tabs.executeScript(null, { file: "sub_1.js" }, function() {
    chrome.tabs.executeScript(null, { file: "sub_2.js" }, function() {
      ....
    });
  });
});
...

My final objective is to inject TinyMCE into content script. 我的最终目标是将TinyMCE注入内容脚本。

I want to solve this problem in advance. 我想提前解决这个问题。

Help me please. 请帮帮我。

Take a look at RequireJS. 看一下RequireJS。 http://requirejs.org/ That should do what you want. http://requirejs.org/那应该做你想要的。

I would go for apache ant , create a build script which will pack all needed js-files into one single file. 我将使用apache ant ,创建一个构建脚本,它将所有需要的js文件打包到一个文件中。

The necessary code is shipped with the tinymce developer version. tinymce开发人员版本随附了必要的代码。 Here is some more information: http://www.tinymce.com/forum/viewtopic.php?id=27812 . 这是一些更多信息: http : //www.tinymce.com/forum/viewtopic.php?id=27812

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM