Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从cjs chrome扩展名读取js脚本文件_Javascript_Google Chrome_Iis_Google Chrome Extension - Fatal编程技术网

Javascript 如何从cjs chrome扩展名读取js脚本文件

Javascript 如何从cjs chrome扩展名读取js脚本文件,javascript,google-chrome,iis,google-chrome-extension,Javascript,Google Chrome,Iis,Google Chrome Extension,我为网站安装了Google chrome扩展插件cjs自定义JavaScript 如果我在cjs编辑器中编写脚本,脚本工作正常: 我在js文件中编写了脚本,并将其放入IIS中,如下所示: 打开IIS管理器 右键单击默认网站 添加应用程序 别名=谷歌脚本 物理路径:例如C:\scripts\google 我创建了一个googleScript.js文件,并将其保存在C:\scripts\google中。该文件的内容是:alertGoogle; 我单击了Connect As并选择Application

我为网站安装了Google chrome扩展插件cjs自定义JavaScript

如果我在cjs编辑器中编写脚本,脚本工作正常:

我在js文件中编写了脚本,并将其放入IIS中,如下所示:

打开IIS管理器 右键单击默认网站 添加应用程序 别名=谷歌脚本 物理路径:例如C:\scripts\google 我创建了一个googleScript.js文件,并将其保存在C:\scripts\google中。该文件的内容是:alertGoogle; 我单击了Connect As并选择Application user pass through authentication 我在IIS中打开了位于googleScript中的默认文档,并添加了一个名为googleScript.js的新默认文档 当我右键单击googleScript并选择ManageApplication->Browse时,一个新的网页正在用我编写的脚本打开。页面的url为 现在回到cjs扩展,而不是谷歌;我写了//localhost/googleScript/googleScript.js;。 调用脚本文件时,警报不再工作。从cjs chrome扩展名调用脚本文件的正确方法是什么?

Read

在继续之前

我创建了一个小型应用程序,您可以使用它在应用程序/扩展中试验这个想法

现在,这是一种在线获取和保存外部脚本源的方法

var download_to_textbox = function (url, el) {
      return $.get(url, null, function (data) {
        el.val(data)
      }, "text")
    };
获取脚本源代码并将其添加到文本区域

download_to_textbox('libraries/alertifyjs/css/alertify.min.css', $('.alertifyjs1'));
使用FileSaver.js保存文件-

阅读

在继续之前

我创建了一个小型应用程序,您可以使用它在应用程序/扩展中试验这个想法

现在,这是一种在线获取和保存外部脚本源的方法

var download_to_textbox = function (url, el) {
      return $.get(url, null, function (data) {
        el.val(data)
      }, "text")
    };
获取脚本源代码并将其添加到文本区域

download_to_textbox('libraries/alertifyjs/css/alertify.min.css', $('.alertifyjs1'));
使用FileSaver.js保存文件-


下面是我如何在Chrome 85上使用。永久性地这样做并不好,Chrome团队有充分的理由禁用对localhost的不安全请求

使能chrome://flags/allow-insecure-localhost 将其粘贴到URL栏中

加http://localhost 到chrome://flags/unsafely-treat-insecure-origin-as-secure 并启用它

重新启动Chrome

在终端窗口中,创建一个包含javascript文件的目录,比如说它叫my-script-file.js

通过cd'ing进入它并运行python3-mhttp.server

将此行添加到cjs:

默认情况下,python3-mhttp.server服务于端口8000

单击CJS弹出窗口左上角的保存
现在,您应该可以在Chrome开发工具的网络选项卡中看到对//localhost:8000/my-script-file.js的请求。

以下是我在Chrome 85上使用的方法。永久性地这样做并不好,Chrome团队有充分的理由禁用对localhost的不安全请求

使能chrome://flags/allow-insecure-localhost 将其粘贴到URL栏中

加http://localhost 到chrome://flags/unsafely-treat-insecure-origin-as-secure 并启用它

重新启动Chrome

在终端窗口中,创建一个包含javascript文件的目录,比如说它叫my-script-file.js

通过cd'ing进入它并运行python3-mhttp.server

将此行添加到cjs:

默认情况下,python3-mhttp.server服务于端口8000

单击CJS弹出窗口左上角的保存 现在,您应该可以在Chrome DevTools的网络选项卡中看到对//localhost:8000/my-script-file.js的请求